-
Notifications
You must be signed in to change notification settings - Fork 0
316 lines (268 loc) · 10.3 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# If you change the name, change the link on the README.md for the badge too
name: Tests
on:
push:
paths:
- sc2/**
- examples/**
- test/**
- docs_generate/**
- pyproject.toml
- poetry.lock
- README.md
- .github/workflows/ci.yml
pull_request:
branches:
- master
- develop
env:
# Docker image version, see https://hub.docker.com/r/burnysc2/python-sc2-docker/tags
# This version should always lack behind one version behind the docker-ci.yml because it is possible that it doesn't exist
VERSION_NUMBER: '1.0.0'
LATEST_PYTHON_VERSION: '3.10'
LATEST_SC2_VERSION: '4.10'
jobs:
run_pytest_tests:
# Run pytest tests on pickle files (pre-generated SC2 API observations)
name: Run pytest
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# Python 3.6 fails due to: https://www.python.org/dev/peps/pep-0563/
# If all type annotations were removed, this library should run in py3.6 and perhaps even 3.5
# Python 3.7 support has been dropped due to missing cached_property (new since Python 3.8) https://docs.python.org/3/library/functools.html#functools.cached_property
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
pip install poetry
- name: Make poetry use local .venv folder
run: poetry config virtualenvs.in-project true
- name: Set up cache
if: matrix.os != 'windows-latest'
uses: actions/cache@v3
with:
path: .venv
key: ${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry install
- name: Run yapf autoformat
if: matrix.os != 'windows-latest'
run: |
poetry run yapf --in-place $(git ls-files '*.py')
- name: Run pylint on sc2 folder
if: matrix.os != 'windows-latest'
run: |
poetry run pylint $(git ls-files '*.py' | grep -E 'sc2/.*')
- name: Run pylint on examples folder
if: matrix.os != 'windows-latest'
run: |
poetry run pylint $(git ls-files '*.py' | grep -E 'examples/.*')
- name: Run pytest
run: |
poetry run pytest test
# Run benchmarks
- name: Run benchmark benchmark_array_creation
run: |
poetry run pytest test/benchmark_array_creation.py
- name: Run benchmark benchmark_distance_two_points
run: |
poetry run pytest test/benchmark_distance_two_points.py
- name: Run benchmark benchmark_distances_cdist
run: |
poetry run pytest test/benchmark_distances_cdist.py
- name: Run benchmark benchmark_distances_points_to_point
run: |
poetry run pytest test/benchmark_distances_points_to_point.py
- name: Run benchmark benchmark_distances_units
run: |
poetry run pytest test/benchmark_distances_units.py
run_test_bots:
# Run test bots that download the SC2 linux client and run it
name: Run testbots linux
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
# Do not allow this test to cancel. Finish all jobs regardless of error
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10']
sc2-version: ['4.10']
env:
IMAGE_NAME: burnysc2/python-sc2:local
steps:
# Copy data from repository
- uses: actions/checkout@v2
- name: Print directories and files
run: |
sudo apt-get install tree
tree
- name: Load and build docker image
# Build docker image from Dockerfile using specific python and sc2 version
env:
BUILD_ARGS: --build-arg PYTHON_VERSION=${{ matrix.python-version }} --build-arg SC2_VERSION=${{ matrix.sc2-version }}
run: |
docker build -f test/Dockerfile -t $IMAGE_NAME $BUILD_ARGS .
- name: Run autotest_bot.py
# Run bot and list resulting files (replay file, stable_id.json)
run: |
docker run -i -d --name my_container $IMAGE_NAME
docker exec -i my_container bash -c "python test/travis_test_script.py test/autotest_bot.py"
docker exec -i my_container bash -c "tree"
docker rm -f my_container
- name: Run upgradestest_bot.py
run: |
docker run -i -d --name my_container $IMAGE_NAME
docker exec -i my_container bash -c "python test/travis_test_script.py test/upgradestest_bot.py"
docker exec -i my_container bash -c "tree"
docker rm -f my_container
- name: Run damagetest_bot.py
run: |
docker run -i -d --name my_container $IMAGE_NAME
docker exec -i my_container bash -c "python test/travis_test_script.py test/damagetest_bot.py"
docker exec -i my_container bash -c "tree"
docker rm -f my_container
- name: Run queries_test_bot.py
run: |
docker run -i -d --name my_container $IMAGE_NAME
docker exec -i my_container bash -c "python test/travis_test_script.py test/queries_test_bot.py"
docker exec -i my_container bash -c "tree"
docker rm -f my_container
run_example_bots:
# Run example bots against computer
name: Run example bots against computer
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
# Do not allow this test to cancel. Finish all jobs regardless of error
fail-fast: false
matrix:
os: [ubuntu-latest]
env:
IMAGE_NAME: burnysc2/python-sc2-docker:local
steps:
# Copy data from repository
- uses: actions/checkout@v2
- name: Print directories and files
run: |
sudo apt-get install tree
tree
- name: Load and build docker image
# Build docker image from Dockerfile using specific python and sc2 version
env:
BUILD_ARGS: --build-arg PYTHON_VERSION=${{ env.LATEST_PYTHON_VERSION }} --build-arg SC2_VERSION=${{ env.LATEST_SC2_VERSION }}
run: |
docker build -f test/Dockerfile -t $IMAGE_NAME $BUILD_ARGS --build-arg VERSION_NUMBER=${{ env.VERSION_NUMBER }} .
- name: Run example bots vs computer
run: |
docker run -i -d --name my_container $IMAGE_NAME
docker exec -i my_container bash -c "python test/run_example_bots_vs_computer.py"
docker exec -i my_container bash -c "tree"
docker rm -f my_container
# TODO Fix in main.py "run_multiple_games" or "a_run_multiple_games" or "a_run_multiple_games_nokill"
# run_bot_vs_bot:
# # Run bot vs bot
# name: Run example bots against each other
# runs-on: ${{ matrix.os }}
# timeout-minutes: 30
# strategy:
# # Do not allow this test to cancel. Finish all jobs regardless of error
# fail-fast: false
# matrix:
# os: [ubuntu-latest]
# python-version: ['3.10']
# sc2-version: ['4.10']
# steps:
# # Copy data from repository
# - uses: actions/checkout@v2
#
# - name: Print directories and files
# run: |
# sudo apt-get install tree
# tree
#
# - name: Load and build docker image
# # Build docker image from Dockerfile using python 3.8
# run: |
# docker build -t test_image -f test/Dockerfile --build-arg PYTHON_VERSION=${{ matrix.python-version }} --build-arg SC2_VERSION=${{ matrix.sc2-version }} --build-arg VERSION_NUMBER=$VERSION_NUMBER .
#
# - name: Run example bots vs each other
# run: |
# docker run -it -d --name my_container test_image
# docker exec -i my_container bash -c "python test/run_example_bots_vs_each_other.py"
# docker exec -i my_container bash -c "tree"
# docker rm -f my_container
release_to_github_pages:
name: GitHub Pages
runs-on: ubuntu-latest
timeout-minutes: 3
needs: [run_pytest_tests, run_test_bots, run_example_bots]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.LATEST_PYTHON_VERSION }}
- name: Install poetry
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#contexts
# https://github.com/readthedocs/readthedocs.org/issues/4912#issuecomment-1110189914
run: |
pip install poetry
poetry config virtualenvs.create false
- name: Install dependencies
run: |
poetry install
- name: Build docs from scratch
run: |
echo "<meta http-equiv=\"refresh\" content=\"0; url=./docs/index.html\" />" > index.html
mkdir -p docs
cd docs_generate
poetry run sphinx-build -a -E -b html . ../docs
- name: Remove files unrelated to docs
run: |
rm -rf data dockerfiles docs_generate examples sc2 test
rm poetry.lock
- name: Publish to Github Pages
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_BRANCH: develop # The branch the action should deploy from.
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: . # The folder the action should deploy.
release_to_pypi:
name: Pypi
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [run_pytest_tests, run_test_bots, run_example_bots]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.LATEST_PYTHON_VERSION }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.LATEST_PYTHON_VERSION }}
- name: Update dependencies
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#contexts
run: |
pip install poetry
- name: Build package
# Builds package to dist/* directory
run: |
poetry build
- name: Publish
# Publish package on pypi
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
continue-on-error: true
run: |
poetry publish --username ${{ secrets.pypi_username }} --password ${{ secrets.pypi_password }}