From ba96c4f1b5d73b0e14783fed7d3fe65cd2696d02 Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Fri, 12 Jul 2024 08:06:40 -0400 Subject: [PATCH] ci(e2e-report): support version other than latest (#2540) This replaces the hardcoded Next.js "latest" version with an optional selector input. While I was at it, I clarified some confusing aspects of this setup. It's tripped up multiple people already. Co-authored-by: Michal Piechowiak --- .github/workflows/e2e-report.yml | 23 +++++++++++++++++++---- .github/workflows/test-e2e.yml | 3 +++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-report.yml b/.github/workflows/e2e-report.yml index 23e11f694d..1bc84e0822 100644 --- a/.github/workflows/e2e-report.yml +++ b/.github/workflows/e2e-report.yml @@ -7,6 +7,14 @@ on: use-branch: description: 'Enable if you want to test data from your selected branch instead of the scheduled test runs from Main' type: boolean + version: + description: 'Version of Next.js (most recent test run must have included this version)' + type: choice + options: + - 'latest' + - 'canary' + - '13.5.1' + default: 'latest' env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} @@ -27,12 +35,19 @@ jobs: E2E_RUN_ID=$(gh run list -w test-e2e.yml -e schedule -s success --json databaseId --jq ".[0].databaseId" --repo $GITHUB_REPOSITORY) fi echo "runId=$E2E_RUN_ID" >> $GITHUB_OUTPUT - - name: Download latest e2e results + - name: Download e2e results if: ${{ steps.get-run-id.outputs.runId }} run: | - echo "Downloading latest test results from run https://github.com/netlify/next-runtime/actions/runs/${{ steps.get-run-id.outputs.runId }}" - rm e2e-report/data/test-results.json - gh run download ${{ steps.get-run-id.outputs.runId }} -n "latest-test-results.json" -D e2e-report/data/ --repo $GITHUB_REPOSITORY + version="${{ inputs.version }}" + version=${version:-latest} + OUTPUT_DIR="e2e-report/data" + OUTPUT_FILENAME="test-results.json" + echo "Downloading ${version} test results from run https://github.com/netlify/next-runtime/actions/runs/${{ steps.get-run-id.outputs.runId }}" + rm "${OUTPUT_DIR}/${OUTPUT_FILENAME}" + artifact_name="${version}-test-results.json" + # NOTE: The artifact name is not necessarily the artifact *file* name. The file name here + # must be `test-results.json`, but this is defined at the artifact upload step. + gh run download ${{ steps.get-run-id.outputs.runId }} -n "${artifact_name}" -D "${OUTPUT_DIR}" --repo $GITHUB_REPOSITORY - name: Install site dependencies if: success() run: | diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 9c952b1bf0..29975aeaef 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -259,6 +259,9 @@ jobs: - name: Upload Test JSON uses: actions/upload-artifact@v4 with: + # TODO(serhalp) Consider renaming this. It's misleading, since it's just an identifier, + # but it's formatted like a filename, and happens to be almost - but not quite - the + # actual filename. name: ${{matrix.version_spec.selector}}-test-results.json path: report/test-results.json