-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (65 loc) · 2.06 KB
/
Copy pathci.yml
File metadata and controls
70 lines (65 loc) · 2.06 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
name: ci
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Lint (zig fmt --check)
run: zig build lint
- name: Build
run: zig build
- name: Unit tests
run: zig build test --summary all
- name: Integration tests
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}
run: zig build itest --summary all
# Runs on macOS: kcov reads the unit-test binary's debug info there,
# while on Linux it reports zero instrumented files for that binary
# (the integration binary works on both).
coverage:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Install kcov
run: brew install kcov
- name: Code coverage
env:
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}
run: |
zig build cov
for f in $(find zig-out/coverage -maxdepth 3 -name coverage.json); do
echo "$f: $(head -c 300 $f | tr -d '\n')"
done
python3 - <<'EOF' >> "$GITHUB_STEP_SUMMARY"
import json
report = json.load(open("zig-out/coverage/merged/kcov-merged/coverage.json"))
print("## Code coverage: %s%%\n" % report["percent_covered"])
print("| file | covered | total | percent |")
print("|---|---|---|---|")
for f in report["files"]:
print("| %s | %s | %s | %s%% |" % (
f["file"].split("/")[-1], f["covered_lines"],
f["total_lines"], f["percent_covered"]))
EOF
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: coverage
path: zig-out/coverage/merged/kcov-merged