Skip to content

Commit

Permalink
chore: use c8 for coverage testing (#14961)
Browse files Browse the repository at this point in the history
* test

* fix

* fix

* test

* test

* test

* test

* c8

* d.ts

* c8 ci

* fix

* fix

* codecov v3
  • Loading branch information
liuxingbaoyu committed Sep 21, 2022
1 parent 5a9b421 commit c602be9
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 32 deletions.
15 changes: 15 additions & 0 deletions .c8rc
@@ -0,0 +1,15 @@
{
"all": true,
"reporter":["lcov", "text"],
"include": [
"packages/*/lib/**/*.{js,cjs,mjs,ts}",
"codemods/*/lib/**/*.{js,cjs,mjs,ts}",
"eslint/*/lib/**/*.{js,cjs,mjs,ts}"
],
"exclude":[
"packages/babel-standalone/**",
"packages/babel-types/**/generated/*",
"packages/babel-helpers/*/helpers/*",
"packages/babel-core/*/vendor/*"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -67,7 +67,7 @@ jobs:
make -j test-ci-coverage
yarn test:esm
- name: Upload coverage report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

test-esm:
name: Test ESM version
Expand Down
2 changes: 1 addition & 1 deletion Gulpfile.mjs
Expand Up @@ -154,7 +154,7 @@ function generateTraverseHelpers(helperKind) {
return generateHelpers(
`./packages/babel-traverse/scripts/generators/${helperKind}.js`,
`./packages/babel-traverse/src/path/generated/`,
`${helperKind}.ts`,
`${helperKind}.d.ts`,
`@babel/traverse -> ${helperKind}`
);
}
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -144,8 +144,9 @@ test-ci: build-standalone-ci
$(MAKE) test-clean

test-ci-coverage:
BABEL_ENV=test BABEL_COVERAGE=true $(MAKE) bootstrap
BABEL_ENV=test BABEL_COVERAGE=true $(YARN) jest --maxWorkers=100% --ci --coverage
BABEL_ENV=test $(MAKE) bootstrap
BABEL_ENV=test BABEL_COVERAGE=true $(YARN) c8 jest --maxWorkers=100% --ci
rm -rf coverage/tmp

bootstrap-flow:
rm -rf build/flow
Expand Down
2 changes: 1 addition & 1 deletion Makefile.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Makefile.source.mjs
Expand Up @@ -374,10 +374,11 @@ target["test-only"] = function (args = []) {
};

target["test-cov"] = function () {
target["build"]();

env(
() => {
target["build"]();
yarn(["jest", "--coverage"]);
yarn(["c8", "jest"]);
},
{
BABEL_ENV: "test",
Expand Down
8 changes: 0 additions & 8 deletions babel.config.js
Expand Up @@ -21,8 +21,6 @@ module.exports = function (api) {

const sources = ["packages/*/src", "codemods/*/src", "eslint/*/src"];

const includeCoverage = process.env.BABEL_COVERAGE === "true";

const envOpts = {
shippedProposals: true,
modules: false,
Expand Down Expand Up @@ -293,12 +291,6 @@ module.exports = function (api) {
].filter(Boolean),
};

// we need to do this as long as we do not test everything from source
if (includeCoverage) {
config.auxiliaryCommentBefore = "istanbul ignore next";
config.plugins.push("babel-plugin-istanbul");
}

return config;
};

Expand Down
15 changes: 8 additions & 7 deletions jest.config.js
Expand Up @@ -19,21 +19,22 @@ module.exports = {
runner: supportsESMAndJestLightRunner ? "jest-light-runner" : "jest-runner",

snapshotFormat: { escapeString: true, printBasicPrototype: true },
coverageProvider: "v8",
coverageReporters: ["lcov", "text"],
collectCoverageFrom: [
"packages/*/src/**/*.{js,cjs,mjs,ts}",
"codemods/*/src/**/*.{js,cjs,mjs,ts}",
"eslint/*/src/**/*.{js,cjs,mjs,ts}",
"packages/*/lib/**/*.{js,cjs,mjs,ts}",
"codemods/*/lib/**/*.{js,cjs,mjs,ts}",
"eslint/*/lib/**/*.{js,cjs,mjs,ts}",
],
// coveragePathIgnorePatterns Doesn't work on windows
coveragePathIgnorePatterns: [
"/node_modules/",
"<rootDir>/packages/babel-standalone/",
"/test/(fixtures|tmp|__data__)/",
".*\\.d\\.ts",
"<rootDir>/packages/babel-standalone/.*",
"<rootDir>/packages/babel-types/src/.*/generated/.*",
"<rootDir>/packages/babel-helpers/src/helpers/.*",
"<rootDir>/packages/babel-core/src/vendor/.*",
"<rootDir>/packages/babel-types/.*/generated/.*",
"<rootDir>/packages/babel-helpers/.*/helpers/.*",
"<rootDir>/packages/babel-core/.*/vendor/.*",
],

// The eslint/* packages is tested against ESLint v8, which has dropped support for Node v10.
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -42,6 +42,7 @@
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"babel-plugin-transform-charcodes": "^0.2.0",
"c8": "^7.12.0",
"chalk": "^5.0.0",
"charcodes": "^0.2.0",
"core-js": "^3.25.1",
Expand Down
@@ -0,0 +1 @@
// A empty file for jest v8 coverage provider
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 65 additions & 10 deletions yarn.lock
Expand Up @@ -3886,10 +3886,10 @@ __metadata:
languageName: node
linkType: hard

"@istanbuljs/schema@npm:^0.1.2":
version: 0.1.2
resolution: "@istanbuljs/schema@npm:0.1.2"
checksum: 5ce9facf2f0e3f4a93e56853cdfd78456e22d2c210c677530046e9c634ddc323dd62423ac711cd3554b5be06052c87fb8e0c266aa9010726940654c357290e78
"@istanbuljs/schema@npm:^0.1.2, @istanbuljs/schema@npm:^0.1.3":
version: 0.1.3
resolution: "@istanbuljs/schema@npm:0.1.3"
checksum: 5282759d961d61350f33d9118d16bcaed914ebf8061a52f4fa474b2cb08720c9c81d165e13b82f2e5a8a212cc5af482f0c6fc1ac27b9e067e5394c9a6ed186c9
languageName: node
linkType: hard

Expand Down Expand Up @@ -5935,6 +5935,7 @@ __metadata:
"@typescript-eslint/eslint-plugin": ^5.36.1
"@typescript-eslint/parser": ^5.36.1
babel-plugin-transform-charcodes: ^0.2.0
c8: ^7.12.0
chalk: ^5.0.0
charcodes: ^0.2.0
core-js: ^3.25.1
Expand Down Expand Up @@ -6369,6 +6370,28 @@ __metadata:
languageName: node
linkType: hard

"c8@npm:^7.12.0":
version: 7.12.0
resolution: "c8@npm:7.12.0"
dependencies:
"@bcoe/v8-coverage": ^0.2.3
"@istanbuljs/schema": ^0.1.3
find-up: ^5.0.0
foreground-child: ^2.0.0
istanbul-lib-coverage: ^3.2.0
istanbul-lib-report: ^3.0.0
istanbul-reports: ^3.1.4
rimraf: ^3.0.2
test-exclude: ^6.0.0
v8-to-istanbul: ^9.0.0
yargs: ^16.2.0
yargs-parser: ^20.2.9
bin:
c8: bin/c8.js
checksum: 3b7fa9ad7cff2cb0bb579467e6b544498fbd46e9353a809ad3b8cf749df4beadd074cde277356b0552f3c8055b1b3ec3ebaf2209e9ad4bdefed92dbf64d283ab
languageName: node
linkType: hard

"cacache@npm:^12.0.2":
version: 12.0.4
resolution: "cacache@npm:12.0.4"
Expand Down Expand Up @@ -7092,7 +7115,7 @@ __metadata:
languageName: node
linkType: hard

"cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3":
"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3":
version: 7.0.3
resolution: "cross-spawn@npm:7.0.3"
dependencies:
Expand Down Expand Up @@ -8605,6 +8628,16 @@ __metadata:
languageName: node
linkType: hard

"foreground-child@npm:^2.0.0":
version: 2.0.0
resolution: "foreground-child@npm:2.0.0"
dependencies:
cross-spawn: ^7.0.0
signal-exit: ^3.0.2
checksum: f77ec9aff621abd6b754cb59e690743e7639328301fbea6ff09df27d2befaf7dd5b77cec51c32323d73a81a7d91caaf9413990d305cbe3d873eec4fe58960956
languageName: node
linkType: hard

"forever-agent@npm:~0.6.1":
version: 0.6.1
resolution: "forever-agent@npm:0.6.1"
Expand Down Expand Up @@ -10047,13 +10080,13 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"istanbul-reports@npm:^3.1.3":
version: 3.1.4
resolution: "istanbul-reports@npm:3.1.4"
"istanbul-reports@npm:^3.1.3, istanbul-reports@npm:^3.1.4":
version: 3.1.5
resolution: "istanbul-reports@npm:3.1.5"
dependencies:
html-escaper: ^2.0.0
istanbul-lib-report: ^3.0.0
checksum: 2132983355710c522f6b26808015cab9a0ee8b9f5ae0db0d3edeff40b886dd83cb670fb123cb7b32dbe59473d7c00cdde2ba6136bc0acdb20a865fccea64dfe1
checksum: 7867228f83ed39477b188ea07e7ccb9b4f5320b6f73d1db93a0981b7414fa4ef72d3f80c4692c442f90fc250d9406e71d8d7ab65bb615cb334e6292b73192b89
languageName: node
linkType: hard

Expand Down Expand Up @@ -14952,7 +14985,7 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"v8-to-istanbul@npm:^9.0.1":
"v8-to-istanbul@npm:^9.0.0, v8-to-istanbul@npm:^9.0.1":
version: 9.0.1
resolution: "v8-to-istanbul@npm:9.0.1"
dependencies:
Expand Down Expand Up @@ -15489,6 +15522,13 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"yargs-parser@npm:^20.2.2, yargs-parser@npm:^20.2.9":
version: 20.2.9
resolution: "yargs-parser@npm:20.2.9"
checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3
languageName: node
linkType: hard

"yargs-parser@npm:^21.0.0":
version: 21.0.1
resolution: "yargs-parser@npm:21.0.1"
Expand All @@ -15505,6 +15545,21 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"yargs@npm:^16.2.0":
version: 16.2.0
resolution: "yargs@npm:16.2.0"
dependencies:
cliui: ^7.0.2
escalade: ^3.1.1
get-caller-file: ^2.0.5
require-directory: ^2.1.1
string-width: ^4.2.0
y18n: ^5.0.5
yargs-parser: ^20.2.2
checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59
languageName: node
linkType: hard

"yargs@npm:^17.3.1":
version: 17.4.1
resolution: "yargs@npm:17.4.1"
Expand Down

0 comments on commit c602be9

Please sign in to comment.