Skip to content

docs: [DHIS2-15187][DHIS2-15190] Working list bulk actions #1857

docs: [DHIS2-15187][DHIS2-15190] Working list bulk actions

docs: [DHIS2-15187][DHIS2-15190] Working list bulk actions #1857

Workflow file for this run

name: 'dhis2: e2e tests'
# Requirements:
#
# - Secrets:
# GITHUB_TOKEN
# CYPRESS_DHIS2_USERNAME
# CYPRESS_DHIS2_PASSWORD
#
# - Customize environment variables:
# BASE_URL_INSTANCES: Set the base url for the instances, e.g. https://test.e2e.dhis2.org
# NAME_PATTERN_LEGACY_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"
# CYPRESS_CONTAINERS: Set the number of parallel Cypress job runs running for each backend version.
# TRIGGER_LABELS: Set the labels that will trigger the workflow.
#
# - Set status check as required:
# We recommend setting "call-e2e-tests-result / e2e-tests-success" as a required step in your workflow.
# This will ensure that one of the following must be true before the PR can be merged:
# 1) The tests have successfully run
# 2) The dev took a conscious decision not to run the tests (see e2e-tests-skip.yml)
# 3) They were skipped due to a special case (see e2e-tests-exception.yml)
on:
pull_request:
types: [labeled]
env:
BASE_URL_INSTANCES: ${{ secrets.CYPRESS_DHIS2_INSTANCES_BASE_URL }}
NAME_PATTERN_LEGACY_INSTANCES: ca-test-{version}
NAME_PATTERN_DEV_INSTANCE: ca-test-dev
CYPRESS_CONTAINERS: 5
TRIGGER_LABELS: e2e-tests, testing
defaults:
run:
shell: bash
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.specs }}
steps:
- uses: actions/checkout@v3
- name: Generate test matrix
id: set-matrix
run: |
node cypress/support/generateTestMatrix.js > matrix.json
echo "::set-output name=specs::$(cat matrix.json)"
prerequisites:
runs-on: ubuntu-latest
needs: setup-matrix
outputs:
json-labels: ${{ steps.json-labels.outputs.labels }}
versions: ${{ steps.legacy-versions.outputs.versions }}
steps:
- name: compute-json-labels
id: json-labels
run: |
arrLabels=(${TRIGGER_LABELS//,/ })
for item in ${arrLabels[@]}; do labels+=\"$item\",; done
echo "::set-output name=labels::[ ${labels%,} ]"
- if: contains(fromJson(steps.json-labels.outputs.labels), github.event.label.name)
uses: actions/checkout@v2
- name: compute-instance-url
id: instance-url
if: contains(fromJson(steps.json-labels.outputs.labels), github.event.label.name)
run: echo "::set-output name=url::${BASE_URL_INSTANCES%/}/${NAME_PATTERN_DEV_INSTANCE/"{version}"/dev}"
- id: legacy-versions
if: contains(fromJson(steps.json-labels.outputs.labels), github.event.label.name)
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.CYPRESS_DHIS2_USERNAME }} # can be removed if maxDHIS2Version has been specified
password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }} # can be removed if maxDHIS2Version has been specified
cypress:
needs: [prerequisites, setup-matrix]
if: contains(fromJson(needs.prerequisites.outputs.json-labels), github.event.label.name)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
versions: ${{ fromJSON(needs.prerequisites.outputs.versions) }}
spec-group: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
env:
SHOULD_RECORD: ${{ contains(github.event.head_commit.message, '[e2e record]') || contains(join(github.event.pull_request.labels.*.name), 'e2e record') }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: compute-instance-url
id: instance-url
run: echo "::set-output name=url::${BASE_URL_INSTANCES%/}/${NAME_PATTERN_LEGACY_INSTANCES/"{version}"/$version}"
env:
version: ${{ matrix.versions }}
- name: Set Cypress Environment Variables
run: |
echo "CYPRESS_GROUP=e2e-${{ matrix.versions }}-${{ matrix.spec-group.id }}" >> $GITHUB_ENV
echo "CYPRESS_TAG=${{ github.event_name }}" >> $GITHUB_ENV
echo "CYPRESS_CI_BUILD_ID=${{ github.run_id }}" >> $GITHUB_ENV
echo "CI_BUILD_ID=${{ github.run_id }}" >> $GITHUB_ENV
- name: Debug Environment Variables
run: |
echo "SHOULD_RECORD=${{ env.SHOULD_RECORD }}"
echo "CI Build ID=${{ env.CI_BUILD_ID }}"
echo "Computed Group=${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_GROUP || '' }}"
echo "Computed Tag=${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_TAG || '' }}"
echo "Computed CI Build ID=${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_CI_BUILD_ID || '' }}"
echo "Spec=${{ join(matrix.spec-group.tests, ',') }}"
- name: Cypress run
uses: cypress-io/github-action@v6
with:
record: ${{ env.SHOULD_RECORD }}
parallel: ${{ env.SHOULD_RECORD }}
group: ${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_GROUP || '' }}
tag: ${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_TAG || '' }}
ci-build-id: ${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_CI_BUILD_ID || '' }}
spec: ${{ join(matrix.spec-group.tests, ',') }}
browser: chrome
start: yarn start:forCypress
wait-on: http://localhost:3000
wait-on-timeout: 300
env:
CI: true
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_dhis2BaseUrl: ${{ steps.instance-url.outputs.url }}
CYPRESS_dhis2InstanceVersion: ${{ matrix.versions }}
CYPRESS_dhis2Username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
CYPRESS_dhis2Password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
CYPRESS_dhis2Username_trackerAutoTestRestricted: ${{ secrets.CYPRESS_DHIS2_USERNAME_TRACKER_AUTO_TEST_RESTRICTED }}
CYPRESS_dhis2Password_trackerAutoTestRestricted: ${{ secrets.CYPRESS_DHIS2_PASSWORD_TRACKER_AUTO_TEST_RESTRICTED }}
NODE_OPTIONS: "--openssl-legacy-provider"
call-e2e-tests-result:
needs: cypress
uses: ./.github/workflows/e2e-tests-result.yml
with:
result: true