Skip to content

Commit 46a3f30

Browse files
authored
Merge pull request #87 from aelf-lxy/master
add github badge
2 parents 275afc1 + 3a6a5c8 commit 46a3f30

File tree

4 files changed

+218
-151
lines changed

4 files changed

+218
-151
lines changed

.github/workflows/coverage.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Unit Test Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '18'
23+
24+
- name: Install dependencies
25+
run: yarn install
26+
27+
- name: Run tests with coverage
28+
run: yarn run test:coverage
29+
30+
- name: Generate coverage badge
31+
uses: jaywcjlove/coverage-badges-cli@main
32+
with:
33+
source: coverage/coverage-summary.json
34+
output: coverage/badges.svg
35+
36+
- name: Deploy to GitHub Pages
37+
uses: peaceiris/actions-gh-pages@v3
38+
with:
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
40+
publish_dir: ./coverage

.github/workflows/test-badge.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
branches:
99
- dev
1010
- master
11+
- feature/badge-success
1112

1213
env:
1314
BRANCH_NAME: 'feature/badge-json'
@@ -48,8 +49,9 @@ jobs:
4849
const tests = "${{ env.TESTS }}";
4950
const failures = "${{ env.FAILURES }}";
5051
const errors = "${{ env.ERRORS }}";
52+
const success = tests - failures;
5153
const color = errors > 0 ? "red" : (failures > 0 ? "green" : "brightgreen");
52-
const content = `{"schemaVersion":1,"label":"tests","message":"${tests} tests, ${failures} failures, ${errors} errors","color":"${color}"}`;
54+
const content = `{"schemaVersion":1,"label":"tests","message":"${tests} tests, ${success} success","color":"${color}"}`;
5355
5456
fs.writeFileSync("${{ env.FILENAME }}", content);
5557

0 commit comments

Comments
 (0)