forked from ecamp/ecamp3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: extract e2e tests to reusable workflow file
That it can be reused to be run multiple times to detect flaky tests.
- Loading branch information
Showing
3 changed files
with
124 additions
and
105 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: '[reusable only] e2e tests build' | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
e2e-tests-build: | ||
name: 'Tests: End-to-end (build job)' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# build API (using cache; provide image to docker compose) | ||
- name: Build docker image (API/PHP) | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: api/Dockerfile | ||
context: './api' | ||
push: false | ||
load: true | ||
target: api_platform_php_dev | ||
builder: ${{ steps.buildx.outputs.name }} | ||
tags: ecamp/ecamp3-dev-api-php | ||
cache-from: type=gha,scope=api | ||
cache-to: type=gha,scope=api,mode=max | ||
outputs: type=docker,dest=/tmp/ecamp3-dev-api-php.tar | ||
|
||
# build caddy (using cache; provide image to docker compose) | ||
- name: Build docker image (Caddy) | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: api/Dockerfile | ||
context: './api' | ||
push: false | ||
load: true | ||
target: api_platform_caddy | ||
builder: ${{ steps.buildx.outputs.name }} | ||
tags: ecamp/ecamp3-dev-api-caddy | ||
cache-from: type=gha,scope=caddy | ||
cache-to: type=gha,scope=caddy,mode=max | ||
outputs: type=docker,dest=/tmp/ecamp3-dev-api-caddy.tar | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: e2e-tests-images | ||
path: /tmp/ecamp3-dev-*.tar |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: '[reusable only] e2e tests run' | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
e2e-tests-run: | ||
name: 'Tests: End-to-end' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
browser: | ||
- chrome | ||
- firefox | ||
- edge | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- run: cp .env.ci .env | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Restore tmp folder | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: e2e-tests-images | ||
path: /tmp | ||
|
||
- name: Load images | ||
run: | | ||
docker load --input /tmp/ecamp3-dev-api-php.tar | ||
docker load --input /tmp/ecamp3-dev-api-caddy.tar | ||
docker image ls -a --digests | ||
- name: Restore cache volumes (npm, composer) | ||
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 | ||
with: | ||
path: .cache | ||
key: docker-compose-${{ hashFiles('frontend/package-lock.json', 'print/package-lock.json', 'api/composer.lock') }}-${{ matrix.browser }} | ||
restore-keys: | | ||
docker-compose- | ||
# start necessary containers | ||
- run: docker compose up -d php caddy frontend pdf print browserless database docker-host | ||
|
||
- uses: cypress-io/github-action@v5 | ||
with: | ||
working-directory: e2e | ||
browser: ${{ matrix.browser }} | ||
wait-on: 'http://localhost:3000, http://localhost:3000/api, http://localhost:3000/print/health' | ||
wait-on-timeout: 300 | ||
|
||
# store screenshots and videos on GitHub as artifacts, for downloading and debugging in case of problems | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: cypress-output-${{ matrix.browser }} | ||
path: | | ||
e2e/data/**/* | ||
# print docker container logs (good for debugging; can be disabled again later on) | ||
- run: docker compose logs --tail="all" | ||
if: always() |