forked from gcovr/gcovr
-
Notifications
You must be signed in to change notification settings - Fork 0
276 lines (237 loc) · 8.63 KB
/
CI.yml
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run GCOVR CI
on:
workflow_dispatch: # For manual triggering
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
milestone-check:
runs-on: ubuntu-22.04
continue-on-error: true
env:
PR_MILESTONE: "${{ github.event.pull_request.milestone.number }}"
steps:
- uses: actions/checkout@v4
- name: Check if PR is assigned to a milestone
if: ${{ github.event_name == 'pull_request' }}
run: |
if [ -z "$PR_MILESTONE" ]; then
echo 'No milestone selected for PR'
exit 1
fi
exit 0
changelog-check:
runs-on: ubuntu-22.04
env:
PR_BODY: "${{ github.event.pull_request.body }}"
CHANGELOG_ISSUE: ":issue:`${{ github.event.pull_request.number }}`"
steps:
- uses: actions/checkout@v4
- name: Check if PR is mentioned in changelog
if: ${{ always() }}
run: |
if [ -z "${{ github.event.pull_request.number }}" ]; then
echo 'No PR defined'
else
if grep -qE '^\[no changelog\]' <<<"$PR_BODY"; then
echo 'Marker "[no changelog]" found in PR body'
if [ "$(grep -F "$CHANGELOG_ISSUE" CHANGELOG.rst)" != "" ]; then
echo "ERROR: $CHANGELOG_ISSUE found in CHANGELOG.rst."
exit 1
else
echo "OK: $CHANGELOG_ISSUE not found in CHANGELOG.rst"
fi
else
echo 'Marker "[no changelog]" not found in PR body'
if [ "$(grep -F "$CHANGELOG_ISSUE" CHANGELOG.rst)" == "" ]; then
echo "ERROR: $CHANGELOG_ISSUE not found in CHANGELOG.rst."
exit 1
else
echo "OK: $CHANGELOG_ISSUE found in CHANGELOG.rst"
fi
fi
fi
exit 0
spell-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install spellchecker
run:
npm install -g cspell@latest
- name: Run spellchecker
run: |
cspell
host:
needs: [milestone-check, changelog-check, spell-check]
uses: ./.github/workflows/gcovr-ci-job.yml
with:
os: ${{ matrix.os }}
gcc: ${{ matrix.gcc }}
python-version: ${{ matrix.python-version }}
upload-dist: ${{ matrix.upload-dist || false }} # Explicit set to false if not set
upload-app: ${{ matrix.upload-app || false }} # Explicit set to false if not set
upload-release-notes: ${{ matrix.upload-release-notes || false }} # Explicit set to false if not set
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# Testing strategy
# ----------------
#
# We have different axes of the testing matrix:
#
# OS: Linux, Windows
# Compiler: GCC-5 to GCC-14, Clang-10 to CLANG-15
# Python: 3.8 -- 3.12, pypy3
#
# Instead of testing all combinations, we try to achieve full coverage
# across each axis. The main test matrix just represents the Python axis on
# Linux. The OS=Windows and Compiler axis are added manually.
#
# Some cases (Clang compiler) are handled via the Docker-tests.
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
gcc: [gcc-8]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8']
include:
# Test additional compilers with Linux.
# Note that all compiler versions are also handled via Docker.
- os: ubuntu-20.04
gcc: gcc-9
python-version: '3.9'
- os: ubuntu-22.04
gcc: gcc-11
python-version: '3.12'
upload-dist: true
upload-app: true
upload-release-notes: true
# Test minimum and maximum Python version on Windows.
- os: windows-2019
gcc: gcc
python-version: '3.8'
- os: windows-2019
gcc: gcc
python-version: '3.12'
upload-app: true
# Test minimum and maximum Python version on Mac OS.
- os: macos-12
gcc: gcc
python-version: '3.12'
- os: macos-13
gcc: gcc
python-version: '3.12'
upload-app: true
- os: macos-14
gcc: gcc
python-version: '3.9'
- os: macos-14
gcc: gcc-13
python-version: '3.12'
upload-app: true
docker:
needs: [milestone-check, changelog-check, spell-check]
uses: ./.github/workflows/gcovr-ci-job.yml
with:
container: true
gcc: ${{ matrix.gcc }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
strategy:
fail-fast: false
matrix:
gcc: [gcc-5, gcc-6, gcc-8, gcc-9, gcc-10, gcc-11, gcc-12, gcc-13, gcc-14, clang-10, clang-13, clang-14, clang-15]
deployment:
needs: [host, docker]
runs-on: ubuntu-22.04
permissions:
contents: write
env:
FORCE_COLOR: "1"
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: "./.github/actions/setup-python"
with:
os: ubuntu-22.04
python-version: 3.12
# Need to prevent creation of an existing tag
- name: Fetch all tags
run: |
git fetch --force --tags --depth=1
- name: Create new tag
run: |
# Create the new tag and check if it needs to be pushed
# Get the version
GcovrVersion="$(sed -n 's/__version__.*"\(.*\)"/\1/ p' gcovr/version.py)"
echo "GCOVR_VERSION=$GcovrVersion" >> $GITHUB_ENV
# Set git user info
git config --global user.email "[email protected]"
git config --global user.name "gcovr authors"
# Try to create the tag and print the output. It's only pushed if it's a real release
git tag -a "$GcovrVersion" -m "$GcovrVersion ($(date -I))"
git tag --list -n "$GcovrVersion"
# Check if it is a new release
VersionPostfix="$(echo "$GcovrVersion" | sed -n 's/^[0-9]*\.[0-9]*// p')"
if [ -z "$VersionPostfix" ]; then
echo "TAG_NEEDS_TO_BE_PUSHED=true" >> $GITHUB_ENV
else
echo "TAG_NEEDS_TO_BE_PUSHED=false" >> $GITHUB_ENV
fi
- name: For a dry run, don't verify tags and documentation
if: ${{ env.TAG_NEEDS_TO_BE_PUSHED == 'false' }}
run: |
echo "EXTRA_CHECKLIST_ARGS=--no-verify-tags --no-verify-docs-next-version" >> $GITHUB_ENV
- name: Run release checklist
run: |
admin/release_checklist.sh $EXTRA_CHECKLIST_ARGS 7.2+main
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: build
pattern: app-*
merge-multiple: true
- name: List standalone applications
run: |
ls -al build
- name: Download distribution files
uses: actions/download-artifact@v4
with:
pattern: dist
- name: List distribution files
run: |
ls -al dist
- name: Download release notes
uses: actions/download-artifact@v4
with:
path: doc/build
pattern: release-notes
- name: Set release notes as job summary
run: |
cat doc/build/release_notes.md >> $GITHUB_STEP_SUMMARY
- name: Push new tag
if: ${{ (github.repository == 'gcovr/gcovr') && (github.event.ref == 'refs/heads/main') && env.TAG_NEEDS_TO_BE_PUSHED == 'true' }}
run: |
# Set git user info
git config --global user.email "[email protected]"
git config --global user.name "gcovr authors"
git push origin "refs/tags/$GCOVR_VERSION"
- name: Create release and upload build artifacts
if: ${{ (github.repository == 'gcovr/gcovr') && (github.event.ref == 'refs/heads/main') && (env.TAG_NEEDS_TO_BE_PUSHED == 'true') }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.GCOVR_VERSION }}
body_path: docs/build/release_notes.md
files: build/*
- name: Publish to PyPi
if: ${{ (github.repository == 'gcovr/gcovr') && (github.event.ref == 'refs/heads/main') && (env.TAG_NEEDS_TO_BE_PUSHED == 'true') }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m nox --session upload_wheel