-
Notifications
You must be signed in to change notification settings - Fork 9
96 lines (90 loc) · 3.18 KB
/
Copy pathci.yml
File metadata and controls
96 lines (90 loc) · 3.18 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
92
93
94
95
96
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Least privilege: these jobs only read the repo (and upload artifacts via the
# Actions runtime token, which needs no extra GITHUB_TOKEN scope).
permissions:
contents: read
jobs:
test:
name: Test / Zig ${{ matrix.zig-version }} / ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
zig-version: ["0.16.0"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: ${{ matrix.zig-version }}
- name: Run unit tests
run: zig build test
fmt:
name: Format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: "0.16.0"
- name: Check formatting
run: zig fmt --check src/ tests/
build:
name: Build / ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: "0.16.0"
- name: Build library
run: zig build
coverage:
name: Coverage (kcov)
runs-on: ubuntu-latest
# Informational: surfaces which branches the unit tests exercise. Not a
# required check -- a coverage dip should not block a merge on its own.
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: "0.16.0"
- name: Install kcov
# kcov was dropped from Ubuntu's repos (gone in 24.04 noble) and ships
# no prebuilt binaries, so build a pinned release from source.
env:
KCOV_VERSION: v43
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake g++ binutils-dev libcurl4-openssl-dev libdw-dev \
libiberty-dev zlib1g-dev libssl-dev
git clone --depth 1 --branch "$KCOV_VERSION" https://github.com/SimonKagstrom/kcov.git /tmp/kcov
cmake -S /tmp/kcov -B /tmp/kcov/build -DCMAKE_BUILD_TYPE=Release
cmake --build /tmp/kcov/build --parallel "$(nproc)"
sudo cmake --install /tmp/kcov/build
- name: Build unit-test binary
run: zig build install-test
- name: Run kcov
run: kcov --include-pattern=src/ --exclude-pattern=src/crypto/ kcov-out ./zig-out/bin/test
- name: Upload coverage report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-report
path: kcov-out