Repository navigation
91 lines (90 loc) · 3.63 KB
/
Copy pathbackend.yml
File metadata and controls
91 lines (90 loc) · 3.63 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
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
name: backend
on:
push:
branches:
- main
paths-ignore:
- "frontend/**"
pull_request:
paths-ignore:
- "frontend/**"
jobs:
test:
runs-on:
labels: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
# `just test` under c8 (backend/.c8rc.json): same suite, plus the report copied out of the
# container to backend/coverage/ for the two steps below.
- name: run tests (with coverage)
run: just test-coverage
timeout-minutes: 50
- name: coverage summary
run: node scripts/coverage-report.mjs markdown backend backend/coverage/coverage-summary.json >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v4
with:
name: coverage-backend
path: |
backend/coverage/coverage-summary.json
backend/coverage/lcov.info
backend/coverage/lcov-report
if-no-files-found: error
# Turns the coverage artifact into a Markdown report (metrics table) and an SVG badge. The script is
# scripts/coverage-report.mjs (no dependencies, no external service). The job force-pushes the report, the
# badge and the raw summary to the orphan `badges` branch as a single commit, with the workflow's own
# GITHUB_TOKEN. README.md links to the report (a link never renders as a broken image; the
# branch only exists after the first main build).
coverage-badge:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: coverage-badge
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: coverage-backend
path: coverage-artifact
- name: render badge
run: |
set -euo pipefail
mkdir -p badges
node scripts/coverage-report.mjs badge coverage-artifact/coverage-summary.json badges/backend-coverage.svg "backend coverage"
cp coverage-artifact/coverage-summary.json badges/backend-coverage-summary.json
{
echo "# Test coverage"
echo
echo "Generated by \`.github/workflows/backend.yml\` (job \`coverage-badge\`) for"
echo "\`${GITHUB_SHA}\` on $(date -u +%Y-%m-%dT%H:%M:%SZ). Do not edit — every run replaces this branch."
echo "Per-file detail: the \`coverage-backend\` artifact (lcov + HTML report) of that run."
echo
node scripts/coverage-report.mjs markdown backend badges/backend-coverage-summary.json
} > badges/README.md
- name: publish to the badges branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
cd badges
git init -b badges
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -q -m "coverage badge for ${GITHUB_SHA}"
git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" badges:badges
license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: earthly/actions/setup-earthly@v1
- uses: actions/setup-node@v3
with:
node-version: '18'
- uses: extractions/setup-just@v1
- name: license checker
run: 'cd backend && npx license-checker --onlyAllow="MIT;ISC;Python-2.0;Apache-2.0;BSD;MPL;CC;Custom: http://github.com/dscape/statsd-parser;" --excludePrivatePackages'