Fix failing logout tests #376
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: RAVS TESTS - DEV | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
schedule: | |
- cron: "30 7 * * *" | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment (e.g., dev, staging)' | |
required: true | |
type: choice | |
options: | |
- dev | |
- qa | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Stop and remove all containers | |
run: | | |
docker stop $(docker ps -q) || true | |
docker rm $(docker ps -aq) || true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build the Docker image | |
run: docker build -t playwright-tests -f Docker/tests.dockerfile . | |
- name: Run Docker container | |
id: run-container | |
run: | | |
docker run -d --name playwright-tests \ | |
--memory 8g \ | |
-e RAVS_PASSWORD="${{ secrets.RAVS_PASSWORD }}" \ | |
-e HEADLESS_MODE="true" \ | |
-e TEST_ENVIRONMENT="${{ inputs.environment }}" \ | |
-e BROWSER="chrome" \ | |
-e MARKER="" \ | |
-e AGENTS=3 \ | |
-p 5050:5050 \ | |
playwright-tests | |
while true; do | |
if docker logs playwright-tests 2>&1 | grep -q "Server started "; then | |
echo "Report successfully generated." | |
break | |
else | |
echo "Waiting for the Allure report to be generated..." | |
sleep 5 | |
fi | |
done | |
- name: Find and upload Allure report directory | |
run: | | |
container_id=$(docker ps -qf "name=playwright-tests") | |
allure_directory=$(docker exec $container_id find / -path /proc -prune -o -type d -name "allure-report" -print -quit) | |
if [[ -n "$allure_directory" ]]; then | |
temp_dir="$(mktemp -d)" | |
docker cp "$container_id":"$allure_directory"/. "$temp_dir" | |
(cd "$(dirname "$temp_dir")" && tar -czf allure-report-${{ inputs.environment }}.tar.gz -C "$(basename "$temp_dir")" .) | |
echo "::set-output name=allure_report_archive::$(realpath "$(dirname "$temp_dir")/allure-report-${{ inputs.environment }}.tar.gz")" | |
echo "ALLURE_REPORT_ARCHIVE=$(realpath "$(dirname "$temp_dir")/allure-report-${{ inputs.environment }}.tar.gz")" >> $GITHUB_ENV | |
else | |
echo "Allure directory not found or is empty." | |
fi | |
- name: Upload Allure report archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: allure-report-${{ inputs.environment }} | |
path: ${{ env.ALLURE_REPORT_ARCHIVE }} | |
- name: Retrieve and extract Allure report artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: allure-report-${{ inputs.environment }} | |
path: allure-report-${{ inputs.environment }} | |
- name: Unzip the tar file | |
run: | | |
tar -xzvf allure-report-${{ inputs.environment }}/allure-report-${{ inputs.environment }}.tar.gz -C allure-report-${{ inputs.environment }} | |
- name: Move Allure report files | |
run: | | |
mv allure-report-${{ inputs.environment }}/* . | |
- name: Get branch name | |
id: get_branch_name | |
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV | |
- name: Set destination branch for GitHub Pages | |
id: set-destination-branch | |
run: echo "DESTINATION_BRANCH=gh-pages-${{ env.BRANCH_NAME }}" >> $GITHUB_ENV | |
- name: Deploy Allure report to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: . | |
destination_branch: gh-pages-${{ inputs.environment }} | |
- name: Output GitHub Pages URL | |
run: | | |
echo "GitHub Pages URL: https://nhsdigital.github.io/ravs-tests/#" | |
- name: Notify Slack on success | |
if: success() | |
run: | | |
BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||') | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"Ravs tests finished running for the ${{ inputs.environment }} environment on branch $BRANCH_NAME! Check the Allure report: https://nhsdigital.github.io/ravs-tests/gh-pages-${{ inputs.environment }}/\"}" ${{ secrets.SLACK_WEBHOOK_URL }} |