Application E2E Tests #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: Application E2E Tests | |
on: | |
workflow_run: | |
workflows: | |
- "Application Build" | |
types: | |
- completed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} | |
cancel-in-progress: true | |
jobs: | |
e2e_test: | |
name: Run E2E tests | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-22.04 | |
strategy: | |
# when one test fails, DO NOT cancel the other | |
# containers, because this will kill Cypress processes | |
# leaving the Dashboard hanging ... | |
# https://github.com/cypress-io/github-action/issues/48 | |
fail-fast: false | |
matrix: | |
# Run 10 copies of the current job in parallel | |
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PUPPETEER_SKIP_DOWNLOAD: "true" | |
VITE_CYPRESS_PORT: 8880 | |
steps: | |
- name: "Download 'workflow_share' artifact" | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GH_PAT }} | |
name: workflow_share | |
repository: MTES-MCT/monitorfish | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Set STATUS_CHECK_ID environment variable | |
run: | | |
echo "STATUS_CHECK_ID=$(cat workflow_share/cypress_job_check_id)" >> $GITHUB_ENV | |
- name: Update job status check | |
uses: LouisBrunner/checks-action@v2.0.0 | |
if: ${{ always() }} | |
with: | |
check_id: ${{ env.STATUS_CHECK_ID }} | |
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" | |
sha: ${{ github.event.workflow_run.head_commit.id }} | |
status: in_progress | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_commit.id }} | |
- name: Set version and environment profile | |
uses: ./.github/actions/set-version-and-environment-profile | |
- name: Set MONITORFISH_VERSION environment variable | |
run: echo "MONITORFISH_VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Download image | |
uses: ishworkh/container-image-artifact-download@v1.0.0 | |
with: | |
commit_sha: ${{ github.event.workflow_run.head_commit.id }} | |
image: monitorfish-app:${{ env.VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
workflow: "Application Build" | |
- name: Run docker images | |
run: make docker-compose-up | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: npm | |
cache-dependency-path: ./frontend/package-lock.json | |
node-version: 20 | |
- name: Setup Firefox | |
uses: browser-actions/setup-firefox@latest | |
with: | |
firefox-version: 119.0.1 | |
- name: Check versions | |
run: | | |
cat /etc/lsb-release | |
node -v | |
npm -v | |
docker -v | |
docker compose version | |
firefox -v | |
which firefox | |
- name: Run Cypress E2E tests | |
id: run_cypress_e2e_tests | |
continue-on-error: true | |
uses: cypress-io/github-action@v6 | |
with: | |
browser: firefox | |
config-file: config/cypress.config.ts | |
env: PORT=8880 | |
install: true | |
install-command: npm ci | |
parallel: true | |
record: true | |
wait-on: "http://localhost:8880" | |
working-directory: ./frontend | |
- name: set final job status check | |
uses: LouisBrunner/checks-action@v2.0.0 | |
if: ${{ always() }} | |
with: | |
check_id: ${{ env.STATUS_CHECK_ID }} | |
conclusion: ${{ steps.run_cypress_e2e_tests.outcome }} | |
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" | |
sha: ${{ github.event.workflow_run.head_commit.id }} | |
status: completed | |
token: ${{ secrets.GITHUB_TOKEN }} | |
e2e_multi_windows_test: | |
name: Run E2E multi windows tests | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-22.04 | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PUPPETEER_SKIP_DOWNLOAD: "true" | |
VITE_CYPRESS_PORT: 8880 | |
steps: | |
- name: "Download 'workflow_share' artifact" | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GH_PAT }} | |
name: workflow_share | |
repository: MTES-MCT/monitorfish | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Set STATUS_CHECK_ID environment variable | |
run: | | |
echo "STATUS_CHECK_ID=$(cat workflow_share/puppeteer_job_check_id)" >> $GITHUB_ENV | |
- name: Update job status check | |
uses: LouisBrunner/checks-action@v2.0.0 | |
if: ${{ always() }} | |
with: | |
check_id: ${{ env.STATUS_CHECK_ID }} | |
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" | |
sha: ${{ github.event.workflow_run.head_commit.id }} | |
status: in_progress | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_commit.id }} | |
- name: Set version and environment profile | |
uses: ./.github/actions/set-version-and-environment-profile | |
- name: Set MONITORFISH_VERSION environment variable | |
run: echo "MONITORFISH_VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Download image | |
uses: ishworkh/container-image-artifact-download@v1.0.0 | |
with: | |
commit_sha: ${{ github.event.workflow_run.head_commit.id }} | |
image: monitorfish-app:${{ env.VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
workflow: "Application Build" | |
- name: Docker login | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: npm | |
cache-dependency-path: ./frontend/package-lock.json | |
node-version: 20 | |
- name: Install Node.js dependencies | |
run: npm ci | |
working-directory: ./frontend | |
- name: Run docker images | |
run: make docker-compose-puppeteer-up | |
- name: Install Firefox | |
run: npx puppeteer browsers install firefox | |
- name: Run multi-windows tests | |
id: run_puppeteer_e2e_tests | |
continue-on-error: true | |
run: npm run test:multi-windows:run | |
working-directory: ./frontend | |
- name: Set final job status check | |
uses: LouisBrunner/checks-action@v2.0.0 | |
if: ${{ always() }} | |
with: | |
check_id: ${{ env.STATUS_CHECK_ID }} | |
conclusion: ${{ steps.run_puppeteer_e2e_tests.outcome }} | |
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" | |
sha: ${{ github.event.workflow_run.head_commit.id }} | |
status: completed | |
token: ${{ secrets.GITHUB_TOKEN }} |