From 366c0f2a090ae3ef7a585b52c86944c3aa91c266 Mon Sep 17 00:00:00 2001 From: Adel Bensaad Date: Mon, 19 Aug 2024 12:58:03 +0100 Subject: [PATCH 1/3] Create analytics-e2e-tests-triggered-by-core workflow chore: fix workflow chore: fix dhis2_version chore: fix env var DHIS2_VERSION chore: fix wait-on dhis2BaseUrl chore: set baseUrl to run tests against instance URL chore: debug increase pageLoadTimeout debug debug Revert "debug" This reverts commit 8fa237100875d33a86e306b883cb643949debb1f. debug chore: refactor workflow for dynamic app andA URLs --- .../analytics-e2e-tests-triggered-by-core.yml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .github/workflows/analytics-e2e-tests-triggered-by-core.yml diff --git a/.github/workflows/analytics-e2e-tests-triggered-by-core.yml b/.github/workflows/analytics-e2e-tests-triggered-by-core.yml new file mode 100644 index 0000000..3b07f2d --- /dev/null +++ b/.github/workflows/analytics-e2e-tests-triggered-by-core.yml @@ -0,0 +1,106 @@ +name: 'e2e-prod' + +on: + workflow_call: + inputs: + should_record: + required: false + type: boolean + default: false + spec-group: + required: false + type: string + api_base_url: + required: true + type: string + app_url: + required: true + type: string + dhis2_version: + required: true + type: string + secrets: + username: + required: true + password: + required: true + recordkey: + required: true + reportportal_api_key: + required: false + reportportal_endpoint: + required: false + reportportal_project: + required: false + +concurrency: + group: e2e-prod-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-prod: + runs-on: ubuntu-latest + env: + CI_BUILD_ID: ${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + PR_TITLE: ${{ github.event.pull_request.title }} + DHIS2_VERSION: ${{ inputs.dhis2_version }} + strategy: + fail-fast: false + matrix: + spec-group: ${{ fromJson(inputs.spec-group) }} + steps: + - uses: actions/checkout@v4 + - 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: Debug spec-group and should_record + run: | + echo "spec-group: ${{ toJson(matrix.spec-group) }}" + echo "should_record: ${{ inputs.should_record }}" + + - name: Debug Test Parameters + run: | + echo "Record: ${{ inputs.should_record }}" + echo "Parallel: ${{ inputs.should_record }}" + echo "Specs: ${{ join(matrix.spec-group.tests, ',') }}" + echo "Group: ${{ inputs.should_record && format('e2e-chrome-parallel-{0}', matrix.spec-group.id) || '' }}" + echo "CI Build ID: ${{ inputs.should_record && github.run_id || '' }}" + + - name: Run e2e tests + uses: cypress-io/github-action@v6 + with: + config: pageLoadTimeout=100000,baseUrl=${{ inputs.app_url }} + wait-on: ${{ inputs.api_base_url }} + wait-on-timeout: 300 + record: ${{ inputs.should_record }} + parallel: ${{ inputs.should_record }} + browser: chrome + spec: ${{ join(matrix.spec-group.tests, ',') }} + group: ${{ inputs.should_record && format('e2e-chrome-parallel-{0}', matrix.spec-group.id) || '' }} + ci-build-id: ${{ inputs.should_record && github.run_id || '' }} + env: + CI: true + CYPRESS_RECORD_KEY: ${{ secrets.recordkey }} + CYPRESS_dhis2BaseUrl: ${{ inputs.api_base_url }} + CYPRESS_dhis2InstanceVersion: ${{ inputs.dhis2_version }} + CYPRESS_dhis2Username: ${{ secrets.username }} + CYPRESS_dhis2Password: ${{ secrets.password }} + CYPRESS_networkMode: live + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPORTPORTAL_API_KEY: ${{ secrets.reportportal_api_key }} + REPORTPORTAL_ENDPOINT: ${{ secrets.reportportal_endpoint }} + REPORTPORTAL_PROJECT: ${{ secrets.reportportal_project }} + + e2e-tests-success: + needs: e2e-prod + if: ${{ success() || failure() }} + runs-on: ubuntu-latest + steps: + - run: if [ "${{ needs.e2e-prod.result }}" != 'success' ]; then exit 1; fi; From 6fecf0eac2ed33b411ded40253bbf97ea6e7c3fd Mon Sep 17 00:00:00 2001 From: Adel Bensaad Date: Tue, 3 Dec 2024 11:08:41 +0000 Subject: [PATCH 2/3] debug: normalize app_url to remove trailing slashes --- .../analytics-e2e-tests-triggered-by-core.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/analytics-e2e-tests-triggered-by-core.yml b/.github/workflows/analytics-e2e-tests-triggered-by-core.yml index 3b07f2d..4929af9 100644 --- a/.github/workflows/analytics-e2e-tests-triggered-by-core.yml +++ b/.github/workflows/analytics-e2e-tests-triggered-by-core.yml @@ -60,10 +60,12 @@ jobs: - run: | echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV - - name: Debug spec-group and should_record + - name: Normalize app_url run: | - echo "spec-group: ${{ toJson(matrix.spec-group) }}" - echo "should_record: ${{ inputs.should_record }}" + echo "Original app_url: ${{ inputs.app_url }}" + NORMALIZED_APP_URL=$(echo "${{ inputs.app_url }}" | sed 's:/*$::') + echo "Normalized app_url: $NORMALIZED_APP_URL" + echo "app_url=$NORMALIZED_APP_URL" >> $GITHUB_ENV - name: Debug Test Parameters run: | @@ -72,11 +74,12 @@ jobs: echo "Specs: ${{ join(matrix.spec-group.tests, ',') }}" echo "Group: ${{ inputs.should_record && format('e2e-chrome-parallel-{0}', matrix.spec-group.id) || '' }}" echo "CI Build ID: ${{ inputs.should_record && github.run_id || '' }}" + echo "Normalized App URL: ${{ env.app_url }}" - name: Run e2e tests uses: cypress-io/github-action@v6 with: - config: pageLoadTimeout=100000,baseUrl=${{ inputs.app_url }} + config: pageLoadTimeout=100000,baseUrl=${{ env.app_url }} wait-on: ${{ inputs.api_base_url }} wait-on-timeout: 300 record: ${{ inputs.should_record }} From 56ad29baf59366905d817731b9bcea23925f6c40 Mon Sep 17 00:00:00 2001 From: adeldhis2 Date: Wed, 25 Dec 2024 12:05:49 +0100 Subject: [PATCH 3/3] Revert "debug: normalize app_url to remove trailing slashes" This reverts commit 6fecf0eac2ed33b411ded40253bbf97ea6e7c3fd. --- .../analytics-e2e-tests-triggered-by-core.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/analytics-e2e-tests-triggered-by-core.yml b/.github/workflows/analytics-e2e-tests-triggered-by-core.yml index 4929af9..3b07f2d 100644 --- a/.github/workflows/analytics-e2e-tests-triggered-by-core.yml +++ b/.github/workflows/analytics-e2e-tests-triggered-by-core.yml @@ -60,12 +60,10 @@ jobs: - run: | echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV - - name: Normalize app_url + - name: Debug spec-group and should_record run: | - echo "Original app_url: ${{ inputs.app_url }}" - NORMALIZED_APP_URL=$(echo "${{ inputs.app_url }}" | sed 's:/*$::') - echo "Normalized app_url: $NORMALIZED_APP_URL" - echo "app_url=$NORMALIZED_APP_URL" >> $GITHUB_ENV + echo "spec-group: ${{ toJson(matrix.spec-group) }}" + echo "should_record: ${{ inputs.should_record }}" - name: Debug Test Parameters run: | @@ -74,12 +72,11 @@ jobs: echo "Specs: ${{ join(matrix.spec-group.tests, ',') }}" echo "Group: ${{ inputs.should_record && format('e2e-chrome-parallel-{0}', matrix.spec-group.id) || '' }}" echo "CI Build ID: ${{ inputs.should_record && github.run_id || '' }}" - echo "Normalized App URL: ${{ env.app_url }}" - name: Run e2e tests uses: cypress-io/github-action@v6 with: - config: pageLoadTimeout=100000,baseUrl=${{ env.app_url }} + config: pageLoadTimeout=100000,baseUrl=${{ inputs.app_url }} wait-on: ${{ inputs.api_base_url }} wait-on-timeout: 300 record: ${{ inputs.should_record }}