-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tests(e2e): coverage for separate shard runs * test(e2e): cache test-build
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,48 @@ on: | |
workflow_call: | ||
|
||
jobs: | ||
test-build: | ||
name: 'test:build' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Setup node | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 18.14.0 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/[email protected] | ||
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/[email protected] | ||
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,10 +73,29 @@ jobs: | |
- name: Install playwright browsers | ||
run: npx playwright install --with-deps | ||
|
||
- name: Cache test-build output | ||
uses: actions/[email protected] | ||
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/[email protected] | ||
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 +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/[email protected] | ||
|
||
- name: Setup node | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 18.14.0 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/[email protected] | ||
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/[email protected] | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters