Skip to content

E2E Tests

E2E Tests #6

Workflow file for this run

name: E2E Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
jobs:
e2e:
if: github.event_name == 'workflow_dispatch' || !github.event.pull_request.draft
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve branch tag
id: branch-tag
run: |
raw="${{ github.head_ref || github.ref_name }}"
tag="${raw//\//-}"
tag="$(printf '%s' "$tag" | tr -cd 'a-zA-Z0-9_.-')"
tag="$(printf '%s' "$tag" | tr '[:upper:]' '[:lower:]')"
while [[ "$tag" == [.-]* ]]; do tag="${tag:1}"; done
tag="${tag:0:128}"
echo "sanitised=$tag" >> "$GITHUB_OUTPUT"
if docker manifest inspect "defradigital/trade-imports-animals-tests:${tag}" >/dev/null 2>&1; then
echo "tests-tag=$tag" >> "$GITHUB_OUTPUT"
echo "Tests image: branch ($tag)"
else
echo "tests-tag=latest" >> "$GITHUB_OUTPUT"
echo "Tests image: latest (no branch tag)"
fi
- name: Start stack
run: ./scripts/stack/run-stack.sh --branch "${{ github.head_ref || github.ref_name }}"
- name: Run E2E tests
run: |
docker run --rm \
--network host \
--user root \
-v ${{ github.workspace }}/artifacts/test-results:/app/test-results \
-v ${{ github.workspace }}/artifacts/playwright-report:/app/playwright-report \
-v ${{ github.workspace }}/artifacts/allure-results:/app/allure-results \
--entrypoint npx \
defradigital/trade-imports-animals-tests:${{ steps.branch-tag.outputs.tests-tag }} \
playwright test \
--config=playwright.local.fast.config.ts \
--grep-invert "@agent|@a11y"
- name: Upload playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: artifacts/playwright-report/
retention-days: 14
- name: Upload allure results
if: always()
uses: actions/upload-artifact@v4
with:
name: allure-results
path: artifacts/allure-results/
retention-days: 14
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: artifacts/test-results/
retention-days: 14
- name: Tear down stack
if: always()
run: docker compose -p trade-imports-animals down