-
-
Notifications
You must be signed in to change notification settings - Fork 9
228 lines (222 loc) · 7.46 KB
/
run-tests.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
name: Run tests
on:
pull_request:
types: [ opened, synchronize, reopened ]
push:
branches: [ main ]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
run-tests:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
version: ['3.9', '3.10', '3.11', '3.12', '3.13']
include:
- version: '3.9'
tox-env: py39,py39-mypy,py39-lint,bandit
- version: '3.10'
tox-env: py310,py310-mypy,py310-lint,bandit
- version: '3.11'
tox-env: py311,py311-mypy,py311-lint,bandit
- version: '3.12'
tox-env: py312,py312-mypy,py312-lint,format,bandit
- version: '3.13'
tox-env: py313,py313-mypy,py313-lint,bandit
- os: windows-latest
version: '3.13'
tox-env: py313,bandit
- os: macos-latest
version: '3.13'
tox-env: py313,bandit
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/bin/poetry
~/.local/share/pypoetry
key: ${{ runner.os }}-python-${{ matrix.version }}-poetry-${{ hashFiles('.github/workflows/run-tests.yml', 'pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true' && ! startsWith (matrix.os, 'windows')
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Poetry (Windows)
if: steps.cache-deps.outputs.cache-hit != 'true' && startsWith (matrix.os, 'windows')
shell: pwsh
run: |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Run tests
env:
TOX_PARALLEL_NO_SPINNER: 1
TOX_SHOW_OUTPUT: "True"
TOXENV: ${{ matrix.tox-env }}
run: |
tox run-parallel -p 4
mkdir coverage
mv .coverage.* "coverage/.coverage.py${{ matrix.version }}"
- name: Archive code coverage results
if: "startsWith (matrix.os, 'ubuntu')"
uses: actions/upload-artifact@v4
with:
name: code-coverage.py${{ matrix.version }}
path: coverage/.coverage.py*
include-hidden-files: true
if-no-files-found: error
run-pypy-tests:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
version: ['3.9', '3.10']
include:
- version: '3.9'
tox-env: pypy39
- version: '3.10'
tox-env: pypy310
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: pypy${{ matrix.version }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/bin/poetry
~/.local/share/pypoetry
key: ${{ runner.os }}-pypy-${{ matrix.version }}-poetry-${{ hashFiles('.github/workflows/run-tests.yml', 'pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Run tests
env:
TOX_PARALLEL_NO_SPINNER: 1
TOX_SHOW_OUTPUT: "True"
TOXENV: ${{ matrix.tox-env }}
run: |
tox run -- -n 2
mkdir coverage
mv .coverage.* "coverage/.coverage.pypy${{ matrix.version }}"
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage.pypy${{ matrix.version }}
path: coverage/.coverage.py*
include-hidden-files: true
if-no-files-found: error
min-deps-test:
# Attempt to run the TOX-ENV tests for the given OS and python
# VERSION with the minimal possible Basilisp dependencies
# versions.
#
# For dependencies to be eligible for minimum version testing,
# they should be declared in `pyproject.toml` as such in the
# following format
#
# <dependency-name> = "^..."
# <dependency-name> = ">=..."
# <dependency-name> = { version = "^..." ...
# <dependency-name> = { version = ">=..." ...
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
version: ['3.9']
tox-env: ['py39']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/bin/poetry
~/.local/share/pypoetry
key: min-deps-test-${{ runner.os }}-python-${{ matrix.version }}-poetry-${{ hashFiles('.github/workflows/run-tests.yml', 'pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Run minimum deps test
env:
TOX_PARALLEL_NO_SPINNER: 1
TOX_SHOW_OUTPUT: "True"
TOXENV: ${{ matrix.tox-env }}
run: |
poetry lock
DEPENDENCY_REGEX="$(poetry show -T --without=dev | awk '{print $1}' | paste -s -d '|' -)"
[[ -z "$DEPENDENCY_REGEX" ]] && { echo "Error: can't source dependencies" ; exit 1; }
echo ::deps $DEPENDENCY_REGEX
sed -i -E 's/('$DEPENDENCY_REGEX')( = )(|\{ version = )"(\^|>=)([0-9])/\1\2\3"==\5/' pyproject.toml
git diff
tox run-parallel -p 2
report-coverage:
runs-on: ubuntu-latest
needs:
- run-tests
- run-pypy-tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/share/pypoetry
key: ${{ runner.os }}-python-coverage-poetry-${{ hashFiles('pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Download code coverage
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Combine Coverage files from all supported Python versions
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: tox run -v -e coverage
- name: Report Combined Coverage
uses: coverallsapp/github-action@v2
with:
file: coverage.xml