chore: only run 3 spec files to enforce shorter duration #152
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: 'e2e-prod' | ||
# Requirements: | ||
# | ||
# - Customize environment variables: | ||
# BASE_URL_INSTANCES: Set the base url for the instances, e.g. https://test.e2e.dhis2.org | ||
# NAME_PATTERN_PROD_INSTANCES: Set the name pattern for your instances. {version} will be replaced by "[majorVersion].[minorVersion]" | ||
# NAME_PATTERN_DEV_INSTANCE: Set the name pattern for your dev instance. {version} will be replaced by "dev" | ||
# | ||
# - Other optional customizations: | ||
# containers: Set the matrix containers array for the e2e-prod job. The number of parallel Cypress instances running for each backend version will equal the array length. | ||
# | ||
# - Set status check as required: | ||
# We recommend setting "e2e-tests-success" as a required step in your workflow. | ||
on: | ||
workflow_call: | ||
secrets: | ||
baseurl: | ||
required: true | ||
username: | ||
required: true | ||
password: | ||
required: true | ||
recordkey: | ||
required: true | ||
env: | ||
BASE_URL_INSTANCES: https://debug.dhis2.org | ||
NAME_PATTERN_PROD_INSTANCES: '{version}' | ||
NAME_PATTERN_DEV_INSTANCE: dev | ||
concurrency: | ||
group: e2e-prod-${{ github.workflow}}-${{ github.ref }} | ||
cancel-in-progress: true | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
compute-prod-versions: | ||
if: !github.event.push.repository.fork && (github.event.pull_request.draft == false || github.action == 'workflow_dispatch') | ||
runs-on: ubuntu-latest | ||
outputs: | ||
versions: ${{ steps.prod-versions.outputs.versions }} | ||
steps: | ||
- name: Compute dev instance url | ||
id: instance-url | ||
run: | | ||
url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_DEV_INSTANCE/"{version}"/dev} | ||
echo "url=$url" >> $GITHUB_OUTPUT | ||
echo "url: $url" | ||
- uses: actions/checkout@v3 | ||
- name: Output prod version urls | ||
id: prod-versions | ||
uses: dhis2/action-supported-legacy-versions@v1 | ||
with: | ||
instance-url-latest: ${{ steps.instance-url.outputs.url }} # can be removed if maxDHIS2Version has been specified | ||
username: ${{ secrets.username }} | ||
password: ${{ secrets.password }} | ||
e2e-prod: | ||
needs: compute-prod-versions | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
versions: ${{ fromJSON(needs.compute-prod-versions.outputs.versions) }} | ||
containers: [1, 2] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
- uses: browser-actions/setup-chrome@v1 | ||
with: | ||
chrome-version: stable | ||
- run: | | ||
echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV | ||
- name: Compute prod instance url | ||
id: instance-url | ||
run: | | ||
url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_PROD_INSTANCES/"{version}"/$version} | ||
echo "url=$url" >> $GITHUB_OUTPUT | ||
echo "url: $url" | ||
env: | ||
version: ${{ matrix.versions }} | ||
- name: Run e2e tests | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
start: yarn d2-app-scripts start | ||
wait-on: 'http://localhost:3000' | ||
wait-on-timeout: 300 | ||
record: true | ||
parallel: true | ||
browser: chrome | ||
group: e2e-chrome-parallel-${{ matrix.versions }} | ||
env: | ||
CI: true | ||
BROWSER: none | ||
CYPRESS_RECORD_KEY: ${{ secrets.recordkey }} | ||
CYPRESS_dhis2BaseUrl: ${{ steps.instance-url.outputs.url }} | ||
CYPRESS_dhis2InstanceVersion: ${{matrix.versions}} | ||
CYPRESS_dhis2Username: ${{ secrets.username }} | ||
CYPRESS_dhis2Password: ${{ secrets.password }} | ||
CYPRESS_networkMode: live | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
e2e-tests-success: | ||
needs: e2e-prod | ||
if: ${{ success() || failure() }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: if [ $result != 'success' ]; then exit 1; fi; | ||
env: | ||
result: ${{ needs.e2e-prod.result }} |