From 89dc6f9f1ab69ffd338d8c8da7d2cc0bb2563694 Mon Sep 17 00:00:00 2001 From: Jan Varho Date: Tue, 18 May 2021 16:47:08 +0300 Subject: [PATCH 1/3] Build and stash packages only once in e2e tests --- .github/workflows/e2e-tests.yml | 58 +++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 5dd711a5f8..add4c71339 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -20,6 +20,12 @@ jobs: pr_git_sha: ${{ steps.set_pr_git_sha.outputs.pr_git_sha }} steps: + # For non-fork PRs + - uses: actions/checkout@v2 + if: ${{ github.event.inputs.pull_request_id == '' }} + with: + ref: ${{ github.event.inputs.sha || github.ref }} + # For manually run PRs - name: Initialize empty git repository if: ${{ github.event.inputs.pull_request_id != '' }} @@ -50,6 +56,37 @@ jobs: sha: ${{ steps.set_pr_git_sha.outputs.pr_git_sha || github.event.inputs.sha || github.sha }} target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: "12.x" + + - name: Build + run: yarn --frozen-lockfile + + - name: Install test utils + run: | + cd packages/e2e-tests/test-utils + yarn --frozen-lockfile + + - name: "Compress build" + run: tar -caf build.tar.gz ./packages ./node_modules + + - name: Wait for existing workflow to complete before e2e tests + uses: softprops/turnstyle@v1 + with: + poll-interval-seconds: 15 + same-branch-only: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Upload build" + uses: actions/upload-artifact@v2 + with: + name: build.tar.gz + path: build.tar.gz + retention-days: 1 + run-e2e-tests: needs: [initialize] runs-on: [ubuntu-latest] @@ -96,21 +133,13 @@ jobs: with: node-version: ${{ matrix.node-version }} - - run: yarn --frozen-lockfile - # TODO: build once and cache for all e2e tests - - - name: Install test utils - run: | - cd packages/e2e-tests/test-utils - yarn --frozen-lockfile - - - name: Wait for existing workflow to complete before e2e tests - uses: softprops/turnstyle@v1 + - name: "Download build" + uses: actions/download-artifact@v2 with: - poll-interval-seconds: 15 - same-branch-only: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: build.tar.gz + + - name: "Uncompress build" + run: tar -xf build.tar.gz - name: Run e2e tests env: @@ -125,6 +154,7 @@ jobs: yarn --frozen-lockfile sleep $[($RANDOM % 15) + 1]s # Sleep 1-15 seconds to try to avoid throttling yarn e2e:ci + timeout-minutes: 30 # In case something goes wrong - name: Mark end-to-end tests as failed # For manual runs (e.g for fork PRs) don't update commit status as there won't be permissions to do so From a37bc3df2947ec2cf2376d2a597aa6533be2fa6f Mon Sep 17 00:00:00 2001 From: Jan Varho Date: Tue, 18 May 2021 17:56:05 +0300 Subject: [PATCH 2/3] Add workaround to locale test --- .../cypress/integration/pages.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts b/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts index 2f7f896ad7..2455dd0cb7 100644 --- a/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts +++ b/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts @@ -209,7 +209,15 @@ describe("Pages Tests", () => { ].forEach(({ path }) => { it(`serves page ${path} with fallback at first`, () => { cy.visit(path); - cy.location("pathname").should("eq", path); + + // Next.js currently behaves inconsistently here, + // dropping the default locale for static pages + if (path === "/en/fallback/d") { + cy.location("pathname").should("eq", "/fallback/d"); + } else { + cy.location("pathname").should("eq", path); + } + cy.contains("Hello fallback"); }); }); From 07617300a9930440a40460bfae4a2ce33e650adc Mon Sep 17 00:00:00 2001 From: Jan Varho Date: Tue, 18 May 2021 19:29:35 +0300 Subject: [PATCH 3/3] Fix the correct test --- .../cypress/integration/pages.test.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts b/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts index 2455dd0cb7..11c5636404 100644 --- a/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts +++ b/packages/e2e-tests/next-app-with-locales/cypress/integration/pages.test.ts @@ -209,15 +209,7 @@ describe("Pages Tests", () => { ].forEach(({ path }) => { it(`serves page ${path} with fallback at first`, () => { cy.visit(path); - - // Next.js currently behaves inconsistently here, - // dropping the default locale for static pages - if (path === "/en/fallback/d") { - cy.location("pathname").should("eq", "/fallback/d"); - } else { - cy.location("pathname").should("eq", path); - } - + cy.location("pathname").should("eq", path); cy.contains("Hello fallback"); }); }); @@ -230,7 +222,15 @@ describe("Pages Tests", () => { ].forEach(({ path }) => { it(`serves page ${path} with correct content soon`, () => { cy.visit(path); - cy.location("pathname").should("eq", path); + + // Next.js currently behaves inconsistently here, + // dropping the default locale for static pages + if (path === "/en/fallback/d") { + cy.location("pathname").should("eq", "/fallback/d"); + } else { + cy.location("pathname").should("eq", path); + } + cy.contains(`Hello ${path.slice(-1)}`); }); });