-
Notifications
You must be signed in to change notification settings - Fork 1
227 lines (191 loc) · 7.02 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
---
name: CI
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
- develop
- v*
jobs:
unit-tests:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
python:
- 3.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
exclude:
# macos-latest is now running on M1 macs
- runs-on: macos-latest
python: 3.8
- runs-on: macos-latest
python: 3.9
- runs-on: macos-latest
python: 3.10
name: "Unit tests • ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
runs-on: ${{ matrix.runs-on }}
if: >-
(github.event_name != 'pull_request'
|| (github.event_name == 'pull_request' && github.event.pull_request.merged != true))
steps:
- uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: 'x64'
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Prepare env
run: python -m pip install -U pytest-github-actions-annotate-failures wheel build
- name: Build and install package
run: python -m pip install -e .[test]
- name: Run Python tests
run: python -m pytest -v --cov=cmake_pc_hooks --cov-report=xml --cov-report=term-missing --cov-branch
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Save coverage report
if: matrix.python == '3.11' && runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage.xml
retention-days: 1
system-tests:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
python:
- 3.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
exclude:
# macos-latest is now running on M1 macs
- runs-on: macos-latest
python: 3.8
- runs-on: macos-latest
python: 3.9
- runs-on: macos-latest
python: 3.10
name: "System tests ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
runs-on: ${{ matrix.runs-on }}
needs: unit-tests
if: >-
(github.event_name != 'pull_request'
|| (github.event_name == 'pull_request' && github.event.pull_request.merged != true))
steps:
- uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Enable Developer Command Prompt
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: 'x64'
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Prepare env
run: python -m pip install -U pytest-github-actions-annotate-failures wheel build
- name: Prepare env (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y clang clang-tidy cppcheck iwyu
python -m pip install pytest-github-actions-annotate-failures pre-commit cpplint lizard
- name: Prepare env (Mac OS)
if: runner.os == 'macOS'
run: |
brew install llvm cppcheck cpplint include-what-you-use pre-commit gnu-sed lizard-analyzer
ln -s "$(brew --prefix llvm)/bin/clang-tidy" /usr/local/bin/clang-tidy
# yamllint disable rule:line-length
- name: Prepare env (Windows)
if: runner.os == 'Windows'
run: |
choco install -y llvm cppcheck ninja
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Write-Output 'Import-Module "${ENV:ChocolateyInstall}\helpers\chocolateyProfile.psm1"' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Update-SessionEnvironment' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output '$id = vswhere -property instanceId' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"' `
| Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Enter-VsDevShell -InstanceId $id' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Set-Location -Path "${ENV:GITHUB_WORKSPACE}"' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Get-Content -Path $PROFILE
. $PROFILE
Get-Location
Write-Output "CMAKE_PREFIX_PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
python -m pip install pre-commit cpplint lizard
Get-Command @("python", "clang-format", "clang-tidy", "cppcheck", "cpplint", "lizard", "pre-commit")
- name: Build and install package
run: python -m pip install -e .[test]
- name: Run test (Unix)
if: runner.os != 'Windows'
env:
LOGLEVEL: DEBUG
run: ./tests/run_tests.sh
- name: Run test (Windows)
if: runner.os == 'Windows'
env:
CC: cl
CXX: cl
LOGLEVEL: DEBUG
run: ./tests/run_tests.ps1
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch coverage report
uses: actions/download-artifact@v3
with:
name: coverage
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
codacy:
name: Codacy coverage
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Fetch coverage report
uses: actions/download-artifact@v3
with:
name: coverage
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
finish:
needs: [unit-tests, system-tests, sonarcloud, codacy]
runs-on: ubuntu-latest
name: Finish CI checks
steps:
- name: All tests pass
run: echo 'OK'