-
-
Notifications
You must be signed in to change notification settings - Fork 94
232 lines (187 loc) · 5.71 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
name: CI
on:
push:
branches-ignore:
- "dependabot/**"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
# Allows for matrix sub-jobs to fail without cancelling the rest
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, "3.10", 3.11, 3.12, 3.13]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Test Installation
run: |
pip install -r dev-requirements/build.txt
pip install .
pip uninstall -y hikari
pip install .[speedups]
pip uninstall -y hikari
- name: Run tests
run: |
pip install -r dev-requirements.txt
nox -s pytest
nox -s pytest-all-features -- --cov-append
python scripts/ci/normalize_coverage.py
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: .coverage.${{ matrix.os }}.${{ matrix.python-version }}
path: .coverage
retention-days: 1
if-no-files-found: error
include-hidden-files: true
upload-coverage:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Download coverage
uses: actions/download-artifact@v4
with:
path: coverages/
# Not specifying any name will lead to the download of all available artifacts
# Since artifacts v2, we can no longer upload multiple artifacts
# with the same name and have them re-download as if it were a directory.
# For this reason, we need to download all available artifacts, filter
# out for only coverage files and then place them in the root directory
# with the name of the artifact
- name: Extract individual coverage files
run: |
cd coverages
for coverage_dir in ./.coverage.*; do
mv "$coverage_dir/.coverage" "../$coverage_dir"
rmdir "$coverage_dir"
done
cd ..
- name: Combine coverage
run: |
pip install -r dev-requirements/coverage.txt
coverage combine
coverage xml
coverage report
- name: Upload coverage to codeclimate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: d40e64ea0ff74713f79365fea4378ab51a2141ad4fcf0fb118496bbf560d4192
with:
coverageLocations: .coverage.xml:coverage.py
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Check stubs
if: always()
run: |
pip install -r dev-requirements.txt
nox -s generate-stubs
if [ "$(git status --short)" ]; then
echo "Stubs were not updated accordingly to the changes. Please run 'nox -s generate-stubs' and commit the changes to fix this."
exit 1
fi
- name: Audit
if: always()
run: |
nox -s audit
- name: Mypy
if: always()
run: |
nox -s mypy
- name: Verify types
if: always()
run: |
nox -s verify-types
- name: Flake8
if: always()
run: |
nox -s flake8
# Temporary until we use ruff for linting too
- name: Ruff format check
if: always()
run: |
nox -s check-reformat-code
- name: Slotscheck
if: always()
run: |
nox -s slotscheck
- name: Codespell
if: always()
run: |
nox -s codespell
- name: Check trailing whitespaces
if: always()
run: |
nox -s check-trailing-whitespaces
twemoji:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Test twemoji mapping
run: |
pip install -r dev-requirements.txt
nox -s twemoji-test
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
# NOTE: This should be kept up to date with .readthedocs.yaml
python-version: 3.11
- name: Build documentation
run: |
pip install -r dev-requirements.txt
nox -s mkdocs
- name: Upload artifacts
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: docs
path: public/docs
retention-days: 2
if-no-files-found: error
# Allows us to add this as a required check in Github branch rules, as all the other jobs are subject to change
ci-done:
needs: [upload-coverage, linting, twemoji, docs]
if: always() && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Set status based on required jobs
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
for result in $RESULTS; do
if [ "$result" != "success" ]; then
exit 1
fi
done