Skip to content

Commit df36cba

Browse files
authored
migrate to c8 (#996)
* migrate to c8 * remove cross-env * report coverages from lib/*.js only * bump codecov-action to v3 * merge coverage job with lint job * remap coverage to source files * add lcov reporter
1 parent b89dfbd commit df36cba

File tree

5 files changed

+168
-421
lines changed

5 files changed

+168
-421
lines changed

.c8rc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"all": true,
3+
"src": ["./src"],
4+
"include": ["lib/**"],
5+
"reporter": ["lcov", "text"]
6+
}

.github/workflows/ci.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@ permissions:
66
contents: read # to fetch code (actions/checkout)
77

88
jobs:
9-
lint:
10-
name: lint
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v3
14-
- uses: actions/setup-node@v3
15-
with:
16-
node-version: latest
17-
cache: 'yarn'
18-
- name: Install dependencies
19-
run: yarn
20-
- name: Lint
21-
run: yarn run lint
229
test:
2310
name: Test - ${{ matrix.os }} - Node ${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}
2411
strategy:
@@ -30,10 +17,6 @@ jobs:
3017
- node-version: "14.15.0" # The minimum supported node version
3118
webpack-version: latest
3219
os: ubuntu-latest
33-
- node-version: latest
34-
webpack-version: latest
35-
os: ubuntu-latest
36-
coverage: true
3720
runs-on: ${{ matrix.os }}
3821
steps:
3922
- uses: actions/checkout@v3
@@ -48,13 +31,29 @@ jobs:
4831
run: yarn add -D webpack@${{ matrix.webpack-version }}
4932
- name: Build babel-loader
5033
run: yarn run build
51-
env:
52-
BABEL_ENV: test
5334
- name: Run tests for webpack version ${{ matrix.webpack-version }}
5435
run: yarn test-only
36+
37+
lint-coverage:
38+
name: Lint and Coverage - ${{ matrix.os }} - Node ${{ matrix.node-version }}, Webpack 5
39+
strategy:
40+
matrix:
41+
os: [ubuntu-latest]
42+
node-version: [latest]
43+
runs-on: ${{ matrix.os }}
44+
steps:
45+
- uses: actions/checkout@v3
46+
- name: Use Node.js ${{ matrix.node-version }}
47+
uses: actions/setup-node@v3
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
cache: 'yarn'
51+
- name: Install dependencies
52+
run: yarn
53+
- name: Run lint and coverage tests
54+
run: yarn test
5555
- name: Submit coverage data to codecov
56-
uses: codecov/codecov-action@v1
57-
if: ${{ matrix.coverage }}
56+
uses: codecov/codecov-action@v3
5857
with:
5958
token: ${{ secrets.CODECOV_TOKEN }}
6059

babel.config.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
"presets": [
66
["@babel/preset-env", {
77
"loose": true,
8+
"bugfixes": true,
89
"modules": false
910
}]
10-
],
11-
"env": {
12-
"test": {
13-
"plugins": ["istanbul"]
14-
}
15-
}
11+
]
1612
}

package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@
2424
"@babel/preset-env": "^7.19.4",
2525
"ava": "^3.13.0",
2626
"babel-eslint": "^10.1.0",
27-
"babel-plugin-istanbul": "^6.1.1",
2827
"babel-plugin-react-intl": "^8.2.25",
29-
"cross-env": "^7.0.2",
28+
"c8": "^8.0.0",
3029
"eslint": "^7.13.0",
3130
"eslint-config-babel": "^9.0.0",
3231
"eslint-config-prettier": "^6.3.0",
3332
"eslint-plugin-flowtype": "^5.2.0",
3433
"eslint-plugin-prettier": "^3.0.0",
3534
"husky": "^4.3.0",
3635
"lint-staged": "^10.5.1",
37-
"nyc": "^15.1.0",
3836
"pnp-webpack-plugin": "^1.6.4",
3937
"prettier": "^2.1.2",
4038
"react": "^17.0.1",
@@ -52,8 +50,8 @@
5250
"precommit": "lint-staged",
5351
"prepublish": "yarn run clean && yarn run build",
5452
"preversion": "yarn run test",
55-
"test": "yarn run lint && cross-env BABEL_ENV=test yarn run build && yarn run test-only",
56-
"test-only": "nyc ava"
53+
"test": "yarn run lint && yarn run build --source-maps && c8 yarn run test-only",
54+
"test-only": "ava"
5755
},
5856
"repository": {
5957
"type": "git",
@@ -118,8 +116,5 @@
118116
"node ./scripts/yarn-install.js",
119117
"git add yarn.lock"
120118
]
121-
},
122-
"resolutions": {
123-
"nyc/node-preload": "0.2.0"
124119
}
125120
}

0 commit comments

Comments
 (0)