Skip to content

Commit 5079e7a

Browse files
feat: Add Coveralls (#9)
* Add Coveralls * Update yarn.lock * Change to use --coverage * Update lcov.info path * Add nyc dependency for coverage * Move coverage from smoke test to rust tests * Delete package-lock.json * Re-add coverage to TS test * Remove flag-name * type
1 parent 510e3fa commit 5079e7a

File tree

3 files changed

+1665
-534
lines changed

3 files changed

+1665
-534
lines changed

.github/workflows/CI.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ jobs:
4545
run: cargo fmt -- --check
4646
- name: Clippy
4747
run: cargo clippy
48+
49+
test:
50+
name: Test
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v5
54+
- name: Install Rust toolchain
55+
uses: dtolnay/rust-toolchain@stable
56+
with:
57+
components: llvm-tools-preview
58+
- name: Install cargo-llvm-cov
59+
uses: taiki-e/install-action@v2
60+
with:
61+
tool: cargo-llvm-cov
62+
- name: Cache cargo registry
63+
uses: actions/cache@v4
64+
with:
65+
path: |
66+
~/.cargo/registry
67+
~/.cargo/git
68+
target
69+
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
70+
restore-keys: |
71+
${{ runner.os }}-cargo-test-
72+
- name: Run tests with coverage
73+
run: cargo llvm-cov --verbose --workspace --lcov --output-path=lcov.info
74+
- name: Upload coverage to Coveralls
75+
env:
76+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
77+
uses: coverallsapp/[email protected]
78+
with:
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
80+
path-to-lcov: lcov.info
81+
parallel: true
4882
build:
4983
strategy:
5084
fail-fast: false
@@ -159,6 +193,14 @@ jobs:
159193
shell: bash
160194
- name: Test bindings
161195
run: yarn test
196+
- name: Upload coverage report
197+
env:
198+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
199+
uses: coverallsapp/[email protected]
200+
with:
201+
github-token: ${{ secrets.GITHUB_TOKEN }}
202+
path-to-lcov: coverage/lcov.info
203+
parallel: true
162204
test-linux-binding:
163205
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
164206
needs:
@@ -225,6 +267,26 @@ jobs:
225267
image: ${{ steps.docker.outputs.IMAGE }}
226268
options: '-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}'
227269
run: yarn test
270+
- name: Upload coverage report
271+
env:
272+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
273+
uses: coverallsapp/[email protected]
274+
with:
275+
github-token: ${{ secrets.GITHUB_TOKEN }}
276+
path-to-lcov: coverage/lcov.info
277+
parallel: true
278+
coverage:
279+
name: Report Coverage
280+
runs-on: ubuntu-latest
281+
needs: [test, test-macOS-windows-binding, test-linux-binding]
282+
steps:
283+
- name: Send coverage
284+
env:
285+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
286+
uses: coverallsapp/[email protected]
287+
with:
288+
github-token: ${{ secrets.GITHUB_TOKEN }}
289+
parallel-finished: true
228290
publish:
229291
name: Publish
230292
runs-on: ubuntu-latest
@@ -233,6 +295,7 @@ jobs:
233295
id-token: write
234296
needs:
235297
- lint
298+
- test
236299
- test-macOS-windows-binding
237300
- test-linux-binding
238301
steps:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"format:rs": "cargo fmt",
5151
"lint": "oxlint .",
5252
"prepublishOnly": "napi prepublish -t npm",
53-
"test": "ava",
53+
"test": "nyc --reporter=lcov ava",
5454
"version": "napi version",
5555
"prepare": "husky"
5656
},
@@ -66,6 +66,7 @@
6666
"husky": "^9.1.7",
6767
"lint-staged": "^16.1.2",
6868
"npm-run-all2": "^8.0.4",
69+
"nyc": "^17.1.0",
6970
"oxlint": "^1.8.0",
7071
"prettier": "^3.6.2",
7172
"tinybench": "^5.0.0",

0 commit comments

Comments
 (0)