-
Notifications
You must be signed in to change notification settings - Fork 1
204 lines (187 loc) · 6.55 KB
/
build.yml
File metadata and controls
204 lines (187 loc) · 6.55 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# SPDX-FileCopyrightText: 2025 Alexandre Gomes Gaigalas <alganet@gmail.com>
# SPDX-License-Identifier: BSD-3-Clause
name: CI
permissions: {}
env:
ALL_FILES_MIN_COVERAGE: 20
CHANGED_FILES_MIN_COVERAGE: 25
on:
push:
branches: [ main ]
paths:
- 'src/**'
- 'tests/**'
- 'Makefile'
- 'build-aux/**'
- '.github/workflows/build.yml'
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- 'Makefile'
- 'build-aux/**'
- '.github/workflows/build.yml'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
include:
- mode: full
name: x86_64-linux-gnu
os: ubuntu-latest
- mode: full
name: x86_64-windows-msvc
os: windows-latest
extension: .exe
- mode: full
name: arm64-apple-darwin
os: macos-latest
- mode: full
name: x86_64-apple-darwin
os: macos-15-intel
- mode: tiny
name: x86_64-linux-gnu
os: ubuntu-latest
- mode: tiny
name: x86_64-windows-msvc
os: windows-latest
extension: .exe
- mode: tiny
name: arm64-apple-darwin
os: macos-latest
- mode: tiny
name: x86_64-apple-darwin
os: macos-15-intel
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-action
- uses: ./.github/actions/make-action
with:
name: ${{ matrix.name }}
mode: ${{ matrix.mode }}
extension: ${{ matrix.extension }}
artifacts: 'true'
qa:
runs-on: ${{ matrix.os }}
needs: build
permissions:
contents: read
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
make: [test, test-compat, coverage]
include:
- os: ubuntu-latest
name: x86_64-linux-gnu
- os: macos-latest
name: arm64-apple-darwin
- os: windows-latest
name: x86_64-windows-msvc
extension: .exe
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-action
- uses: ./.github/actions/make-action
with:
name: ${{ matrix.name }}
mode: ${{ matrix.make == 'coverage' && 'coverage' || 'full' }}
make: ${{ matrix.make == 'coverage' && 'coverage-report' || matrix.make }}
extension: ${{ matrix.extension }}
artifacts: ${{ matrix.make == 'coverage' && 'true' || 'false' }}
artifacts_from: build
artifacts_from_mode: full
report:
runs-on: ubuntu-latest
needs: qa
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: true
- uses: ./.github/actions/setup-action
- uses: actions/download-artifact@v8
with:
pattern: coverage-report-*
path: artifact
- name: Coverage report
run: |
mkdir -p report
chmod +x artifact/coverage-report-x86_64-linux-gnu/coverage/phl
lcov --add-tracefile artifact/coverage-report-x86_64-linux-gnu/coverage/coverage.info \
--add-tracefile artifact/coverage-report-x86_64-windows-msvc/coverage/coverage.info \
--add-tracefile artifact/coverage-report-arm64-apple-darwin/coverage/coverage.info \
--ignore-errors format \
--output-file report/coverage.info
genhtml --quiet --include 'src/*'\
--output-directory report/html report/coverage.info
./artifact/coverage-report-x86_64-linux-gnu/coverage/phl \
build-aux/lcov_info_to_text.php --content=all\
report/coverage.info > report/coverage.md
./artifact/coverage-report-x86_64-linux-gnu/coverage/phl \
build-aux/lcov_to_markdown.php --output-dir=report \
report/coverage.info
echo "### Coverage" >> report/summary.md
echo "" >> report/summary.md
./artifact/coverage-report-x86_64-linux-gnu/coverage/phl \
build-aux/lcov_info_to_text.php --content=summary\
report/coverage.info >> report/summary.md
echo "" >> report/summary.md
echo "Details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> report/summary.md
- name: Coverage comment
if: github.event_name == 'pull_request'
run: |
echo "<details><summary>Code Coverage Report</summary>" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
cat report/coverage.md >> "$GITHUB_STEP_SUMMARY"
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
gh pr comment $PR_NUMBER --edit-last --create-if-none --body-file report/summary.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- uses: actions/upload-artifact@v7
with:
name: report-html
path: report/html
- name: Coverage history
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Assumes the 'coverage' branch already exists and that actions/checkout
# checked out with 'persist-credentials: true' (default) so we can push.
git fetch origin coverage
# Clean artifacts from local repo to avoid conflicts with git checkout
rm -f artifact/coverage-report-*/coverage/coverage.info
git checkout coverage
git pull --ff-only origin coverage || true
# Copy all contents of report/ to .
cp -rf report/* . || true
# Don't need the html/ directory in the repo
rm -rf html report || true
# git add markdown and info files in current dir and subdirs
find . -type f \( -name '*.info' -o -name '*.md' \) -print0 | xargs -0 -r git add || true
- name: Coverage push
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
set -euo pipefail
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "Coverage: ${GITHUB_SHA} (${GITHUB_RUN_ID})"
git push origin coverage
fi
- name: Restore workspace
if: always()
run: |
set -euo pipefail
echo "Restoring workspace to original commit: ${GITHUB_SHA}"
git fetch origin || true
git checkout --detach "${GITHUB_SHA}" || true
git reset --hard "${GITHUB_SHA}" || true