-
-
Notifications
You must be signed in to change notification settings - Fork 74
216 lines (210 loc) · 7.61 KB
/
run-tox-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
name: Run Tox tests
on:
push:
branches:
- master
- releases/*
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-latest]
python-version: [
"3.9",
"3.10",
"3.11",
"3.12",
"3.13-dev", # Not yet released, so we need to use -dev to get the release candidate
"pypy-3.9",
]
include:
- os: macos-latest
python-version: "3.11"
exclude:
- os: windows-latest
python-version: 'pypy-3.9'
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install system library(linux)
if: runner.os == 'linux'
run: |
sudo apt-get update -q -y
sudo apt-get install -q -y libarchive-dev graphviz
- name: Download libarchive(Windows)
if: runner.os == 'Windows'
uses: carlosperate/download-file-action@v2
with:
file-url: "https://libarchive.org/downloads/libarchive-v3.5.3-win64.zip"
file-name: "libarchive-v3.5.3-win64.zip"
- name: Install libarchive(Windows)
if: runner.os == 'Windows'
run: |
$file = "libarchive-v3.5.3-win64.zip"
Expand-Archive -LiteralPath $file -DestinationPath $env:GITHUB_WORKSPACE
choco install graphviz
- name: Install dependencies
run: |
pip install -U pip tox wheel setuptools setuptools_scm[toml]
pip install tox-gh-actions coveralls coverage[toml]
- name: Test project with tox
if: runner.os != 'Windows'
run: |
tox
coverage xml -o cobertura.xml
env:
PYTEST_ADDOPTS: "--cov-config=pyproject.toml --cov --cov-append --benchmark-skip"
- name: Test project with tox (windows)
if: runner.os == 'Windows'
run: |
echo LIBARCHIVE="${env:LIBARCHIVE}"
tox
coverage xml -o cobertura.xml
env:
LIBARCHIVE: "${{ github.workspace }}\\libarchive\\bin\\archive.dll"
PYTEST_ADDOPTS: "--cov-config=pyproject.toml --cov --cov-append --benchmark-skip"
- name: Send coverage to coveralls
run: |
coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: py-${{ matrix.python-version }}-${{ matrix.os }}
- uses: actions/setup-java@v4
if: runner.os != 'Windows'
with:
distribution: 'temurin'
java-version: '21'
- name: Send coverage to codacy
if: runner.os != 'Windows'
run: |
curl -LS -o codacy-coverage-reporter-assembly.jar "$(curl -LSs https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | endswith(".jar"))) | .[0].browser_download_url')"
java -jar codacy-coverage-reporter-assembly.jar report -l Python -t ${PROJECT_TOKEN} --partial -r cobertura.xml
env:
PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
linter:
name: Linter checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: x64
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: v0.20.3
- name: Install dependencies
run: |
pip install -U pip tox wheel setuptools setuptools_scm[toml]
- name: Lint check
run: |
tox -e check | reviewdog -f flake8 -reporter=github-check -fail-level=error
env:
REVIEWDOG_TOKEN: ${{ secrets.REVIEWDOG_TOKEN }}
- name: MyPy check
run: |
tox -e mypy | reviewdog -f mypy -reporter=github-check -fail-level=error
env:
REVIEWDOG_TOKEN: ${{ secrets.REVIEWDOG_TOKEN }}
- name: docs build and link check
run: |
tox -e docs
test_slow_tests:
name: Test slow test cases
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: x64
- name: Install system library(linux)
run: |
sudo apt-get update -q -y
sudo apt-get install -q -y libarchive-dev
- name: Install dependencies
run: |
pip install -U pip setuptools setuptools_scm[toml]
pip install tox tox-gh-actions
- name: Test project with tox
run: tox
env:
PYTEST_ADDOPTS: "--no-cov --run-slow -k extract_high_compression_rate"
test_on_aarch64:
name: Test on ${{ matrix.arch }}
runs-on: ubuntu-22.04
strategy:
matrix:
arch: [aarch64]
distro: [ubuntu22.04]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Build & run test
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
githubToken: ${{ github.token }}
install: |
apt-get update -q -y
apt-get install -q -y p7zip-full python3 python3-pip python3-cffi build-essential gcc git libffi-dev python3-dev libarchive-dev
python3 -m pip install -U pip tox setuptools setuptools_scm[toml] coverage[toml] coveralls
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
python3 -c "import platform;print('Machine type:', platform.machine())"
python3 -m tox -e py310
coveralls
env: |
PYTEST_ADDOPTS: "--cov-config=pyproject.toml --cov --cov-append --benchmark-skip"
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: py-${{ matrix.python-version }}-${{ matrix.os }}
finish:
runs-on: ubuntu-latest
name: finish parallel build
needs: build
steps:
- name: Tell Coveralls that the parallel build is finished
run: |
curl -k \
https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN \
-d "payload[build_num]=$GITHUB_SHA&payload[status]=done"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Send coverage to codacy
run: |
curl -LS -o codacy-coverage-reporter-assembly.jar "$(curl -LSs https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | endswith(".jar"))) | .[0].browser_download_url')"
java -jar codacy-coverage-reporter-assembly.jar final -t ${PROJECT_TOKEN}
env:
PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}