Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): e2e coverage #2142

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -35,10 +73,29 @@ 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
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
Expand All @@ -47,6 +104,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 }}-
Comment on lines +119 to +127
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a good candidate for reusable workflows

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already a re-usable workflow :(



- 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
Expand Down
1 change: 1 addition & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down