-
-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (53 loc) · 1.81 KB
/
ci.yml
File metadata and controls
61 lines (53 loc) · 1.81 KB
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
name: CI
on:
push:
branches: [main, staging]
pull_request:
branches: [main, staging]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: project/package-lock.json
- name: Install dependencies
working-directory: project
run: npm ci --omit=optional
- name: Run tests
working-directory: project
run: |
npm test 2>&1 | tee test-output.txt
# Fail the step if node exited non-zero (tee masks the exit code)
exit ${PIPESTATUS[0]}
- name: Parse test results
if: always()
id: test-results
working-directory: project
run: |
PASS=$(grep -oP '# pass \K[0-9]+' test-output.txt || echo "0")
FAIL=$(grep -oP '# fail \K[0-9]+' test-output.txt || echo "0")
echo "pass=$PASS" >> "$GITHUB_OUTPUT"
echo "fail=$FAIL" >> "$GITHUB_OUTPUT"
if [ "$FAIL" = "0" ]; then
echo "color=brightgreen" >> "$GITHUB_OUTPUT"
echo "label=$PASS passing" >> "$GITHUB_OUTPUT"
else
echo "color=red" >> "$GITHUB_OUTPUT"
echo "label=$PASS passing, $FAIL failing" >> "$GITHUB_OUTPUT"
fi
- name: Update test count badge
if: github.ref == 'refs/heads/main' && always()
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ vars.BADGE_GIST_ID }}
filename: nekocore-test-results.json
label: tests
message: ${{ steps.test-results.outputs.label }}
color: ${{ steps.test-results.outputs.color }}
style: flat-square