From daf3e26b7f19d07ced11f1dfe51bef920a9cb6d4 Mon Sep 17 00:00:00 2001 From: kahboom Date: Mon, 3 Jun 2024 18:25:57 +0100 Subject: [PATCH] test(e2e): split install + run jobs --- .github/workflows/e2e-tests.yaml | 63 +++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index 56a5853..3ce82c8 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -10,20 +10,8 @@ on: - cron: '0 2 * * FRI' jobs: - cypress-run: + install: runs-on: ubuntu-latest - timeout-minutes: 30 - strategy: - matrix: - browser: [ chrome, electron ] - env: - - name: no-variable - NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "" - - name: with-variable - NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "https://rekor.sigstore.dev" - env: - CYPRESS_baseUrl: ${{ matrix.env.url }} - steps: - name: Checkout 🛎 uses: actions/checkout@v4 @@ -59,8 +47,57 @@ jobs: sudo apt-get install -y firefox; fi + - name: Cypress install + uses: cypress-io/github-action@v6 + with: + # disable running of tests within install job + runTests: false + build: npm run build + + - name: Save build folder + uses: actions/upload-artifact@v4 + with: + name: build + if-no-files-found: error + path: build + + cypress-run: + runs-on: ubuntu-latest + needs: install + timeout-minutes: 30 + strategy: + matrix: + browser: [ chrome, electron ] + env: + - name: no-variable + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "" + - name: with-variable + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "https://rekor.sigstore.dev" + env: + CYPRESS_baseUrl: ${{ matrix.env.url }} + + steps: + - name: Checkout 🛎 + uses: actions/checkout@v4 + + - name: Download the build folder + uses: actions/download-artifact@v4 + with: + name: build + path: .next + + - name: Start Next.js app + run: npm run start & + env: + NODE_ENV: ${{ matrix.env.name }} + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }} + + - name: Wait for Next.js to start + run: npx wait-on http://localhost:3000 + - name: Run Cypress tests run: npx cypress run --browser ${{ matrix.browser }} + uses: cypress-io/github-action@v6 env: NODE_ENV: ${{ matrix.env.name }} NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }}