-
Notifications
You must be signed in to change notification settings - Fork 1
236 lines (216 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
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: ci
on:
push:
branches: [ "*" ]
schedule:
# Every day at 2:02.
- cron: '2 2 * * *'
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 20 # stop runaway job after 20 minutes
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ ubuntu-24.04, ubuntu-22.04, macos-14, macos-13, windows-2022 ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
env:
SHELLOUS_TRACE: all
BUILD_NAME: build (${{ matrix.os }},${{ matrix.python-version }})
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Install dependencies
run: |
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Lint
if: matrix.python-version != '3.13-dev'
run: |
ruff check --exit-zero .
pylint -v --fail-under 9.5 shellous
# Run pylint on tests directory with some checks disabled.
pylint --disable=C0116,C0103,R0903,W0212,C0302,C0415,R1735 --fail-under 9.1 tests
pyright || echo "Failed."
- name: Run Tests
run: |
if ! pytest -vv -s --durations=20 --log-cli-level=DEBUG | ./ci/annotate.awk -v step=Run_Tests; then
echo "::warning title=Run Tests Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --durations=20 --log-cli-level=DEBUG --last-failed
fi
- name: Run Code Coverage (Linux and MacOS)
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12') && matrix.python-version != '3.13-dev'
run: |
# Run coverage.
coverage run --source shellous -m pytest --log-cli-level=DEBUG
# Re-run with coverage for shellous/watcher.py
SHELLOUS_CHILDWATCHER_TYPE=default coverage run --source shellous -m pytest
# Re-run with coverage for shellous/watcher.py and ThreadStrategy.
SHELLOUS_CHILDWATCHER_TYPE=default SHELLOUS_THREADSTRATEGY=1 coverage run --source shellous -m pytest
- name: Upload Code Coverage
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12') && matrix.python-version != '3.13-dev'
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.SHELLOUS_CODECOV_TOKEN }}
verbose: true
- name: Run Tests with uvloop (Linux and MacOS)
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-13') && matrix.python-version != '3.13-dev'
run: |
pip3 install --require-hashes -r ./ci/requirements-uvloop.txt
# Ignore ResourceWarning with uvloop for now (TODO).
if ! pytest -vv -s --log-cli-level=DEBUG -W ignore::ResourceWarning; then
echo "::warning title=uvloop Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG -W ignore::ResourceWarning --last-failed
fi
env:
SHELLOUS_LOOP_TYPE: "uvloop"
- name: Run Tests with eager task factory
if: matrix.python-version == '3.12'
run: |
if ! pytest -vv -s --durations=20 --log-cli-level=DEBUG | ./ci/annotate.awk -v step=Run_Tests; then
echo "::warning title=Run Tests Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --durations=20 --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_LOOP_TYPE: "eager_task_factory"
- name: Run Tests with PidfdWatcher (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
if ! pytest -vv -s --log-cli-level=DEBUG; then
echo "::warning title=PidfdChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "pidfd"
- name: Run Tests with SafeChildWatcher (Linux and MacOS; Python 3.11 only)
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12') && matrix.python-version == '3.11'
run: |
if ! pytest -vv -s --log-cli-level=DEBUG; then
echo "::warning title=SafeChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "safe"
- name: Run Tests with DefaultChildWatcher (Linux and MacOS)
if: matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12'
run: |
if ! pytest -vv -s --log-cli-level=DEBUG | ./ci/annotate.awk -v step=DefaultChildWatcher; then
echo "::warning title=DefaultChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "default"
- name: Verify Types
if: matrix.python-version != '3.13-dev'
run: |
PYTHONPATH=. pyright --verifytypes shellous
- name: Format Check
run: |
black --check .
isort --check .
build-alpine:
runs-on: ubuntu-latest
timeout-minutes: 20 # stop runaway job after 20 minutes
strategy:
fail-fast: false
matrix:
image-tag: ['python:3.10-alpine', 'python:3.11-alpine', 'python:3.12-alpine']
container:
image: ${{ matrix.image-tag }}
env:
SHELLOUS_TRACE: all
BUILD_NAME: build (${{ matrix.image-tag }})
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install Dependencies
run: |
apk add --update gcc musl-dev python3-dev bash grep
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Run Tests
run: |
ps ; echo "alpine" `cat /etc/alpine-release` ; env
if ! pytest -v -s --log-cli-level=DEBUG; then
echo "::warning title=Run Tests Warning::Re-running failed tests in $BUILD_NAME"
pytest -v -s --log-cli-level=DEBUG --last-failed
fi
- name: Run Tests with DefaultChildWatcher
run: |
if ! pytest -v -s --log-cli-level=DEBUG; then
echo "::warning title=DefaultChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -v -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "default"
build-pypy:
runs-on: ubuntu-latest
timeout-minutes: 20 # stop runaway job after 20 minutes
strategy:
fail-fast: false
matrix:
pypy-version: [ 'pypy-3.9', 'pypy-3.10']
env:
SHELLOUS_TRACE: all
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python ${{ matrix.pypy-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.pypy-version }}
- name: Install dependencies
run: |
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Run Tests
run: |
pytest -vv -s --durations=20 --log-cli-level=DEBUG -W ignore::pytest.PytestUnraisableExceptionWarning
- name: Run Tests with DefaultChildWatcher
run: |
pytest -vv -s --log-cli-level=DEBUG -W ignore::pytest.PytestUnraisableExceptionWarning
env:
SHELLOUS_CHILDWATCHER_TYPE: "default"
build-13:
runs-on: ubuntu-latest
timeout-minutes: 20 # stop runaway job after 20 minutes
env:
SHELLOUS_TRACE: all
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python 3.13
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.13-dev'
- name: Install dependencies
run: |
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Run Tests
run: |
pytest -vv -s --log-cli-level=DEBUG