Skip to content

Commit 672fb9b

Browse files
committed
update test workflow
1 parent 1c2e088 commit 672fb9b

File tree

1 file changed

+59
-87
lines changed

1 file changed

+59
-87
lines changed

.github/workflows/unity-test.yml

Lines changed: 59 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Secrets
2-
# ULF_REPO: Git repository url contains ulf files. https://mob-sakai:{{token}}@github.com/mob-sakai/ulfs.git
2+
# UNITY_LICENSE:
33
name: unity-test
44

55
on:
@@ -15,113 +15,85 @@ on:
1515

1616
jobs:
1717
unity-test:
18+
runs-on: ubuntu-latest
1819
strategy:
1920
fail-fast: false
2021
matrix:
21-
unity:
22-
[
23-
"2018.4.25f1",
24-
"2019.4.10f1",
25-
"2020.1.0f1",
26-
"2020.1.1f1",
27-
"2020.1.2f1",
28-
"2020.1.3f1",
29-
"2020.1.4f1",
30-
"2020.1.5f1",
22+
unityVersion: [
23+
2018.4.30f1,
24+
2019.4.16f1,
25+
# 2020.1.16f1,
26+
2020.2.0f1,
3127
]
3228
env:
33-
RUN_UNITY: "xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath ."
34-
35-
runs-on: ubuntu-latest
36-
container:
37-
# Use Unity image from https://hub.docker.com/r/gableroux/unity3d/tags
38-
image: gableroux/unity3d:${{ matrix.unity }}
29+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
3930

4031
steps:
41-
# Activate Unity Editor
42-
- name: Activate Unity Editor
43-
id: activation
44-
run: |
45-
# Clone ulfs.
46-
apt-get update
47-
apt-get install software-properties-common -y
48-
apt-add-repository ppa:git-core/ppa -y
49-
apt-get update
50-
apt-get install git -y
51-
git clone --depth 1 ${ULF_REPO} .ulfs
52-
53-
# Activate with ulf.
54-
ULF_FILE=.ulfs/Unity_v${UNITY_VERSION}.ulf
55-
echo $ULF_FILE
56-
if [ -e ${ULF_FILE} ]; then
57-
/opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -manualLicenseFile ${ULF_FILE} \
58-
| grep -E 'LICENSE SYSTEM.*\w{32} != \w{32}' && FAILED=true
59-
else
60-
echo "::error:: ulf file '${ULF_FILE}' is not found."
61-
FAILED=true
62-
fi
63-
64-
# Activation failed.
65-
if [ $FAILED ]; then
66-
echo "::error:: the unity activation may have failed. manual activation is required.%0A \
67-
1. download the artifact's .alf file.%0A \
68-
2. Go to https://license.unity3d.com/manual to activate manually.%0A \
69-
3. Generate a .ulf file from the .alf file and download it.%0A \
70-
4. Rename .ulf to 'Unity_v${UNITY_VERSION}.ulf'.%0A \
71-
5. Add file to ulfs repository.%0A \
72-
5. Re-run the jobs."
73-
74-
/opt/Unity/Editor/Unity -quit -batchmode -nographics -logFile -createManualActivationFile
75-
exit 1
76-
fi
32+
- run: echo "$GITHUB_CONTEXT"
7733
env:
78-
ULF_REPO: ${{ secrets.ULF_REPO }}
79-
UNITY_VERSION: ${{ matrix.unity }}
80-
81-
# (On failed activation) Upload unity activation file
82-
- name: Upload unity activation file
83-
uses: actions/upload-artifact@v2
84-
if: failure()
85-
with:
86-
name: Unity_v${{ matrix.unity }}.alf
87-
path: ./*.alf
88-
89-
# Setup testspace
90-
- uses: testspace-com/setup-testspace@v1
91-
with:
92-
domain: ${{ github.repository_owner }}
34+
GITHUB_CONTEXT: ${{ toJson(github) }}
9335

9436
# Checkout sandbox project
9537
- uses: actions/checkout@v2
9638
with:
9739
ref: "sandbox"
9840
submodules: "true"
99-
fetch-depth: "1"
41+
fetch-depth: "0"
10042

10143
# Update package submodule
10244
- name: "Update package submodule"
10345
working-directory: Packages/dev
104-
run: git checkout ${{ github.head_ref }}
46+
run: git checkout ${{ github.sha }}
10547

106-
# Run playmode tests
107-
- name: "Run playmode tests"
108-
if: always() && steps.activation.conclusion == 'success'
48+
- uses: actions/cache@v2
49+
with:
50+
path: Library
51+
key: Library-${{ matrix.unityVersion }}-${{ github.sha }}
52+
restore-keys: |
53+
Library-${{ matrix.unityVersion }}-
54+
Library-
55+
56+
# Install codecoverage package
57+
- name: "Install codecoverage package"
58+
if: startsWith(matrix.unityVersion, '2019.4.')
10959
run: |
110-
# Install codecoverage
111-
if [ -z "`echo ${{ matrix.unity }} | grep 2018.`" ]; then
112-
npm i -g openupm-cli
113-
openupm add com.unity.testtools.codecoverage
114-
fi
60+
npx openupm-cli add -f com.unity.testtools.codecoverage@0.4.0-preview
11561
116-
$RUN_UNITY -runTests -testPlatform playmode -enableCodeCoverage || exit 0
62+
# Run tests
63+
- name: "Run tests"
64+
uses: game-ci/unity-test-runner@main
65+
with:
66+
unityVersion: ${{ matrix.unityVersion }}
67+
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
68+
customParameters: -enableCodeCoverage -coverageOptions assemblyFilters:+CSharpCompilerSettings_,-*-CSharp,-*.Tests,-IgnoreAccessibility
11769

118-
# Run editmode tests
119-
- name: "Run editmode tests"
120-
if: always() && steps.activation.conclusion == 'success'
121-
run: |
122-
$RUN_UNITY -runTests -testPlatform editmode -enableCodeCoverage || exit 0
70+
- uses: actions/upload-artifact@v2
71+
if: always()
72+
with:
73+
name: TestResults-${{ matrix.unityVersion }}
74+
path: |
75+
artifacts/*.xml
76+
CodeCoverage/**/TestCoverageResults_*.xml
77+
78+
publish:
79+
needs: unity-test
80+
runs-on: ubuntu-latest
81+
if: always()
82+
steps:
83+
84+
- uses: actions/download-artifact@v2
85+
with:
86+
path: artifacts
87+
88+
- run: |
89+
ls -R
90+
working-directory: artifacts
91+
92+
- uses: testspace-com/setup-testspace@v1
93+
with:
94+
domain: ${{github.repository_owner}}
12395

124-
# Push test results
12596
- name: Push test results
126-
if: always() && steps.activation.conclusion == 'success'
127-
run: testspace "[${{ matrix.unity }}]TestResults-*.xml" "[Code Coverage]CodeCoverage/**/TestCoverageResults_*.xml"
97+
if: always()
98+
run: |
99+
testspace `find . -name '*.xml' | tr '\n' ' '`

0 commit comments

Comments
 (0)