-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
146 lines (130 loc) · 4.2 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
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
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: unityci
UNITY_ACTIVATION_FILE: ./unity3d.alf
IMAGE: unityci/editor # https://hub.docker.com/r/unityci/editor
IMAGE_VERSION: 1 # latest unityci docker image
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
coverage: /<Linecoverage>(.*?)</Linecoverage>/
.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/$TEST_PLATFORM-coverage/
reports:
junit:
- $UNITY_DIR/$TEST_PLATFORM-junit-results.xml
- "$UNITY_DIR/$TEST_PLATFORM-coverage/coverage.xml"
expire_in: 2 weeks
coverage: /<Linecoverage>(.*?)</Linecoverage>/
test-playmode:
<<: *test-with-junit-reports
variables:
TEST_PLATFORM: playmode
TESTING_TYPE: JUNIT
test-editmode:
<<: *test-with-junit-reports
variables:
TEST_PLATFORM: editmode
TESTING_TYPE: JUNIT
.build: &build
stage: build_and_test
<<: *unity_defaults
script:
- chmod +x ./ci/build.sh && ./ci/build.sh
artifacts:
paths:
- $UNITY_DIR/Builds/
build-android:
<<: *build
image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
variables:
BUILD_TARGET: Android
BUILD_APP_BUNDLE: "false"
# 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"]