-
Notifications
You must be signed in to change notification settings - Fork 1
206 lines (161 loc) · 5.47 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
name: CI
on:
workflow_dispatch:
push:
branches:
- master
- beta
- alpha
- '*.x'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 3
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.x
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: |
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
pipx run nox -s pylint
consistency:
if: ${{ !cancelled() && ! failure() }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.x
- name: Install copier
run: pipx install copier==9.3.1
- name: Verify template
run: pipx run nox -s template_build
- name: Test for consistency
run: |
echo "List inconsistent files:"
git status --porcelain
git diff --exit-code || ( \
echo "# :warning: Inconsistent files found" >> $GITHUB_STEP_SUMMARY && \
echo "The following files are inconsistent with the template:" >> $GITHUB_STEP_SUMMARY && \
git status --porcelain | while read file; do echo "- $file"; done >> $GITHUB_STEP_SUMMARY && \
echo "" >> $GITHUB_STEP_SUMMARY && \
echo "Please run 'copier copy -r HEAD -f . .' to fix them." >>$GITHUB_STEP_SUMMARY && \
exit 1 \
)
checks:
runs-on: ${{ matrix.runs-on }}
needs: [pre-commit]
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.12']
runs-on: [ubuntu-22.04, macos-14, windows-2022]
include:
- python-version: pypy-3.10
runs-on: ubuntu-22.04
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/pip
~/.cache/vcpkg
key: ${{ matrix.python-version }}-${{ matrix.runs-on }}-${{ hashFiles('vcpkg.json') }}
restore-keys: ${{ matrix.python-version }}-${{ matrix.runs-on }}-${{ hashFiles('vcpkg.json') }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: python -m pip install .[test] -v
- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20
- name: Upload coverage report
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6
check-docs:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/pip
~/.cache/vcpkg
key: docs-${{ hashFiles('vcpkg.json') }}
restore-keys: docs-${{ hashFiles('vcpkg.json') }}
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Checks the docs with warnings as errors
run: pipx run nox -s docs -- --check
- name: Checks the docs for broken links
run: pipx run nox -s docs -- --linkcheck
check-mkdocs-docs:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install copier
run: pipx install copier==9.3.1
- name: Apply mkdocs
run: pipx run nox -s template_build -- -d docs_type=mkdocs
- name: Checks the docs with warnings as errors
run: pipx run nox -s docs -- --check
pass:
if: always()
needs:
- checks
- check-docs
- check-mkdocs-docs
runs-on: ubuntu-22.04
timeout-minutes: 2
permissions:
pull-requests: write
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
- name: Approve pr if all jobs succeeded
if: contains(github.event.pull_request.labels.*.name, 'auto-approval')
uses: hmarr/auto-approve-action@v4