-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
266 lines (254 loc) · 8.19 KB
/
.gitlab-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
image: docker:20.10.2
include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
stages:
- prepare
- build
- extra
default:
interruptible: true
variables:
GIT_DEPTH: "20"
GIT_FETCH_EXTRA_FLAGS: "--no-tags"
# CI environment settings
DOCKER_BUILDKIT: 1
DOCKER_DRIVER: "overlay2"
DOCKER_TLS_CERTDIR: "/certs"
DM_PROJECT_NAME: ColonialMarinesALPHA
# Build targets and deps
IMG_BUILD_CMBASE: "i386/ubuntu:bionic"
IMG_BUILD_PYTHON: "python:3.7-buster"
IMG_BUILD_NODE: "node:15-buster"
BYOND_MAJOR: "513"
BYOND_MINOR: "1542"
SPDMM_VERSION: "suite-1.7"
# Resource settings
BYOND_DOWNLOAD_URL: "https://secure.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip"
SPDMM_DOWNLOAD_URL: "https://github.com/SpaceManiac/SpacemanDMM/releases/download/${SPDMM_VERSION}"
# Targets
BYOND_INSTALL_DIR: "${CI_PROJECT_DIR}/ci-byond-inst"
# CM_CHANGELOG_DEPLOY_KEY: set to a valid SSH key as GitLab deploy key to push changelog to repo when on main branch
CM_CHANGELOG_DEPLOY_NAME: "ChangelogBot"
CM_CHANGELOG_DEPLOY_MAIL: "[email protected]"
.dind:
image: docker:20.10.2
services:
- docker:20.10.2-dind
before_script:
- "[ $CI_REGISTRY ] && command -v docker && echo $CI_JOB_TOKEN | docker login --username gitlab-ci-token --password-stdin $CI_REGISTRY"
# Prepare map files
build:map-templates:
stage: prepare
image: $IMG_BUILD_PYTHON
dependencies: []
script:
- python3 tools/ci/template_dm_generator.py
artifacts:
name: 'map_template'
paths:
- 'maps/_basemap.dm'
# TGUI Interface
build:tgui:
stage: prepare
image: $IMG_BUILD_NODE
dependencies: []
cache:
key: "tgui-deps"
paths:
- 'tgui/.yarn/cache'
variables:
CACHE_FALLBACK_KEY: "tgui-deps"
script:
- chmod u+x tgui/bin/tgui
- tgui/bin/tgui
artifacts:
name: 'tgui_bundle'
paths:
- 'tgui/public/'
expose_as: 'TGUI Bundles'
expire_in: '7 days'
# Updated changelog for inclusion in game build if on main branch
# TODO Add support for auto-detecting MR changelog and including it, for Testmerges
report:changelog:
stage: prepare
image: $IMG_BUILD_PYTHON
dependencies: []
script:
- pip install python-dateutil requests beautifulsoup4 pyyaml
- GITLAB_CHANGELOG_PID=${CI_PROJECT_ID} python3 tools/changelogs/generate_changelogs.py dev html/changelogs/
- python3 tools/GenerateChangelog/ss13_genchangelog.py html/changelog.html html/changelogs/
artifacts:
name: 'changelogs'
paths:
- 'html/changelog.html'
- 'html/changelog.css'
- 'html/changelogs/.all_changelog.yml'
- "${CI_PROJECT_ID}.txt"
expose_as: 'Changelogs'
expire_in: '3 days'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# Run DreamMaker to build game release build
build:dm:
stage: build
image: $IMG_BUILD_CMBASE
dependencies:
- 'build:tgui'
- 'report:changelog'
cache:
key: "byond-${BYOND_MAJOR}.${BYOND_MINOR}"
paths:
- byond.zip
script:
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y build-essential libssl-dev unzip wget
- "[ -f byond.zip ] || wget -O byond.zip $BYOND_DOWNLOAD_URL"
- mkdir -p $BYOND_INSTALL_DIR
- unzip byond.zip -d $BYOND_INSTALL_DIR && cd ${BYOND_INSTALL_DIR}/byond
- make here
- source bin/byondsetup
- cd $CI_PROJECT_DIR
- cp tools/ci/_compile_options_release.dm code/_compile_options.dm
- DreamMaker ${DM_PROJECT_NAME}.dme
artifacts:
name: 'binaries'
paths:
- "${DM_PROJECT_NAME}.dmb"
- "${DM_PROJECT_NAME}.rsc"
expose_as: 'DM Binaries'
expire_in: '14 days'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# Run DreamMaker to build game in test mode
build:dm-testing:
stage: build
image: $IMG_BUILD_CMBASE
dependencies:
- 'build:tgui'
- 'build:map-templates'
cache:
key: "byond-${BYOND_MAJOR}.${BYOND_MINOR}"
paths:
- byond.zip
script:
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y build-essential libssl-dev unzip wget
- "[ -f byond.zip ] || wget -O byond.zip $BYOND_DOWNLOAD_URL"
- mkdir -p $BYOND_INSTALL_DIR
- unzip byond.zip -d $BYOND_INSTALL_DIR && cd ${BYOND_INSTALL_DIR}/byond
- make here
- source bin/byondsetup
- cd $CI_PROJECT_DIR
- cp tools/ci/_compile_options.dm code/_compile_options.dm
- DreamMaker ${DM_PROJECT_NAME}.dme
# Run SpacemanDMM static tests
tests:
stage: build
image: $IMG_BUILD_PYTHON
dependencies:
- 'build:map-templates'
cache:
key: "dreamchecker-${SPDMM_VERSION}"
paths:
- dreamchecker
script:
- cp tools/ci/_compile_options.dm code/_compile_options.dm
- find . -iname "*.json" -not -path "*/node_modules/*" -exec python3 ./tools/json_verifier.py {} \;
- "[ -f dreamchecker ] || wget -O dreamchecker ${SPDMM_DOWNLOAD_URL}/dreamchecker"
- chmod u+x dreamchecker
- ./dreamchecker --json
# Build and push deployment container
build:runner:
stage: extra
extends: .dind
dependencies:
- 'build:dm'
script:
- docker pull ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}:latest || docker pull ${CI_REGISTRY_IMAGE}/${CI_DEFAULT_BRANCH}:latest || true
- docker build
--platform=linux/386
--cache-from ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}:latest
--cache-from ${CI_REGISTRY_IMAGE}/${CI_DEFAULT_BRANCH}:latest
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg BYOND_BASE_IMAGE=${IMG_BUILD_CMBASE}
--build-arg BYOND_MAJOR
--build-arg BYOND_MINOR
--build-arg BYOND_DOWNLOAD_URL
--build-arg DM_PROJECT_NAME
--tag ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}:${CI_PIPELINE_ID}
--tag ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}:latest
--target cm-runner .
- docker push ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}:${CI_PIPELINE_ID}
- docker push ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}:latest || true
rules:
- if: '$CI_REGISTRY_IMAGE && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# Generate DM documentation
report:dmdoc:
stage: extra
image:
name: alpine/git
entrypoint: [""]
cache:
key: "dmdoc-${SPDMM_VERSION}"
paths:
- dmdoc-bin
script:
- "[ -f dmdoc-bin ] || wget -O dmdoc-bin ${SPDMM_DOWNLOAD_URL}/dmdoc"
- chmod u+x dmdoc-bin
- ./dmdoc-bin
artifacts:
name: ci_dmdoc
paths:
- 'dmdoc/'
expose_as: 'DM Documentation'
expire_in: '14 days'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
changes:
- "**/*.dm"
# Reports effective map changes on same branch, using dmm-tools to render full map file
report:map-changed-report:
stage: extra
image:
name: alpine/git
entrypoint: [""]
dependencies: []
cache:
key: "dmm-tools-${SPDMM_VERSION}"
paths:
- dmm-tools
script:
- CHANGED_MAP_FILES=`git diff-tree -r --diff-filter=d --name-only --no-commit-id ${CI_COMMIT_BEFORE_SHA}..${CI_COMMIT_SHA} maps/*.dmm`
- "[ -f dmm-tools ] || wget -O dmm-tools ${SPDMM_DOWNLOAD_URL}/dmm-tools"
- chmod u+x dmm-tools
- ./dmm-tools map-info --json ${CHANGED_MAP_FILES} > mapinfo.txt
- ./dmm-tools minimap -o maps-renders ${CHANGED_MAP_FILES}
artifacts:
name: ci_map_changes
paths:
- 'maps-renders/'
- 'mapinfo.txt'
expose_as: 'Maps Changes'
expire_in: '30 days'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BEFORE_SHA'
changes:
- "maps/**/*.dmm"
commit:changelog:
stage: extra
image:
name: alpine/git
entrypoint: [""]
interruptible: false
script:
- eval `ssh-agent -s`
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- git config --local user.email ${CM_CHANGELOG_DEPLOY_MAIL}
- git config --local user.name ${CM_CHANGELOG_DEPLOY_NAME}
- git config --local push.default simple
- git add html/changelog* ${CI_PROJECT_ID}.txt
- git commit -m "changelog-${CI_COMMIT_BRANCH}"
- git remote set-url origin "[email protected]:${CI_PROJECT_PATH}.git"
- GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git push -o ci.skip origin HEAD:${CI_COMMIT_BRANCH}
rules:
- if: '$SSH_PRIVATE_KEY && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
dependencies:
- report:changelog