From 4bc20385930bbd9657ae64b46c13617076a2fd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 10:49:38 +0100 Subject: [PATCH 01/12] chore: init draft --- .github/workflows/e2e-tests-exceptions.yml | 11 --- .github/workflows/e2e-tests-result.yml | 24 ----- .github/workflows/e2e-tests-skip.yml | 12 --- .github/workflows/e2e-tests.yml | 102 +++++++++------------ 4 files changed, 41 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/e2e-tests-exceptions.yml delete mode 100644 .github/workflows/e2e-tests-result.yml delete mode 100644 .github/workflows/e2e-tests-skip.yml diff --git a/.github/workflows/e2e-tests-exceptions.yml b/.github/workflows/e2e-tests-exceptions.yml deleted file mode 100644 index d915fcd011..0000000000 --- a/.github/workflows/e2e-tests-exceptions.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: 'dhis2: e2e tests exceptions' - -on: - push: - -jobs: - call-e2e-tests-result: - if: github.actor == 'dhis2-bot' || contains(github.event.head_commit.message, '[skip ci]') - uses: ./.github/workflows/e2e-tests-result.yml - with: - result: true diff --git a/.github/workflows/e2e-tests-result.yml b/.github/workflows/e2e-tests-result.yml deleted file mode 100644 index 153bdcdd84..0000000000 --- a/.github/workflows/e2e-tests-result.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: 'dhis2: result of e2e tests' - -# The job here (e2e-tests-success) will be set to true if all the tests pass. -# Setting "call-e2e-tests-result / e2e-tests-success" as a required step in your workflow is recommended. - -on: - workflow_call: - inputs: - result: - required: true - type: boolean - -defaults: - run: - shell: bash - -jobs: - e2e-tests-success: - runs-on: ubuntu-latest - steps: - - name: verify - run: if [ $result != true ]; then exit 1; fi; - env: - result: ${{ inputs.result }} diff --git a/.github/workflows/e2e-tests-skip.yml b/.github/workflows/e2e-tests-skip.yml deleted file mode 100644 index ebd7d26d71..0000000000 --- a/.github/workflows/e2e-tests-skip.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'dhis2: skip e2e tests' - -on: - pull_request_target: - types: [labeled] - -jobs: - call-e2e-tests-result: - if: github.event.label.name == 'skip-e2e-tests' - uses: ./.github/workflows/e2e-tests-result.yml - with: - result: true diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 48c6e337f9..aa45b10b26 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -4,6 +4,7 @@ name: 'dhis2: e2e tests' # # - Secrets: # GITHUB_TOKEN +# CYPRESS_RECORD_KEY # CYPRESS_DHIS2_USERNAME # CYPRESS_DHIS2_PASSWORD # @@ -11,63 +12,47 @@ name: 'dhis2: e2e tests' # 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. +# +# - Other optional customizations: +# containers: Set the matrix containers array for the cypress 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 "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) +# We recommend setting "e2e-tests-success" as a required step in your workflow. on: pull_request: - types: [labeled] + types: [opened, synchronize, reopened, ready_for_review] 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: 8 - TRIGGER_LABELS: e2e-tests, testing + BASE_URL_INSTANCES: https://test.e2e.dhis2.org + NAME_PATTERN_LEGACY_INSTANCES: '{version}dev' + NAME_PATTERN_DEV_INSTANCE: dev + +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true defaults: run: shell: bash jobs: - prerequisites: + compute-versions: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest outputs: - json-labels: ${{ steps.json-labels.outputs.labels }} - matrix-containers: ${{ steps.matrix-containers.outputs.containers }} 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%,} ]" - - - name: compute-matrix-containers - id: matrix-containers - if: contains(fromJson(steps.json-labels.outputs.labels), github.event.label.name) - run: | - for (( cnt = 1; cnt <= $CYPRESS_CONTAINERS; cnt++)); do containers+=$cnt,; done - echo "::set-output name=containers::[ ${containers%,} ]" - - - 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}" + run: | + url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_DEV_INSTANCE/"{version}"/dev} + echo "url=$url" >> $GITHUB_OUTPUT + echo "url: $url" + + - uses: actions/checkout@v3 - 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 @@ -75,59 +60,54 @@ jobs: password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }} # can be removed if maxDHIS2Version has been specified cypress: - needs: prerequisites - if: contains(fromJson(needs.prerequisites.outputs.json-labels), github.event.label.name) + needs: compute-versions runs-on: ubuntu-latest container: cypress/browsers:node14.7.0-chrome84 strategy: fail-fast: false matrix: - versions: ${{ fromJSON(needs.prerequisites.outputs.versions) }} - containers: ${{ fromJSON(needs.prerequisites.outputs.matrix-containers) }} + versions: ${{ fromJSON(needs.compute-versions.outputs.versions) }} + containers: [1, 2, 3, 4, 5, 6] steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: 14.x + - uses: actions/checkout@v3 - - uses: actions/cache@v2 - id: yarn-cache + - uses: actions/setup-node@v1 with: - path: '**/node_modules' - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - - - name: Install - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile + node-version: 16.x - name: compute-instance-url id: instance-url - run: echo "::set-output name=url::${BASE_URL_INSTANCES%/}/${NAME_PATTERN_LEGACY_INSTANCES/"{version}"/$version}" + run: | + url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_LEGACY_INSTANCES/"{version}"/$version} + echo "url=$url" >> $GITHUB_OUTPUT + echo "url: $url" env: version: ${{ matrix.versions }} - name: Cypress run - uses: cypress-io/github-action@v2 + uses: cypress-io/github-action@v4 with: record: true parallel: true group: e2e-chrome-parallel-${{ matrix.versions }} browser: chrome - start: yarn start:forCypress + start: yarn d2-app-scripts start wait-on: http://localhost:3000 wait-on-timeout: 300 env: CI: true - CYPRESS_RECORD_KEY: '6b0bce0d-a4e8-417b-bbee-9157cbe9a999' + 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 }} - call-e2e-tests-result: + e2e-tests-success: needs: cypress - uses: ./.github/workflows/e2e-tests-result.yml - with: - result: true + if: ${{ success() || failure() }} + runs-on: ubuntu-latest + steps: + - run: if [ $result != 'success' ]; then exit 1; fi; + env: + result: ${{ needs.cypress.result }} \ No newline at end of file From bb355c49c1e5c5e9580d5b879ae4c3243f0f2dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 11:14:12 +0100 Subject: [PATCH 02/12] chore: up --- .github/workflows/e2e-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index aa45b10b26..2e4ab1a553 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -27,6 +27,7 @@ env: BASE_URL_INSTANCES: https://test.e2e.dhis2.org NAME_PATTERN_LEGACY_INSTANCES: '{version}dev' NAME_PATTERN_DEV_INSTANCE: dev + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} concurrency: group: ${{ github.workflow}}-${{ github.ref }} From 475afa5f047eeb8a8b47ad17f926fe885ee81215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:42:55 +0100 Subject: [PATCH 03/12] chore: up --- .github/workflows/e2e-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 2e4ab1a553..c67c45f677 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -27,7 +27,6 @@ env: BASE_URL_INSTANCES: https://test.e2e.dhis2.org NAME_PATTERN_LEGACY_INSTANCES: '{version}dev' NAME_PATTERN_DEV_INSTANCE: dev - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} concurrency: group: ${{ github.workflow}}-${{ github.ref }} @@ -39,7 +38,7 @@ defaults: jobs: compute-versions: - if: github.event.pull_request.draft == false + if: !github.event.pull_request.draft && !github.event.base.repo.fork runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From 494a0fdb6045622b8c996ee1d55a7e889891f4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:48:24 +0100 Subject: [PATCH 04/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c67c45f677..381b2d398e 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: !github.event.pull_request.draft && !github.event.base.repo.fork + if: !github.event.pull_request.draft runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From 523a0f109d883a19eed7087c4f80d28cd535cf36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:49:03 +0100 Subject: [PATCH 05/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 381b2d398e..446a3a58d5 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: !github.event.pull_request.draft + if: '!github.event.pull_request.draft' runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From 5e34e8dd870fdff82bb85ec131b0ae7ce4597cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:50:27 +0100 Subject: [PATCH 06/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 446a3a58d5..5a5ccf1d33 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -17,7 +17,7 @@ name: 'dhis2: e2e tests' # containers: Set the matrix containers array for the cypress 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. +# We recommend setting "e2e-tests-success" as a required step in your workflow. on: pull_request: From 6e21c9ccdba70d9d7c2906ce8d338165bc8e85dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:52:32 +0100 Subject: [PATCH 07/12] chore: up --- .github/workflows/e2e-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 5a5ccf1d33..34167b6e0d 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -17,7 +17,7 @@ name: 'dhis2: e2e tests' # containers: Set the matrix containers array for the cypress 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. +# We recommend setting "e2e-tests-success" as a required step in your workflow. on: pull_request: @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: '!github.event.pull_request.draft' + if: '!github.event.pull_request.draft && !github.event.base.repo.fork' runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From f3f07560e43e7f47b2c6a23ee31be60affe9d745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:55:51 +0100 Subject: [PATCH 08/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 34167b6e0d..3ca9e2a7c0 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: '!github.event.pull_request.draft && !github.event.base.repo.fork' + if: github.event.pull_request.draft == false && github.event.base.repo.fork == false runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From 645d9c80de2eca17c299bea507da599868e9a2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:59:06 +0100 Subject: [PATCH 09/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 3ca9e2a7c0..cc023ab1f3 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: github.event.pull_request.draft == false && github.event.base.repo.fork == false + if: '!github.event.pull_request.draft && !github.event.pull_request.base.repo.fork' runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From e1bb4ed6b36d37adc5d7760e7c8be5b15c56d05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:59:41 +0100 Subject: [PATCH 10/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index cc023ab1f3..67906bea7e 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: '!github.event.pull_request.draft && !github.event.pull_request.base.repo.fork' + if: !github.event.pull_request.draft && !github.event.pull_request.base.repo.fork runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From 596c185f6b4d3c9bee8bd51a5b604c0426bbe40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 12:59:59 +0100 Subject: [PATCH 11/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 67906bea7e..cc023ab1f3 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: !github.event.pull_request.draft && !github.event.pull_request.base.repo.fork + if: '!github.event.pull_request.draft && !github.event.pull_request.base.repo.fork' runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }} From ad10ab437628f6dbbac0c5c31d772e16ced3db16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Fri, 4 Nov 2022 13:18:56 +0100 Subject: [PATCH 12/12] chore: up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index cc023ab1f3..311553c9fd 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -38,7 +38,7 @@ defaults: jobs: compute-versions: - if: '!github.event.pull_request.draft && !github.event.pull_request.base.repo.fork' + if: '!github.event.pull_request.draft && !github.event.pull_request.head.repo.fork' runs-on: ubuntu-latest outputs: versions: ${{ steps.legacy-versions.outputs.versions }}