Skip to content

Commit

Permalink
migrate to c8 (#996)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JLHwung committed Jul 18, 2023
1 parent b89dfbd commit df36cba
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 421 deletions.
6 changes: 6 additions & 0 deletions .c8rc.json
@@ -0,0 +1,6 @@
{
"all": true,
"src": ["./src"],
"include": ["lib/**"],
"reporter": ["lcov", "text"]
}
41 changes: 20 additions & 21 deletions .github/workflows/ci.yml
Expand Up @@ -6,19 +6,6 @@ permissions:
contents: read # to fetch code (actions/checkout)

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: latest
cache: 'yarn'
- name: Install dependencies
run: yarn
- name: Lint
run: yarn run lint
test:
name: Test - ${{ matrix.os }} - Node ${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}
strategy:
Expand All @@ -30,10 +17,6 @@ jobs:
- node-version: "14.15.0" # The minimum supported node version
webpack-version: latest
os: ubuntu-latest
- node-version: latest
webpack-version: latest
os: ubuntu-latest
coverage: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -48,13 +31,29 @@ jobs:
run: yarn add -D webpack@${{ matrix.webpack-version }}
- name: Build babel-loader
run: yarn run build
env:
BABEL_ENV: test
- name: Run tests for webpack version ${{ matrix.webpack-version }}
run: yarn test-only

lint-coverage:
name: Lint and Coverage - ${{ matrix.os }} - Node ${{ matrix.node-version }}, Webpack 5
strategy:
matrix:
os: [ubuntu-latest]
node-version: [latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn
- name: Run lint and coverage tests
run: yarn test
- name: Submit coverage data to codecov
uses: codecov/codecov-action@v1
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

8 changes: 2 additions & 6 deletions babel.config.json
Expand Up @@ -5,12 +5,8 @@
"presets": [
["@babel/preset-env", {
"loose": true,
"bugfixes": true,
"modules": false
}]
],
"env": {
"test": {
"plugins": ["istanbul"]
}
}
]
}
11 changes: 3 additions & 8 deletions package.json
Expand Up @@ -24,17 +24,15 @@
"@babel/preset-env": "^7.19.4",
"ava": "^3.13.0",
"babel-eslint": "^10.1.0",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-react-intl": "^8.2.25",
"cross-env": "^7.0.2",
"c8": "^8.0.0",
"eslint": "^7.13.0",
"eslint-config-babel": "^9.0.0",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-prettier": "^3.0.0",
"husky": "^4.3.0",
"lint-staged": "^10.5.1",
"nyc": "^15.1.0",
"pnp-webpack-plugin": "^1.6.4",
"prettier": "^2.1.2",
"react": "^17.0.1",
Expand All @@ -52,8 +50,8 @@
"precommit": "lint-staged",
"prepublish": "yarn run clean && yarn run build",
"preversion": "yarn run test",
"test": "yarn run lint && cross-env BABEL_ENV=test yarn run build && yarn run test-only",
"test-only": "nyc ava"
"test": "yarn run lint && yarn run build --source-maps && c8 yarn run test-only",
"test-only": "ava"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -118,8 +116,5 @@
"node ./scripts/yarn-install.js",
"git add yarn.lock"
]
},
"resolutions": {
"nyc/node-preload": "0.2.0"
}
}

0 comments on commit df36cba

Please sign in to comment.