mirror of
https://github.com/suitenumerique/docs
synced 2026-04-21 13:37:20 +00:00
We had to maintains 2 jobs, test-e2e-chromium and test-e2e-other-browser, in the impress-frontend workflow. By factorising the E2E tests into a separate workflow, we can now maintain only one job for each browser, which is much simpler and easier to maintain.
161 lines
4.9 KiB
YAML
161 lines
4.9 KiB
YAML
name: E2E Tests
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
browser-name:
|
|
description: 'Name used for cache keys and artifact names (e.g. chromium, other-browser)'
|
|
required: true
|
|
type: string
|
|
projects:
|
|
description: 'Playwright --project flags (e.g. --project=chromium)'
|
|
required: true
|
|
type: string
|
|
timeout-minutes:
|
|
description: 'Job timeout in minutes'
|
|
required: false
|
|
type: number
|
|
default: 30
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
install-dependencies:
|
|
uses: ./.github/workflows/dependencies.yml
|
|
with:
|
|
node_version: '22.x'
|
|
with-front-dependencies-installation: true
|
|
|
|
prepare-e2e:
|
|
runs-on: ubuntu-latest
|
|
needs: install-dependencies
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Restore Playwright browsers cache
|
|
id: playwright-cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
|
|
restore-keys: |
|
|
playwright-${{ runner.os }}-
|
|
|
|
- name: Install Playwright browsers
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd src/frontend/apps/e2e
|
|
yarn install-playwright chromium firefox webkit
|
|
|
|
- name: Save Playwright browsers cache
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
|
|
|
|
test-e2e:
|
|
needs: prepare-e2e
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: ${{ inputs.timeout-minutes }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22.x"
|
|
|
|
- name: Restore the frontend cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: "src/frontend/**/node_modules"
|
|
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Set e2e env variables
|
|
run: cat env.d/development/common.e2e >> env.d/development/common.local
|
|
|
|
- name: Restore Playwright browsers cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Free disk space before Docker
|
|
uses: ./.github/actions/free-disk-space
|
|
|
|
- name: Start Docker services
|
|
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
|
|
|
|
- name: Restore last-run cache
|
|
if: ${{ github.run_attempt > 1 }}
|
|
id: restore-last-run
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
key: playwright-last-run-${{ github.run_id }}-${{ inputs.browser-name }}
|
|
|
|
- name: Run e2e tests
|
|
env:
|
|
PLAYWRIGHT_LIST_PRINT_STEPS: true
|
|
FORCE_COLOR: true
|
|
run: |
|
|
cd src/frontend/
|
|
|
|
LAST_FAILED_FLAG=""
|
|
if [ "${{ github.run_attempt }}" != "1" ]; then
|
|
LAST_RUN_FILE="apps/e2e/test-results/.last-run.json"
|
|
if [ -f "$LAST_RUN_FILE" ]; then
|
|
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
|
|
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
|
|
LAST_FAILED_FLAG="--last-failed"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
yarn e2e:test ${{ inputs.projects }} $LAST_FAILED_FLAG
|
|
|
|
- name: Save last-run cache
|
|
if: always()
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
key: playwright-last-run-${{ github.run_id }}-${{ inputs.browser-name }}
|
|
|
|
- name: Upload last-run artifact
|
|
if: always()
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: playwright-instance-last-run-${{ inputs.browser-name }}
|
|
path: src/frontend/apps/e2e/test-results/.last-run.json
|
|
include-hidden-files: true
|
|
if-no-files-found: warn
|
|
retention-days: 7
|
|
|
|
- uses: actions/upload-artifact@v6
|
|
if: always()
|
|
with:
|
|
name: playwright-${{ inputs.browser-name }}-report
|
|
path: src/frontend/apps/e2e/report/
|
|
retention-days: 7
|