From 4c49b571686c68b1f9a27b77e55e491fe35dd331 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:05:08 -0700 Subject: [PATCH 1/2] tests(e2e): coverage for separate shard runs --- .github/workflows/test-e2e.yml | 44 ++++++++++++++++++++++++++++++++++ config-overrides.js | 1 + 2 files changed, 45 insertions(+) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 05a05d15b..d636f3240 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -39,6 +39,15 @@ jobs: - name: Run test build run: npm run test:build + - name: Cache nyc_output dir + uses: actions/cache@v3.3.1 + id: nyc_output-cache + with: + path: ./.nyc_output + key: nyc_output-${{ runner.os }}-${{ github.sha }} + restore-keys: | + nyc_output-${{ runner.os }}-${{ github.sha }} + - name: Run repeated-E2E against Kubo if: github.ref != 'refs/heads/main' # only run duplicated e2e tests on PRs run: npm run test:e2e -- --repeat-each 10 --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} # run each test 10 times to ensure no flakiness @@ -47,6 +56,41 @@ jobs: if: github.ref == 'refs/heads/main' # run non-duplicated tests on non-PRs run: npm run test:e2e -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + e2e-coverage: # since we run coverage in shards and some files may not contain coverage, we cache the .nyc_output directory + name: 'e2e-coverage' + runs-on: ubuntu-latest + needs: [test-e2e] + steps: + - uses: actions/checkout@v3.5.3 + + - name: Setup node + uses: actions/setup-node@v3.6.0 + with: + node-version: 18.14.0 + + - name: Cache bigger downloads + uses: actions/cache@v3.3.1 + id: cache + with: + path: ${{ github.workspace }}/.cache + key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} + restore-keys: | + ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} + ${{ runner.os }}- + + + - name: Install dependencies + run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm + + - name: Cache nyc_output dir + uses: actions/cache@v3.3.1 + id: nyc_output-cache + with: + path: ./.nyc_output + key: nyc_output-${{ runner.os }}-${{ github.sha }} + restore-keys: | + nyc_output-${{ runner.os }}-${{ github.sha }} + - name: Generate nyc coverage report id: coverage run: npx nyc report --reporter=lcov diff --git a/config-overrides.js b/config-overrides.js index bd4663256..f6a4fc630 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -110,6 +110,7 @@ function webpackOverride (config) { const REACT_APP_ENV = process.env.REACT_APP_ENV ?? process.env.NODE_ENV ?? 'development' if (REACT_APP_ENV === 'test') { config.module.rules = modifyBabelLoaderRuleForTest(config.module.rules) + config.devtool = 'inline-source-map' } else if (REACT_APP_ENV === 'development') { config.optimization = { ...config.optimization, From 3344a914eea29b778e0628bfcaaa8bff61c42e41 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:12:18 -0700 Subject: [PATCH 2/2] test(e2e): cache test-build --- .github/workflows/test-e2e.yml | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index d636f3240..aeafec63a 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -2,10 +2,48 @@ on: workflow_call: jobs: + test-build: + name: 'test:build' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.3 + + - name: Setup node + uses: actions/setup-node@v3.6.0 + with: + node-version: 18.14.0 + + - name: Cache bigger downloads + uses: actions/cache@v3.3.1 + id: cache + with: + path: ${{ github.workspace }}/.cache + key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} + restore-keys: | + ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} + ${{ runner.os }}- + + - name: Install dependencies + run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm + + - name: Cache test-build output + uses: actions/cache@v3.3.1 + id: test-build-cache + with: + path: build + key: test-build-${{ runner.os }}-${{ github.sha }} + restore-keys: | + test-build-${{ runner.os }}-${{ github.sha }} + + # This is required to ensure that our code is instrumented with coverage details + - name: Run test build + if: steps.test-build-cache.outputs.cache-hit != 'true' + run: npm run test:build test-e2e: name: 'test:e2e' runs-on: ubuntu-latest + needs: [test-build] strategy: fail-fast: false matrix: @@ -35,8 +73,18 @@ jobs: - name: Install playwright browsers run: npx playwright install --with-deps + - name: Cache test-build output + uses: actions/cache@v3.3.1 + id: test-build-cache + with: + path: build + key: test-build-${{ runner.os }}-${{ github.sha }} + restore-keys: | + test-build-${{ runner.os }}-${{ github.sha }} + # This is required to ensure that our code is instrumented with coverage details - name: Run test build + if: steps.test-build-cache.outputs.cache-hit != 'true' run: npm run test:build - name: Cache nyc_output dir