-
Notifications
You must be signed in to change notification settings - Fork 8
310 lines (290 loc) · 11.3 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
name: Shared CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
lint:
name: Run Lint
uses: codecov/gha-workflows/.github/workflows/lint.yml@v1.0.0
build:
name: Build Shared
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Cache Requirements
id: cache-requirements
uses: actions/cache@v3
env:
cache-name: cache-requirements
with:
path: |
venv
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install requirements
if: ${{ steps.cache-requirements.outputs.cache-hit != 'true' }}
run: |
python -m venv venv
. venv/bin/activate
pip install setuptools_rust
pip install -r tests/requirements.txt
pip install -r requirements.txt
python setup.py develop
pip install codecov-cli
codecovstartup:
name: Codecov Startup
needs: build
uses: codecov/gha-workflows/.github/workflows/codecov-startup.yml@v1.2.0
secrets: inherit
ats:
name: ATS
needs: [build]
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Cache Requirements
id: cache-requirements
uses: actions/cache@v3
env:
cache-name: cache-requirements
with:
path: |
venv
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install reqs
run: |
. venv/bin/activate
pip install setuptools_rust
pip install -r tests/requirements.txt
pip install -r requirements.txt
python setup.py develop
pip install codecov-cli
# Need the action to support venv
# - name: Run ATS
# uses: codecov/codecov-ats@v0
# env:
# CODECOV_STATIC_TOKEN: ${{ secrets.STATIC_TOKEN }}
# CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
- name: Run Static Analysis
run: |
. venv/bin/activate
codecovcli static-analysis --token=${{ secrets.STATIC_TOKEN }}
- name: Run Label Analysis
run: |
. venv/bin/activate
codecovcli label-analysis --base-sha=$(git merge-base HEAD^ origin/main) --token=${{ secrets.STATIC_TOKEN }}
# Leaving the below for now. We have some super sus test names that defeat shell escaping. If we figure out a path forward we can change to the output mode and get these stats more effectively
# - name: Run Tests
# id: tests
# run: |
# . venv/bin/activate
# START=$(date +%s)
# TESTS_TO_RUN=$(jq -r '.ats_tests_to_run | map(@sh) | join(" ")' analysis.json --raw-output)
# TEST_COUNT=$(jq -r '.ats_tests_to_run | length' analysis.json)
# RUNNER_OPTIONS=$(jq -r '.runner_options | join(" ")' analysis.json | tr -d '\n')
# python -m pytest $(echo $RUNNER_OPTIONS) --cov=./ $(echo $TESTS_TO_RUN)
# END=$(date +%s)
# DURATION=$((END - START))
# echo duration=$DURATION>> "$GITHUB_OUTPUT"
# echo test_count=$TEST_COUNT>> "$GITHUB_OUTPUT"
- name: Upload Coverage
run: |
. venv/bin/activate
codecovcli upload-process --flag smart-labels --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
# - name: Run Skip Tests
# id: skip
# run: |
# . venv/bin/activate
# START=$(date +%s)
# TESTS_TO_RUN=$(jq -r '.ats_tests_to_skip | map(@sh) | join(" ")' analysis.json --raw-output)
# TEST_COUNT=$(jq -r '.ats_tests_to_skip | length' analysis.json)
# RUNNER_OPTIONS=$(jq -r '.runner_options | join(" ")' analysis.json | tr -d '\n')
# python -m pytest $(echo $RUNNER_OPTIONS) --cov=./ $(echo $TESTS_TO_RUN)
# END=$(date +%s)
# DURATION=$((END - START))
# echo duration=$DURATION>> "$GITHUB_OUTPUT"
# echo test_count=$TEST_COUNT>> "$GITHUB_OUTPUT"
#
#
# - name: Summary
# run: |
# echo "### ATS Summary" >> $GITHUB_STEP_SUMMARY
# echo "" >> $GITHUB_STEP_SUMMARY
# echo "- ${{ steps.tests.outputs.test_count }} tests ran in ${{ steps.tests.outputs.duration }} seconds" >> $GITHUB_STEP_SUMMARY
# echo "- ${{ steps.skip.outputs.test_count }} tests skipped" >> $GITHUB_STEP_SUMMARY
# echo "- Skipped tests took ${{ steps.skip.outputs.duration }} seconds" >> $GITHUB_STEP_SUMMARY
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4-beta
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
# with:
# flags: smart-labels
# plugins: pycoverage,compress-pycoverage
test:
name: Test
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Cache Requirements
id: cache-requirements
uses: actions/cache@v3
env:
cache-name: cache-requirements
with:
path: |
venv
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install reqs
run: |
. venv/bin/activate
pip install setuptools_rust
pip install -r tests/requirements.txt
pip install -r requirements.txt
python setup.py develop
pip install codecov-cli
- name: Run tests
run: |
. venv/bin/activate
python -m pytest --cov=./
# Don't upload on forks for now.
- name: upload using codecovcli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
. venv/bin/activate
codecovcli upload-process --flag python${{ matrix.python-version }} --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
- name: upload using codecovcli staging
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
. venv/bin/activate
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} upload-process --flag python${{ matrix.python-version }} --token ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
- name: upload using codecovcli qa
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
. venv/bin/activate
codecovcli -u ${{ secrets.CODECOV_QA_URL }} upload-process --flag python${{ matrix.python-version }} --token ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
- name: upload using codecovcli public qa
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
. venv/bin/activate
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} upload-process --flag python${{ matrix.python-version }} --token ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
mutation:
name: Run Mutations
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Cache Requirements
id: cache-requirements
uses: actions/cache@v3
env:
cache-name: cache-requirements
with:
path: |
venv
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}
- name: Install Requirements
run: |
make requirements.install
- name: Run mutations
run: |
make test_env.mutation
rust:
name: Rust Tests
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Run install cli
run: |
pip install codecov-cli
- name: Run rust tests
run: |
make test_env.rust_tests
## Don't upload on forks for now.
- name: upload using codecovcli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli upload-process --flag rust --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
- name: upload using codecovcli staging
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} upload-process --flag rust --token ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
- name: upload using codecovcli qa
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_QA_URL }} upload-process --flag rust --token ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
- name: upload using codecovcli public qa
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} upload-process --flag rust --token ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error