Skip to content

Commit

Permalink
chore(ci): πŸ‘· coverage action (#907)
Browse files Browse the repository at this point in the history
* chore(ci): πŸ‘· coverage action

* chore(actions): πŸ‘· split yml

* chore(ci-coverage): πŸ‘· continue-on-error when doing coverage

* chore(scripts): πŸ”§ add scripts.cov for coverage

* refactor: πŸ”₯ remove coverage github action

* Revert "refactor: πŸ”₯ remove coverage github action"

This reverts commit 9a683dd82c4abb405243b663074b685c0b6c0204.

* feat: ✨ using codecov service
  • Loading branch information
stormslowly authored and sorrycc committed Jun 23, 2022
1 parent 295d494 commit 619bead
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Coverage

env:
NODE_OPTIONS: --max-old-space-size=6144

on:
push:
branches:
- master
paths-ignore:
- 'examples/**'
- 'docs/**'
- '**/*.md'
pull_request:
types:
- 'opened'
- 'synchronize'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
coverage:
permissions:
checks: write
pull-requests: write
contents: read
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org/'

- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-node-jest-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-node-jest-${{ matrix.node-version }}-
- run: pnpm install

- run: pnpm build

- name: Run tests
run: pnpm run cov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@
/test/**/fixtures/*/.umi-production
/test/**/fixtures/*/src/.umi
/test/**/fixtures/*/src/.umi-production
/coverage
7 changes: 7 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ export default {
'<rootDir>/packages/.+/fixtures',
],
transformIgnorePatterns: ['/node_modules/', '/compiled/'],
collectCoverageFrom: [
'**/src/**/*.{ts,tsx}',
'!**/examples/**/*.{js,jsx,ts,tsx}',
'!**/compiled/**/*.{js,jsx}',
'!**/fixtures/**/*.*',
'!packages/create-umi/templates/**/*.*',
],
} as Config.InitialOptions;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build:force": "umi-scripts turbo --cmd build --no-cache",
"build:release": "umi-scripts turbo --cmd build --no-cache -- --declarationMap false",
"check:packageFiles": "umi-scripts checkPackageFiles",
"cov": "jest --coverage",
"dep:update": "pnpm up --interactive --latest --recursive",
"dev": "umi-scripts turbo --cmd dev",
"doc:build": "pnpm doc:deps && umi build",
Expand Down

0 comments on commit 619bead

Please sign in to comment.