generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
213 lines (187 loc) · 7.85 KB
/
gameci.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
# MIT License
#
# Copyright (c) 2022 anatawa12
# Copyright (c) 2022 bd_
#
# 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.
name: GameCI
on:
push:
branches: [dev, ci]
# This is a bit of a radioactive event; we need to be very careful with what permissions
# we assign this action, as we're allowing arbitrary code execution with the context of
# whatever permissions we assign.
pull_request_target: {}
workflow_dispatch: {}
workflow_call:
secrets:
UNITY_LICENSE:
required: true
# pull_request_target grants access to a privileged GITHUB_TOKEN by default, revoke this
permissions: {}
jobs:
build-and-test:
name: Unit tests
strategy:
matrix:
#unity_version: [ auto, 2022.3.5f1 ]
unity_version: [ 2019.4.31f1, 2022.3.6f1 ]
sdk: [ vrcsdk, standalone ]
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
steps:
- id: setup
name: Setup
env:
unity_version: ${{ matrix.unity_version }}
sdk: ${{ matrix.sdk }}
run: |
set -x
sudo apt-get install xmlstarlet -y
should_test=true
echo should_test=$should_test >> $GITHUB_OUTPUT
can_fail=false
if [ $sdk == standalone ]; then
can_fail=$should_test
fi
echo can_fail=$can_fail >> $GITHUB_OUTPUT
if $can_fail; then
check_name="Unsupported test result ($unity_version, $sdk)"
else
check_name="Test result ($unity_version, $sdk)"
fi
echo check_name=$check_name >> $GITHUB_OUTPUT
- uses: LouisBrunner/[email protected]
id: create_check
name: Create check
if: ${{ github.event_name == 'pull_request_target' && steps.setup.outputs.can_fail == 'true' }}
with:
token: ${{ github.token }}
name: ${{ steps.setup.outputs.check_name }}
status: in_progress
- uses: LouisBrunner/[email protected]
id: create_skipped_check
name: Create check (skipped)
if: ${{ github.event_name == 'pull_request_target' && steps.setup.outputs.should_test == 'false' }}
with:
token: ${{ github.token }}
name: ${{ steps.setup.outputs.check_name }}
conclusion: skipped
output: '{ "summary": "Skipped" }'
- uses: actions/checkout@v3
if: ${{ steps.setup.outputs.should_test == 'true' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- id: prepare-project
if: ${{ steps.setup.outputs.should_test == 'true' }}
name: Prepare project
run: |
mkdir .github/ProjectRoot/Packages/nadena.dev.ndmf -p
mv [^P]* .github/ProjectRoot/Packages/nadena.dev.ndmf
mv .github/ProjectRoot/* .
mv 'Packages/nadena.dev.ndmf/UnitTests~' 'Packages/nadena.dev.ndmf/UnitTests'
for i in packages-lock manifest vpm-manifest; do
if [ -e "$i-${{ matrix.unity_version }}.json" ]; then
mv "$i-${{ matrix.unity_version }}.json" Packages/$i.json -v
fi
done
- id: symlink-deps
if: ${{ steps.setup.outputs.should_test == 'true' && matrix.sdk != 'vrcsdk' }}
name: Symlink dependencies
run: |
cd Packages/nadena.dev.ndmf
ln -s 'Dependencies~' Dependencies
- uses: anatawa12/sh-actions/resolve-vpm-packages@master
name: Resolve VPM packages
if: ${{ matrix.sdk == 'vrcsdk' && steps.setup.outputs.should_test == 'true' }}
- if: ${{ steps.setup.outputs.should_test == 'true' }}
name: "Debug: List project contents"
run: |
ls -lR
ls -lR Packages/nadena*
- uses: actions/cache@v3
if: ${{ steps.setup.outputs.should_test == 'true' }}
with:
path: Library
key: Library-${{ matrix.unity_version }}-${{ matrix.sdk }}
restore-keys: Library-
- uses: game-ci/unity-test-runner@v3
id: gameci
continue-on-error: ${{ steps.setup.outputs.can_fail == 'true' }}
if: ${{ steps.setup.outputs.should_test == 'true' }}
env:
# meh, just a personal license...
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
testMode: EditMode
unityVersion: ${{ matrix.unity_version }}
githubToken: ${{ github.token }}
coverageOptions: generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+nadena.dev.*
customParameters: -nographics -assemblyNames nadena.dev.ndmf.UnitTests
checkName: ${{ steps.setup.outputs.check_name }}
# For our main "supported" platforms, we report the conclusion of gameci as-is. However, for standalone, we report
# neutral if it failed.
- id: determine_conclusion
name: Determine conclusion
if: ${{ steps.setup.outputs.should_test == 'true' }}
env:
unity_version: ${{ matrix.unity_version }}
sdk_platform: ${{ matrix.sdk }}
gameci_outcome: ${{ steps.gameci.outcome }}
can_fail: ${{ steps.setup.outputs.can_fail }}
run: |
set -x
outcome=$gameci_outcome
# Check whether any tests actually ran
test_count=$(
if ! cat ${{ steps.gameci.outputs.artifactsPath }}/editmode-results.xml | \
xmlstarlet sel -t -v "/test-run/@total"; then
echo 0
fi
)
if [ $test_count -eq 0 ] || [ x$test_count == x ]; then
outcome=failure
output="{ \"summary\": \"No tests ran\" }"
if ! $can_fail; then
exit 1
fi
else
output="{ \"summary\": \"Result: $outcome ($test_count tests)\" }"
fi
if [ "$outcome" == "failure" ] && $can_fail; then
outcome=neutral
fi
echo matrix_outcome=$outcome >> $GITHUB_OUTPUT
echo matrix_output=$output >> $GITHUB_OUTPUT
- uses: LouisBrunner/[email protected]
name: Set check conclusion
if: ${{ github.event_name == 'pull_request_target' && steps.setup.outputs.can_fail == 'true' }}
with:
token: ${{ github.token }}
check_id: ${{ steps.create_check.outputs.check_id }}
conclusion: ${{ steps.determine_conclusion.outputs.matrix_outcome }}
output: ${{ steps.determine_conclusion.outputs.matrix_output }}
- uses: actions/upload-artifact@v3
if: ${{ steps.setup.outputs.should_test == 'true' && matrix.sdk == 'vrcsdk' && matrix.unity_version == 'auto' }}
continue-on-error: true
with:
name: Coverage results ${{ matrix.unity_version }} ${{ matrix.sdk }}
path: ${{ steps.gameci.outputs.coveragePath }}