-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
306 lines (272 loc) · 9.74 KB
/
.gitlab-ci.yml
File metadata and controls
306 lines (272 loc) · 9.74 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
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
# Taken from https://gitlab.com/game-ci/unity3d-gitlab-ci-example/-/blob/main/.gitlab-ci.yml and modified to fit our needs.
# See https://game.ci/docs/gitlab/getting-started for more information.
# The MIT License (MIT)
# Copyright (c) 2017 Gabriel Le Breton
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
include: secrets.yml
stages:
- prepare
- build_and_test
# - deploy
# If you are looking for a place where to add 'UNITY_LICENSE_FILE' and other secrets, please visit your project's gitlab page:
# settings > CI/CD > Variables instead
variables:
BUILD_NAME: VR4VET
UNITY_ACTIVATION_FILE: ./unity3d.alf
IMAGE: unityci/editor # https://hub.docker.com/r/unityci/editor
IMAGE_VERSION: 1 # This will automatically use latest v1.x.x, see https://github.com/game-ci/docker/releases
UNITY_DIR: $CI_PROJECT_DIR # this needs to be an absolute path. Defaults to the root of your tree.
# You can expose this in Unity via Application.version
VERSION_NUMBER_VAR: $CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID-$CI_JOB_ID
VERSION_BUILD_VAR: $CI_PIPELINE_IID
image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION
get-unity-version:
image: alpine
stage: prepare
variables:
GIT_DEPTH: 1
script:
- echo UNITY_VERSION=$(cat $UNITY_DIR/ProjectSettings/ProjectVersion.txt | grep "m_EditorVersion:.*" | awk '{ print $2}') | tee prepare.env
artifacts:
reports:
dotenv: prepare.env
.unity_before_script: &unity_before_script
before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh
needs:
- job: get-unity-version
artifacts: true
.cache: &cache
cache:
key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM"
paths:
- $UNITY_DIR/Library/
.license: &license
rules:
- if: '$UNITY_LICENSE != null'
when: always
.unity_defaults: &unity_defaults
<<:
- *unity_before_script
- *cache
- *license
# run this job when you need to request a license
# you may need to follow activation steps from documentation
get-activation-file:
<<: *unity_before_script
rules:
- if: '$UNITY_LICENSE == null'
when: manual
stage: prepare
script:
- chmod +x ./ci/get_activation_file.sh && ./ci/get_activation_file.sh
artifacts:
paths:
- $UNITY_ACTIVATION_FILE
expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public
.test: &test
stage: build_and_test
<<: *unity_defaults
script:
- chmod +x ./ci/test.sh && ./ci/test.sh
artifacts:
when: always
expire_in: 2 weeks
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
# tags:
# - gitlab-org
# coverage: /<Linecoverage>(.*?)</Linecoverage>/
# Tests without junit reporting results in GitLab
# test-playmode:
# <<: *test
# variables:
# TEST_PLATFORM: playmode
# TESTING_TYPE: NUNIT
# test-editmode:
# <<: *test
# variables:
# TEST_PLATFORM: editmode
# TESTING_TYPE: NUNIT
# uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab
# We currently have the following issue which prevents it from working right now, but you can give
# a hand if you're interested in this feature:
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/151
.test-with-junit-reports: &test-with-junit-reports
stage: build_and_test
<<: *unity_defaults
script:
# This could be made faster by adding these packages to base image or running in a separate job (and step)
# We could use an image with these two depencencies only and only do the saxonb-xslt command on
# previous job's artifacts
- apt-get update && apt-get install -y default-jre libsaxonb-java
- chmod +x ./ci/test.sh && ./ci/test.sh
- saxonb-xslt -s $UNITY_DIR/$TEST_PLATFORM-results.xml -xsl $CI_PROJECT_DIR/ci/nunit-transforms/nunit3-junit.xslt >$UNITY_DIR/$TEST_PLATFORM-junit-results.xml
artifacts:
when: always
paths:
# This is exported to allow viewing the Coverage Report in detail if needed
- $UNITY_DIR/CodeCoverage/
reports:
junit:
- $UNITY_DIR/$TEST_PLATFORM-junit-results.xml
- "$UNITY_DIR/CodeCoverage/coverage.xml"
expire_in: 2 weeks
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
# tags:
# - gitlab-org
# coverage: /<Linecoverage>(.*?)</Linecoverage>/
test-playmode-with-junit-reports:
<<: *test-with-junit-reports
variables:
TEST_PLATFORM: playmode
TESTING_TYPE: JUNIT
test-editmode-with-junit-reports:
<<: *test-with-junit-reports
variables:
TEST_PLATFORM: editmode
TESTING_TYPE: JUNIT
generate-report:
stage: build_and_test
<<: *unity_defaults
script:
- chmod +x ./ci/test_coverage_report.sh && ./ci/test_coverage_report.sh
artifacts:
when: always
expire_in: 2 weeks
paths:
# This is exported to allow viewing the Coverage Report in detail if needed
- $UNITY_DIR/CodeCoverage/
needs:
- job: get-unity-version
artifacts: true
- job: test-playmode-with-junit-reports
artifacts: true
- job: test-editmode-with-junit-reports
artifacts: true
coverage: '/^Line coverage: \d+\.\d+%$/'
check-code-style:
stage: build_and_test
<<: *unity_defaults
script:
- wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
- dpkg -i packages-microsoft-prod.deb
- apt-get update
- apt-get install -y apt-transport-https
- apt-get install -y dotnet-sdk-7.0
- dotnet --version
- chmod +x ./ci/check_code_style.sh && ./ci/check_code_style.sh
artifacts:
when: always
expire_in: 2 weeks
paths:
- $UNITY_DIR/stylecop_log.txt
- $UNITY_DIR/stylecop_log_raw.txt
.build: &build
stage: build_and_test
<<: *unity_defaults
script:
- chmod +x ./ci/build.sh && ./ci/build.sh
artifacts:
paths:
- $UNITY_DIR/Builds/
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
# tags:
# - gitlab-org
# build-StandaloneLinux64:
# <<: *build
# variables:
# BUILD_TARGET: StandaloneLinux64
# build-StandaloneLinux64-il2cpp:
# <<: *build
# image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION
# variables:
# BUILD_TARGET: StandaloneLinux64
# SCRIPTING_BACKEND: IL2CPP
# build-StandaloneOSX:
# <<: *build
# image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION
# variables:
# BUILD_TARGET: StandaloneOSX
#Note: build target names changed in recent versions, use this for versions < 2017.2:
# build-StandaloneOSXUniversal:
# <<: *build
# variables:
# BUILD_TARGET: StandaloneOSXUniversal
build-StandaloneWindows64:
<<: *build
image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION
variables:
BUILD_TARGET: StandaloneWindows64
# # For webgl support, you need to set Compression Format to Disabled for v0.9. See https://github.com/game-ci/docker/issues/75
# build-WebGL:
# <<: *build
# image: $IMAGE:$UNITY_VERSION-webgl-$IMAGE_VERSION
# # Temporary workaround for https://github.com/game-ci/docker/releases/tag/v0.9 and webgl support in current project to prevent errors with missing ffmpeg
# before_script:
# - chmod +x ./ci/before_script.sh && ./ci/before_script.sh
# - apt-get update && apt-get install ffmpeg -y
# variables:
# BUILD_TARGET: WebGL
# build-android:
# <<: *build
# image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
# variables:
# BUILD_TARGET: Android
# BUILD_APP_BUNDLE: "false"
# build-android-il2cpp:
# <<: *build
# image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
# variables:
# BUILD_TARGET: Android
# BUILD_APP_BUNDLE: "false"
# SCRIPTING_BACKEND: IL2CPP
#deploy-android:
# stage: deploy
# image: ruby
# script:
# - cd $UNITY_DIR/Builds/Android
# - echo $GPC_TOKEN > gpc_token.json
# - gem install bundler
# - bundle install
# - fastlane supply --aab "${BUILD_NAME}.aab" --track internal --package_name com.youcompany.yourgame --json_key ./gpc_token.json
# needs: ["build-android"]
# build-ios-xcode:
# <<: *build
# image: $IMAGE:$UNITY_VERSION-ios-$IMAGE_VERSION
# variables:
# BUILD_TARGET: iOS
#build-and-deploy-ios:
# stage: deploy
# script:
# - cd $UNITY_DIR/Builds/iOS/$BUILD_NAME
# - pod install
# - fastlane ios beta
# tags:
# - ios
# - mac
# needs: ["build-ios-xcode"]
# pages:
# image: alpine:latest
# stage: deploy
# script:
# - mv "$UNITY_DIR/Builds/WebGL/${BUILD_NAME}" public
# artifacts:
# paths:
# - public
# only:
# - $CI_DEFAULT_BRANCH
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_TAG
when: never
- when: always