-
Notifications
You must be signed in to change notification settings - Fork 8
210 lines (196 loc) · 8.85 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
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/[email protected]
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/[email protected]
secrets: inherit
ats:
name: ATS
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
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build
run: |
make test_env.build
- name: Bring containers up
run: |
make test_env.up
# 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: |
docker-compose exec shared codecovcli create-commit --token=${{ secrets.CODECOV_ORG_TOKEN }}
docker-compose exec shared codecovcli static-analysis --token=${{ secrets.STATIC_TOKEN }}
- name: Run Label Analysis
run: |
docker-compose exec shared 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: |
docker-compose exec shared 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
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build
run: |
make test_env.build
- name: Bring containers up
run: |
make test_env.up
- name: Run tests
run: |
make test_env.test
# Don't upload on forks for now.
- name: upload using codecovcli
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
docker-compose exec shared codecovcli upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
docker-compose exec shared codecovcli do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
- name: upload using codecovcli staging
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} || true
- name: upload using codecovcli qa
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_QA_URL }} upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_QA_URL }} do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
- name: upload using codecovcli public qa
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} || true
mutation:
name: Run Mutations
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build
run: |
make test_env.build
- name: Bring containers up
run: |
make test_env.up
- name: Run mutations
run: |
make test_env.mutation