-
Notifications
You must be signed in to change notification settings - Fork 183
189 lines (164 loc) · 6.04 KB
/
docker-ci.yml
File metadata and controls
189 lines (164 loc) · 6.04 KB
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
name: Build and push Docker image
# Only run if Dockerfile or docker-ci.yml changed
on:
push:
paths:
- dockerfiles/**
- uv.lock
- pyproject.toml
- .github/workflows/docker-ci.yml
pull_request:
branches:
- master
- develop
env:
VERSION_NUMBER: "1.0.7"
LATEST_PYTHON_VERSION: "3.14"
LATEST_SC2_VERSION: "4.10"
EXPERIMENTAL_PYTHON_VERSION: "3.15"
jobs:
download_sc2_maps:
name: Download and cache sc2 maps
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Cache sc2 maps
uses: actions/cache@v4
id: cache-sc2-maps
with:
path: |
dockerfiles/maps
key: ${{ runner.os }}-maps-${{ hashFiles('dockerfiles/maps/**') }}
restore-keys: |
${{ runner.os }}-maps-
- name: Download sc2 maps
run: sh dockerfiles/download_maps.sh
if: steps.cache-sc2-maps.outputs.cache-hit != 'true'
run_test_docker_image:
name: Run test_docker_image.sh
needs: [download_sc2_maps]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Cache sc2 maps
uses: actions/cache@v4
id: cache-sc2-maps
with:
path: |
dockerfiles/maps
key: ${{ runner.os }}-maps-${{ hashFiles('dockerfiles/maps/**') }}
restore-keys: |
${{ runner.os }}-maps-
- name: Download sc2 maps
run: sh dockerfiles/download_maps.sh
if: steps.cache-sc2-maps.outputs.cache-hit != 'true'
- name: Run shell script
env:
VERSION_NUMBER: ${{ env.VERSION_NUMBER }}
PYTHON_VERSION: ${{ env.LATEST_PYTHON_VERSION }}
SC2_VERSION: ${{ env.LATEST_SC2_VERSION }}
run: sh dockerfiles/test_docker_image.sh
run_test_new_python_version:
name: Run test_new_python_candidate.sh
needs: [download_sc2_maps]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Cache sc2 maps
uses: actions/cache@v4
id: cache-sc2-maps
with:
path: |
dockerfiles/maps
key: ${{ runner.os }}-maps-${{ hashFiles('dockerfiles/maps/**') }}
restore-keys: |
${{ runner.os }}-maps-
- name: Download sc2 maps
run: sh dockerfiles/download_maps.sh
if: steps.cache-sc2-maps.outputs.cache-hit != 'true'
- name: Run shell script
continue-on-error: true
env:
VERSION_NUMBER: ${{ env.VERSION_NUMBER }}
PYTHON_VERSION: ${{ env.EXPERIMENTAL_PYTHON_VERSION }}
SC2_VERSION: ${{ env.LATEST_SC2_VERSION }}
run: sh dockerfiles/test_new_python_candidate.sh
docker_build:
name: Build docker image
needs: [download_sc2_maps]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
sc2-version: ["4.10"]
env:
IMAGE_NAME: burnysc2/python-sc2-docker:py_${{ matrix.python-version }}-sc2_${{ matrix.sc2-version }}
BUILD_ARGS: --build-arg PYTHON_VERSION=${{ matrix.python-version }} --build-arg SC2_VERSION=${{ matrix.sc2-version }}
steps:
- uses: actions/checkout@v3
- name: Cache sc2 maps
uses: actions/cache@v4
id: cache-sc2-maps
with:
path: |
dockerfiles/maps
key: ${{ runner.os }}-maps-${{ hashFiles('dockerfiles/maps/**') }}
restore-keys: |
${{ runner.os }}-maps-
- name: Download sc2 maps
run: sh dockerfiles/download_maps.sh
if: steps.cache-sc2-maps.outputs.cache-hit != 'true'
- name: Build docker image
run: docker build -f dockerfiles/Dockerfile -t $IMAGE_NAME-v$VERSION_NUMBER $BUILD_ARGS .
- name: Run test bots on image
run: |
echo "Start container, override the default entrypoint"
docker run -i -d \
--name test_container \
--env 'PYTHONPATH=/root/python-sc2/' \
--entrypoint /bin/bash \
$IMAGE_NAME-v$VERSION_NUMBER
echo "Install python-sc2"
docker exec -i test_container mkdir -p /root/python-sc2
docker cp pyproject.toml test_container:/root/python-sc2/
docker cp uv.lock test_container:/root/python-sc2/
docker cp sc2 test_container:/root/python-sc2/sc2
docker cp test test_container:/root/python-sc2/test
docker cp examples test_container:/root/python-sc2/examples
docker exec -i test_container bash -c "pip install uv \
&& cd python-sc2 && uv sync --frozen --no-cache --no-install-project"
echo "Run various test bots"
docker exec -i test_container bash -c "cd python-sc2 && uv run python test/travis_test_script.py test/autotest_bot.py"
docker exec -i test_container bash -c "cd python-sc2 && uv run python test/run_example_bots_vs_computer.py"
- name: Login to DockerHub
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Upload docker image
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
run: docker push $IMAGE_NAME-v$VERSION_NUMBER
- name: Upload docker image as latest tag
if: github.ref == 'refs/heads/develop' && github.event_name == 'push' && matrix.python-version == env.LATEST_PYTHON_VERSION && matrix.sc2-version == env.LATEST_SC2_VERSION
run: |
docker tag $IMAGE_NAME-v$VERSION_NUMBER burnysc2/python-sc2-docker:latest
docker push burnysc2/python-sc2-docker:latest