-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (92 loc) · 3.24 KB
/
qa.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: QA checks
on:
pull_request:
branches:
- main
push:
branches:
- docs
jobs:
lint:
name: Lint, Typecheck, Test and Build source files
runs-on: [ self-hosted, Linux ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Lint source files
run: npm run lint
- name: Check types
run: npm run typecheck
- name: Run tests
run: npm run test:coverage
- name: Build package
run: npm run build
- name: 'Report Coverage'
if: always()
uses: davelosert/vitest-coverage-report-action@v2
- name: Gather data
id: data
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
LICENSE=$(node -p "require('./package.json').license")
echo "license=$LICENSE" >> "$GITHUB_OUTPUT"
# COVERAGE=$(node -p "require('./coverage/coverage-summary.json').total.lines.pct")
COVERAGE=50
echo "coverage=$COVERAGE" >> "$GITHUB_OUTPUT"
BRANCH=${GITHUB_REF#refs/heads/}
echo "branch=$BRANCH" >> "${GITHUB_OUTPUT}"
shell: bash
- uses: actions/checkout@v4
with:
ref: gh-badges
- name: Create badges directory
run: mkdir -p "${{ steps.data.outputs.branch }}"
shell: bash
- name: Generate version badge
uses: emibcn/badge-action@v2.0.2
with:
label: npm
status: ${{ steps.data.outputs.version }}
color: 066fef
path: ${{ steps.data.outputs.branch }}/version.svg
- name: Generate coverage badge
uses: emibcn/badge-action@v2.0.2
with:
label: coverage
status: ${{ steps.data.outputs.coverage }}%
color: ${{ steps.data.outputs.coverage > 90 && 'green'
|| steps.data.outputs.coverage > 80 && 'yellow,green'
|| steps.data.outputs.coverage > 70 && 'yellow'
|| steps.data.outputs.coverage > 60 && 'orange,yellow'
|| steps.data.outputs.coverage > 50 && 'orange'
|| steps.data.outputs.coverage > 40 && 'red,orange'
|| steps.data.outputs.coverage > 30 && 'red,red,orange'
|| steps.data.outputs.coverage > 20 && 'red,red,red,orange'
|| 'red' }}
path: ${{ steps.data.outputs.branch }}/coverage.svg
- name: Generate license badge
uses: emibcn/badge-action@v2.0.2
with:
label: license
status: ${{ steps.data.outputs.license }}
color: 066fef,ffffff
path: ${{ steps.data.outputs.branch }}/license.svg
- name: Commit files
run: |
git config --local user.email "${{ github.actor_id }}+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git status
git commit -m "Update badges"
- name: Push changes
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-badges