forked from randovania/randovania
247 lines (202 loc) · 7.45 KB
/
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: Python Package
on:
pull_request:
push:
branches:
- main
- stable
tags:
- 'v*.*.*'
jobs:
pytest:
strategy:
fail-fast: false
matrix:
include:
- os: 'ubuntu-latest'
python: '3.10'
executable: false
name: 'Linux'
- os: 'ubuntu-latest'
python: '3.10'
executable: true
name: 'Linux Executable'
- os: 'macos-latest'
python: '3.10'
executable: false
name: 'macOS'
- os: 'macos-latest'
python: '3.10'
executable: true
name: 'macOS Executable'
- os: 'windows-latest'
python: '3.10'
executable: false
name: 'Windows'
- os: 'windows-latest'
python: '3.10'
executable: true
name: 'Windows Executable'
- os: 'windows-latest'
python: '3.10'
executable: false
name: 'Resolver'
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
env:
# Due to https://github.com/eventlet/eventlet/issues/670, merely importing eventlet during a test running with
# pytest-async causes an error. Settings EVENTLET_IMPORT_VERSION_ONLY allows us to avoid that error, but this
# instead causes the flask_socketio to fail importing. Setting FLASK_RUN_FROM_CLI causes it to default to the
# threading async method instead, avoiding the issue
EVENTLET_IMPORT_VERSION_ONLY: ${{ fromJSON('[0, 1]')[matrix.os == 'macos-latest'] }}
FLASK_RUN_FROM_CLI: ${{ fromJSON('[0, 1]')[matrix.os == 'macos-latest'] }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Set up cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Apt
run: sudo apt-get -q update && sudo apt-get -y install libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libgl1-mesa-dev
if: matrix.os == 'ubuntu-latest'
- name: Install core Python packages
run: python -m pip install --upgrade -r requirements-setuptools.txt
- name: Install Python packages
run: python -m pip install -r requirements.txt -e . -e ".[gui]" -e ".[server]" -e ".[test]"
- name: Install extra Python packages (Linux)
run: python -m pip install -r requirements-xvfb.txt
if: matrix.os == 'ubuntu-latest'
- name: build whell
run: python setup.py bdist_wheel
- name: build sdist
run: python setup.py sdist
if: ${{ !matrix.executable && matrix.os == 'ubuntu-latest' }}
- name: run pytest (no resolver)
run: python -m pytest --cov randovania --cov-report=xml --skip-resolver-tests -n auto --durations=100
if: ${{ !matrix.executable && matrix.name != 'Resolver' }}
- name: run pytest (resolver)
run: python -m pytest --cov randovania --cov-report=xml --durations=100 -n auto test/resolver/test_resolver.py
if: ${{ matrix.name == 'Resolver' }}
- name: create executable
run: python -u tools/create_release.py
if: matrix.executable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRODUCTION: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/stable') }}
- name: executable check
run: dist/randovania/randovania --version
if: matrix.executable
- name: executable test
run: dist/randovania/randovania --pytest --skip-gui-tests --skip-echo-tool --skip-resolver-tests --durations=100 --ignore=test/server
if: matrix.executable
- name: codecov
uses: codecov/codecov-action@v3
if: ${{ !matrix.executable }}
with:
fail_ci_if_error: true
files: ./coverage.xml
- name: Upload artifacts
if: ${{ matrix.executable }}
uses: actions/upload-artifact@v3
with:
name: Randovania ${{ matrix.name }}
if-no-files-found: error
path: |
dist/randovania-*.zip
dist/randovania-*.tar.gz
dist/randovania-*.7z
- name: Upload binaries to release
uses: svenstaro/upload-release-action@2.3.0
if: ${{ matrix.executable && startsWith(github.ref, 'refs/tags/v') }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/randovania-*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
body: "Release executable"
- name: Publish distribution 📦 to PyPI
if: ${{ !matrix.executable && startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest' }}
run: |
python -m pip install twine
python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}
lint:
runs-on: 'windows-latest'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Set up cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-lint.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python packages
run: |
python -m pip install --upgrade -r requirements-setuptools.txt
python -m pip install -r requirements-lint.txt
- name: Test if requirements files are up to date
run: |
python tools/update_requirements.py --quiet
git diff --exit-code
discord_alert:
runs-on: 'ubuntu-latest'
needs: pytest
if: ${{ startsWith(github.ref, 'refs/heads/') }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Set up cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python packages
run: |
python -m pip install --upgrade -r requirements-setuptools.txt
python -m pip install -e . aiohttp -c requirements.txt
- name: Discord Notifications
run: python tools/post_discord_webhook.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}