RAVS TESTS - QA #28
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: Run Tests and Publish Allure Report | |
on: | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- 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@v1 | |
- 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="qa" \ | |
-e BROWSER="chrome" \ | |
-e MARKER="logout" \ | |
-e AGENTS=3 \ | |
-p 5050:5050 \ | |
playwright-tests | |
while true; do | |
if docker logs playwright-tests 2>&1 | grep -q "Report successfully generated to allure-report"; then | |
echo "Report successfully generated." | |
break | |
else | |
echo "Waiting for the Allure report to be generated..." | |
sleep 5 | |
fi | |
done | |
- name: Start Docker container | |
run: | | |
docker start playwright-tests | |
sleep 5 | |
- name: Find and upload Allure report directory | |
run: | | |
container_id=$(docker ps -qf "name=playwright-tests") | |
echo "Container ID: $container_id" | |
allure_directory=$(docker exec $container_id find / -type d -name "allure-report" -print -quit) | |
echo "Allure Directory: $allure_directory" | |
if [[ -n "$allure_directory" ]]; then | |
echo "ALLURE_DIRECTORY=$allure_directory" >> $GITHUB_ENV | |
ls -la $allure_directory | |
fi | |
# Create a temporary directory to store the contents | |
temp_dir="$(mktemp -d)" | |
echo "Temporary Directory: $temp_dir" | |
# Suspend all processes within the container | |
docker exec $container_id pkill -STOP -u root | |
# Lock the Allure report directory | |
docker exec $container_id chmod 400 "$allure_directory" | |
# Copy the contents of allure_directory to the temporary directory | |
docker cp "$container_id":"$allure_directory"/. "$temp_dir" | |
# Archive the contents of the temporary directory | |
tar -czf "$temp_dir/allure-report.tar.gz" -C "$temp_dir" . || [[ $? -eq 1 ]] | |
# Unlock the Allure report directory | |
docker exec $container_id chmod 755 "$allure_directory" | |
# Unpack the archive into the gh-pages directory | |
mkdir gh-pages | |
tar -xzf "$temp_dir/allure-report.tar.gz" -C gh-pages | |
echo ls -la gh-pages | |
else | |
echo "Allure directory not found or is empty." | |
fi | |
# Move the Allure report files to the root of the gh-pages directory | |
- name: Move Allure report files | |
run: mv gh-pages/* . | |
- name: Deploy Allure report to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: gh-pages | |
- name: Check contents of gh-pages | |
run: ls -la gh-pages | |
- name: Get GitHub Pages URL | |
id: pages-url | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const repo = context.repo.repo; | |
const owner = context.repo.owner; | |
const pagesUrl = `https://${owner}.github.io/${repo}`; | |
core.setOutput('pages_url', pagesUrl); | |
- name: Output GitHub Pages URL | |
run: | | |
echo "GitHub Pages URL: ${{ steps.pages-url.outputs.pages_url }}" | |
- name: Clean up | |
run: docker stop $(docker ps -q) || true |