Repository navigation
289 lines (248 loc) · 9.07 KB
/
Copy pathcode-coverage.yml
File metadata and controls
289 lines (248 loc) · 9.07 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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
concurrency:
cancel-in-progress: true
group: coverage-${{ github.workflow }}-${{ github.ref }}
jobs:
chat-cli-tests:
name: Chat CLI tests
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
cache: pip
cache-dependency-path: ai-projects/chat-cli/requirements.txt
python-version: "3.12"
- name: Install deps
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pytest pytest-cov coverage[toml]
working-directory: ai-projects/chat-cli
- env:
COVERAGE_FILE: ../../.coverage.chat-cli
name: Run tests
run: |
pytest tests/ \
--cov=src \
--cov-branch \
--cov-report=xml:../../coverage-chat-cli.xml \
--cov-report=term \
-v
working-directory: ai-projects/chat-cli
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: coverage-chat-cli
path: |
.coverage.chat-cli
coverage-chat-cli.xml
timeout-minutes: 20
phi-tests:
continue-on-error: true
name: Phi tests (optional)
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
cache: pip
cache-dependency-path: AI/microsoft_phi-silica-3.6_v1/requirements.txt
python-version: "3.12"
- name: Install deps
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pytest pytest-cov coverage[toml]
working-directory: AI/microsoft_phi-silica-3.6_v1
- env:
COVERAGE_FILE: ../../.coverage.phi
name: Run tests (optional)
run: |
pytest tests/ \
--cov=. \
--cov-branch \
--cov-report=xml:../../coverage-phi.xml \
--cov-report=term \
-v
working-directory: AI/microsoft_phi-silica-3.6_v1
- if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
if-no-files-found: ignore
name: coverage-phi
path: |
.coverage.phi
coverage-phi.xml
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.12"
- name: Install coverage tooling
run: python -m pip install --upgrade pip coverage[toml]
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: coverage-artifacts
- name: Combine coverage
run: |
find coverage-artifacts -type f -name ".coverage*" -exec cp {} . \;
ls -la .coverage* || true
coverage combine .coverage.*
coverage xml -o coverage.xml
coverage report --fail-under=70
- name: Upload combined artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: coverage-combined
path: coverage.xml
- name: Upload to Codecov
uses: step-security/codecov-action@db5c3605ff3c9dc7f0b2791e6bea84a561bacab8
with:
fail_ci_if_error: false
files: coverage.xml
flags: unittests
name: codecov-combined
verbose: true
- if: github.event_name == 'pull_request'
name: Upsert PR coverage comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
const fs = require("fs");
const xml = fs.readFileSync("coverage.xml", "utf8");
const match = xml.match(/lines-valid="(\d+)".*lines-covered="(\d+)"/s);
if (!match) return;
const [, total, covered] = match;
const percent = ((Number(covered) / Number(total)) * 100).toFixed(2);
const marker = "<!-- coverage-comment -->";
const body = `${marker}
📊 **Code Coverage**: ${percent}% (${covered}/${total} lines)
Full report: [Codecov](https://codecov.io/github/${context.repo.owner}/${context.repo.repo})`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100
});
const existing = comments.find(c => c.user.type === "Bot" && c.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}
timeout-minutes: 20
quantum-ml-tests:
name: Quantum ML tests
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
cache: pip
cache-dependency-path: ai-projects/quantum-ml/requirements.txt
python-version: "3.12"
- name: Install deps
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pytest pytest-cov coverage[toml]
working-directory: ai-projects/quantum-ml
- env:
COVERAGE_FILE: ../../.coverage.quantum-ml
name: Run tests
run: |
pytest tests/ \
--cov=src \
--cov-branch \
--cov-report=xml:../../coverage-quantum-ml.xml \
--cov-report=term \
-v
working-directory: ai-projects/quantum-ml
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: coverage-quantum-ml
path: |
.coverage.quantum-ml
coverage-quantum-ml.xml
timeout-minutes: 20
root-tests:
name: Root tests (py${{ matrix.python-version }})
runs-on: ubuntu-latest
steps:
- name: Harden runner (audit outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
cache: pip
python-version: ${{ matrix.python-version }}
- name: Install deps
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
python -m pip install pytest pytest-cov coverage[toml]
- env:
COVERAGE_FILE: .coverage.root.py${{ matrix.python-version }}
name: Run tests with coverage data
run: |
pytest tests/ \
--cov=. \
--cov-branch \
--cov-report=xml:coverage-root-py${{ matrix.python-version }}.xml \
--cov-report=term \
-v
- name: Upload root coverage artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: coverage-root-py${{ matrix.python-version }}
path: |
.coverage.root.py${{ matrix.python-version }}
coverage-root-py${{ matrix.python-version }}.xml
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
timeout-minutes: 20
name: Code Coverage
on:
pull_request:
branches: [main, dev]
push:
branches: [main, dev]
workflow_dispatch:
permissions:
contents: read