-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (37 loc) · 1.18 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install --global pnpm@7
- run: pnpm install
- run: pnpm run build
- run: pnpm run lint
- run: pnpm test -- --coverage --coverageReporters="json-summary"
- uses: actions/github-script@v6
id: coveragejson
with:
script: |
const fs = require('fs')
const summary = JSON.parse(fs.readFileSync('./coverage/coverage-summary.json').toString())
const {pct} = summary.total.branches
const colors = {'00EE00': 98, 'FFFF33': 90}
return {
pct,
color: Object.entries(colors).find(e => pct >= e[1])[0] || 'FF0000',
}
- name: coverage badge
if: github.ref_name == 'main'
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: coverage
LABEL: coverage
STATUS: '${{ fromJson(steps.coveragejson.outputs.result).pct }}%'
COLOR: ${{ fromJson(steps.coveragejson.outputs.result).color }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}