-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (164 loc) · 4.91 KB
/
lint_test.yml
File metadata and controls
205 lines (164 loc) · 4.91 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
name: Lint and Test codebase
on:
push:
branches:
# We don't run this on any other branches because we assume that
# pull requests will be opened for them:
- main
paths:
- '.github/workflows/**'
- 'library/**'
- 'tests/**'
pull_request:
types:
- opened
- synchronize
- ready_for_review
- reopened
paths:
- '.github/workflows/**'
- 'library/**'
- 'tests/**'
env:
# This is ordered from lowlevel to toplevel, such that any subpackages
# that depend on other subpackages are installed last (so that it isn't
# installed from PyPI).
subpackages: 'gateway rest models cache interactions bot'
jobs:
import:
# This job is a very quick sanity check: if we can't import all
# subpackages (usually thanks to syntax errors) we shouldn't run the rest.
name: Import the library
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install Flit
run: pip install flit
- name: Install all subpackages
run: |
cd library/
for subpackage in ${{ env.subpackages }}; do
cd wumpy-$subpackage/
flit install --extras all --pth-file
cd ..
done
cd ..
- name: Import subpackages
run: |
for subpackage in ${{ env.subpackages }}; do
python -c "import wumpy.$subpackage"
done
flake8:
name: Lint with flake8
runs-on: ubuntu-latest
needs: import
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install Flake8
run: pip install flake8
- name: Lint codebase with Flake8
run: flake8 library/
isort:
name: Verify import order
runs-on: ubuntu-latest
needs: import
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install Isort
run: pip install isort
- name: Run isort on codebase
run: isort . --check-only
pyright:
name: Verify static types
runs-on: ubuntu-latest
# Isort is exluded here because the import order being wrong doesn't mean
# that this will fail (flake8 complains about missing imports though).
needs: [import, flake8]
strategy:
# If one of the subpackages fail this step, we want to continue running
# the rest as to not mask errors.
fail-fast: false
matrix:
subpackage:
- cache
- bot
- gateway
- interactions
- models
- rest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Attempt to access cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
# The subpackage isn't included here because it should be shared
key: 'pyright-v3.7'
- name: Install Pyright and Flit
run: pip install pyright flit
- name: Install all subpackages
run: |
cd library/
for subpackage in ${{ env.subpackages }}; do
cd wumpy-$subpackage/
flit install --extras all --pth-file
cd ..
done
cd ..
- name: Verify wumpy-${{ matrix.subpackage }} types
run: pyright --verifytypes wumpy/${{ matrix.subpackage }}/
pytest:
name: Run unit tests
runs-on: ubuntu-latest
needs: [import, flake8, isort]
strategy:
# If one of the Python versions fail we still want to continue testing
# the rest if possible.
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Pytest and flit
run: pip install pytest flit
- name: Install wumpy-testing utility
run: pip install git+https://github.com/wumpyproject/wumpy-testing
# If we're unsuccessful in installing wumpy-testing because it is
# currently broken or similar we can still run all other tests because
# it is an optional dependency.
continue-on-error: true
- name: Install all subpackages
run: |
cd library/
for subpackage in ${{ env.subpackages }}; do
cd wumpy-$subpackage/
flit install --extras all --pth-file
cd ..
done
cd ..
- name: Run pytest tests
run: pytest tests/