-
Notifications
You must be signed in to change notification settings - Fork 3
268 lines (214 loc) · 7.05 KB
/
code-quality.yaml
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
name: code quality
on:
pull_request:
branches:
- main
jobs:
linting:
runs-on: ubuntu-latest
env:
PYTHONPATH: .
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3
- name: setup python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: install python dependencies
id: pip
run: python -m pip install -e .[dev,docs]
- name: run ruff
id: ruff
run: python -m ruff grizzly/ grizzly_extras/ tests/ example/
- name: run mypy
id: mypy
run: python -m mypy grizzly/ grizzly_extras/ tests/ example/
- name: gevent poison check
id: gevent-poison
run: |
find grizzly_extras/ -type f -name '*.py' -exec grep -nHE '^\s?(import|from) grizzly\.' {} \;
find grizzly_extras/ -type f -name '*.py' -exec grep -nHE '^\s*(import|from) grizzly\.' {} \; | awk '/(import|from) grizzly\./ {exit 1}'
test-and-coverage:
name: "test-and-coverage / ${{ matrix.runs-on }} / python-${{ matrix.python-version }}"
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
runs-on: ['ubuntu-latest']
include:
- python-version: '3.11'
runs-on: windows-latest
env:
PYTHONPATH: .
steps:
- name: timezone
id: timezone
uses: szenius/[email protected]
with:
timezoneLinux: 'Europe/Stockholm'
timezoneWindows: 'W. Europe Standard Time'
- name: checkout
id: checkout
uses: actions/checkout@v3
- name: setup python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: install python dependencies
id: pip
run: python -m pip install -e .[dev,docs]
- name: pytest
id: pytest
run: python -m pytest --ignore=tests/e2e
- name: coverage (not windows)
if: runner.os != 'Windows'
id: coverage-not-windows
run: python -m coverage report --omit=**/*messagequeue*,**/mq/* --fail-under=90
- name: coverage (windows)
if: runner.os == 'Windows'
id: coverage-windows
run: python -m coverage report --omit=**/*messagequeue*,**/mq/* --fail-under=89
test-e2e:
name: 'e2e tests ${{ matrix.run_mode }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
run_mode: ['local', 'dist']
env:
E2E_RUN_MODE: "${{ matrix.run_mode }}"
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: setup environment
id: setup-environment
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo PYTHONPATH=$PWD >> $GITHUB_ENV
- name: install python dependencies
id: pip
run: python -m pip install -e .[dev]
- name: install docker-compose
id: install-docker-compose
if: matrix.run_mode == 'dist'
uses: KengoTODA/actions-setup-docker-compose@main
with:
version: '2.20.3'
- name: ssh agent
id: ssh-agent
run: |
ssh-agent -a /tmp/ssh_auth_sock
- name: 'pytest (e2e ${{ matrix.run_mode }})'
id: pytest-e2e
env:
SSH_AUTH_SOCK: /tmp/ssh_auth_sock
run: python -m pytest tests/e2e
pre-documentation-scripts:
name: 'documentation / script inventory'
runs-on: 'ubuntu-latest'
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3
- name: create script matrix
id: create-script-matrix
run: |
echo "matrix=$(ls -1 script/docs-* | awk 'BEGIN {printf "["} {printf "\""$0"\", "} END {print "]"}' | sed -r 's|", \]$|"\]|')" >> $GITHUB_OUTPUT
- name: validate script matrix
run: |
echo '${{ steps.create-script-matrix.outputs.matrix }}'
outputs:
matrix: ${{ steps.create-script-matrix.outputs.matrix }}
documentation-scripts:
name: "documentation / ${{ matrix.script }}"
runs-on: 'ubuntu-latest'
needs: pre-documentation-scripts
strategy:
fail-fast: false
matrix:
script: ${{ fromJson(needs.pre-documentation-scripts.outputs.matrix) }}
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3
- name: setup python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: install python dependencies
id: pip
run: python -m pip install -e .[docs]
- name: exists
run: test -e ${{ matrix.script }}
- name: executable
run: test -x ${{ matrix.script }}
- name: runnable
run: ./${{ matrix.script }}
documentation-build:
name: "documentation / build"
runs-on: 'ubuntu-latest'
needs: documentation-scripts
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3
- name: setup python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: setup node
id: setup-node
uses: actions/setup-node@v3
- name: install python dependencies
id: pip
run: python -m pip install -e .[docs]
- name: build
working-directory: ./docs/
run: |
git checkout -b v0.0.0
novella --site-dir "$PWD/_build" --base-url grizzly/ 2>&1 | awk '/WARNING/ && !/Image file.*referenced in.*not found/ {print $0; exit 1} /ERROR/ {print $0; exit 1} {print $0}'
- name: check for unresolved pydoc-markdown tags
working-directory: ./docs/_build
run: find . -type f -name '*.html' | xargs -- grep -nHE '\{\@.*\}' | awk 'BEGIN{rc=0} !/^$/ {rc=1; print} END{exit rc}'
- name: check for @TODO annotations
working-directory: ./docs/_build
run: find . -type f -name '*.html' | xargs -- grep -nHE '@TODO' | awk 'BEGIN{rc=0} !/^$/ {rc=1; print} END{exit rc}'
- name: check for unclosed code blocks
working-directory: ./docs/_build
run: for file in $(find . -type f -name '*.md'); do awk 'BEGIN{count=0} /```/ {count+=1} END{if (count % 2 != 0) { print FILENAME ", contains uneven number of code-block markers"; exit 1;}}' $file || break; done
- name: check code block format
working-directory: ./docs/_build
run: for file in $(find . -type f -name '*.md'); do awk 'BEGIN{count=0} /``` / {print FILENAME " " $0; count+=1} END{if (count > 0) { print FILENAME ", there should not be a space between code-block and language specification"; exit 1;}}' $file || break; done
release-quality:
name: releasable
runs-on: 'ubuntu-latest'
if: always()
needs:
- linting
- test-and-coverage
- test-e2e
- documentation-build
steps:
- uses: technote-space/workflow-conclusion-action@v3
- run: |
[[ "${{ env.WORKFLOW_CONCLUSION }}" == "success" ]] || exit 1