From 0bd77b478b3c74eb61d873fd888a5856da017460 Mon Sep 17 00:00:00 2001 From: BacLuc Date: Sat, 18 Nov 2023 15:36:27 +0100 Subject: [PATCH] ci: add job to run e2e tests multiple times With upload-artifacts v4 you cannot re-upload an artifact with the same name. --- .github/workflows/e2e-tests.yml | 59 ++++++++++++++++++++ .github/workflows/reusable-e2e-tests-run.yml | 5 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/e2e-tests.yml diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml new file mode 100644 index 0000000000..9acf5f2ef1 --- /dev/null +++ b/.github/workflows/e2e-tests.yml @@ -0,0 +1,59 @@ +name: "Tests: End to End to detect flaky tests" + +on: + workflow_dispatch: + inputs: + pr_number: + type: number + description: | + Number of times the tests should run + required: true + default: 10 + pull_request: + types: [opened, labeled, unlabeled, synchronize] + schedule: + - cron: '42 4 * * *' + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }} + cancel-in-progress: false + +jobs: + create-array: + name: 'Create large array for matrix' + if: contains(github.event.pull_request.labels.*.name, 'test-flaky-e2e!') || github.event_name != 'pull_request' + runs-on: ubuntu-latest + outputs: + array: ${{ steps.array.outputs.result }} + + steps: + - name: Create large array + uses: actions/github-script@v6 + id: array + with: + script: | + function range(start, stop) { + return Array(stop - start) + .fill(start) + .map((value, index) => value + index); + } + return range(0, ${{ inputs.pr_number != null && inputs.pr_number || 10 }}) + + e2e-tests-build: + name: 'Tests: End-to-end build to detect flaky tests' + needs: + - create-array + uses: ./.github/workflows/reusable-e2e-tests-build.yml + + e2e-tests-run: + name: 'Tests: End-to-end run to detect flaky tests' + needs: + - create-array + - e2e-tests-build + uses: ./.github/workflows/reusable-e2e-tests-run.yml + with: + run-identifier: ${{ matrix.array }} + strategy: + fail-fast: false + matrix: + array: ${{ fromJSON(needs.create-array.outputs.array) }} diff --git a/.github/workflows/reusable-e2e-tests-run.yml b/.github/workflows/reusable-e2e-tests-run.yml index 0cbb1fb3f9..ff888b6d00 100644 --- a/.github/workflows/reusable-e2e-tests-run.yml +++ b/.github/workflows/reusable-e2e-tests-run.yml @@ -2,6 +2,9 @@ name: '[reusable only] e2e tests run' on: workflow_call: + run-identifier: + required: false + type: string jobs: e2e-tests-run: @@ -58,7 +61,7 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: cypress-output-${{ matrix.browser }} + name: cypress-output-${{ matrix.browser }}${{ inputs.run-identifier != null && format('-{0}', inputs.run-identifier) }} path: | e2e/data/**/*