-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (81 loc) · 3.03 KB
/
Copy pathcoverage.yml
File metadata and controls
90 lines (81 loc) · 3.03 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
name: Coverage
on:
pull_request:
branches: [dev]
push:
branches: [dev]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
kcov:
permissions:
contents: read
id-token: write
issues: write
pull-requests: write
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
- name: Setup Nix
uses: ./.github/actions/setup-nix
- name: Setup Zig cache
uses: ./.github/actions/setup-zig-cache
with:
cache-key-prefix: zig-ci-coverage
- name: Run kcov line coverage
run: |
set -euo pipefail
mkdir -p coverage/kcov
# kcov currently provides the stable line-coverage signal for Zig tests;
# branch coverage and required thresholds are deferred until a baseline exists.
set +e
nix develop .#ci-unit --command kcov \
--include-path=src,modules,libs \
--exclude-path=.zig-cache,zig-cache,assets,docs \
coverage/kcov \
zig build test
kcov_status=$?
set -e
if [ "$kcov_status" -ne 0 ]; then
echo "::warning::kcov exited with status $kcov_status; rerunning tests without instrumentation to distinguish coverage tooling failures from test failures"
nix develop .#ci-unit --command zig build test
fi
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: kcov-report
path: coverage/kcov
retention-days: 14
- name: Upload to Codecov
uses: codecov/codecov-action@v5
continue-on-error: true
with:
directory: coverage/kcov
flags: unit
name: zigcraft-kcov
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Comment non-blocking coverage status
if: github.event_name == 'pull_request'
uses: actions/github-script@v8
with:
script: |
const marker = '<!-- zigcraft-kcov-status -->';
const body = `${marker}\n### kcov coverage\n\nLine coverage ran for this PR and uploaded a non-blocking report artifact named \`kcov-report\`. Codecov upload is configured as non-blocking while the project captures a stable baseline.`;
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find((comment) => comment.user.type === 'Bot' && comment.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body });
}