Skip to content

Commit dcfe341

Browse files
authored
Merge pull request #312 from Cysharp/feature/unittest
ci: Change Unity UnitTest from Mono to IL2CPP and enabled on CI
2 parents 753a555 + 1f5a9a7 commit dcfe341

28 files changed

+131
-3393
lines changed

.github/workflows/build-debug.yml

+43-29
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,58 @@ jobs:
1414
runs-on: ubuntu-latest
1515
timeout-minutes: 10
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
1919
- run: dotnet build -c Debug
2020
- run: dotnet test -c Debug --no-build
2121

2222
build-unity:
23-
if: "((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:'))"
24-
# strategy:
25-
# matrix:
26-
# unity: ["2021.3.11f1"]
23+
if: ${{ ((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:')) && github.triggering_actor != 'dependabot[bot]' }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
unity: ["2022.3.39f1", "6000.0.12f1"] # Test with LTS
2728
runs-on: ubuntu-latest
2829
timeout-minutes: 15
2930
steps:
30-
- uses: actions/checkout@v3
31-
# Execute scripts: RuntimeUnitTestToolkit
32-
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend mono /BuildTarget StandaloneLinux64
33-
# - name: Build UnitTest(Linux64, mono)
34-
# uses: Cysharp/Actions/.github/actions/unity-builder@main
35-
# env:
36-
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
37-
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
38-
# UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
39-
# with:
40-
# projectPath: src/MemoryPack.Unity
41-
# unityVersion: ${{ matrix.unity }}
42-
# targetPlatform: StandaloneLinux64
43-
# buildMethod: UnitTestBuilder.BuildUnitTest
44-
# customParameters: /headless /ScriptBackend mono
45-
# Unity 2021.2 and above changed Headless mode. It seems require Dedicated Server currently and investigating alternative api to enable batch mode.
46-
# - name: Execute UnitTest
47-
# run: ./src/MemoryPack.Unity/bin/UnitTest/StandaloneLinux64_Mono2x/test -batchmode
31+
- name: Load secrets
32+
id: op-load-secret
33+
uses: 1password/load-secrets-action@v2
34+
with:
35+
export-env: false
36+
env:
37+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }}
38+
UNITY_EMAIL: "op://GitHubActionsPublic/UNITY_LICENSE/username"
39+
UNITY_PASSWORD: "op://GitHubActionsPublic/UNITY_LICENSE/credential"
40+
UNITY_SERIAL: "op://GitHubActionsPublic/UNITY_LICENSE/serial"
4841

49-
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
42+
- uses: actions/checkout@v4
43+
44+
# Run SourceGenerater to generate serialization code
45+
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
46+
- run: dotnet build -c Debug # require build before run
47+
- name: Make sure generated files are exists.
48+
run: ls -lR "src/MemoryPack/bin/Debug/netstandard2.1"
49+
50+
# Execute Unittest
51+
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend IL2CPP /BuildTarget StandaloneLinux64
52+
- name: Build UnitTest
53+
uses: Cysharp/Actions/.github/actions/unity-builder@main
54+
env:
55+
UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }}
56+
UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }}
57+
UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }}
5058
with:
51-
directory: src/MemoryPack.Unity
59+
projectPath: src/MemoryPack.Unity
60+
unityVersion: ${{ matrix.unity }}
61+
targetPlatform: StandaloneLinux64
62+
buildMethod: UnitTestBuilder.BuildUnitTest
63+
customParameters: "/headless /ScriptBackend IL2CPP"
64+
- name: Check UnitTest file is generated
65+
run: ls -lR ./src/MemoryPack.Unity/bin/UnitTest
66+
- name: Execute UnitTest
67+
run: ./src/MemoryPack.Unity/bin/UnitTest/StandaloneLinux64_IL2CPP/test
5268

53-
# Store artifacts.
54-
- uses: actions/upload-artifact@v3
69+
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
5570
with:
56-
name: MemoryPack.${{ matrix.unity }}.unitypackage
57-
path: ./src/MemoryPack.Unity/*.unitypackage
71+
directory: src/MemoryPack.Unity

.github/workflows/build-release.yml

+38-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
timeout-minutes: 10
2929
steps:
3030
- run: echo ${{ needs.update-packagejson.outputs.sha }}
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232
with:
3333
ref: ${{ needs.update-packagejson.outputs.sha }}
3434
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
@@ -43,13 +43,49 @@ jobs:
4343

4444
build-unity:
4545
needs: [update-packagejson]
46+
strategy:
47+
matrix:
48+
unity: ["2022.3.39f1"]
4649
runs-on: ubuntu-latest
4750
timeout-minutes: 15
4851
steps:
52+
- name: Load secrets
53+
id: op-load-secret
54+
uses: 1password/load-secrets-action@v2
55+
with:
56+
export-env: false
57+
env:
58+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }}
59+
UNITY_EMAIL: "op://GitHubActionsPublic/UNITY_LICENSE/username"
60+
UNITY_PASSWORD: "op://GitHubActionsPublic/UNITY_LICENSE/credential"
61+
UNITY_SERIAL: "op://GitHubActionsPublic/UNITY_LICENSE/serial"
62+
4963
- run: echo ${{ needs.update-packagejson.outputs.sha }}
50-
- uses: actions/checkout@v3
64+
- uses: actions/checkout@v4
5165
with:
5266
ref: ${{ needs.update-packagejson.outputs.sha }}
67+
68+
# Run SourceGenerater to generate serialization code
69+
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
70+
- run: dotnet build -c Debug # require build before run
71+
- name: Make sure generated files are exists.
72+
run: ls -lR "src/MemoryPack/bin/Debug/netstandard2.1"
73+
74+
# Execute Unittest
75+
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend IL2CPP /BuildTarget StandaloneLinux64
76+
- name: Build UnitTest
77+
uses: Cysharp/Actions/.github/actions/unity-builder@main
78+
env:
79+
UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }}
80+
UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }}
81+
UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }}
82+
with:
83+
projectPath: src/MemoryPack.Unity
84+
unityVersion: ${{ matrix.unity }}
85+
targetPlatform: StandaloneLinux64
86+
buildMethod: UnitTestBuilder.BuildUnitTest
87+
customParameters: "/headless /ScriptBackend IL2CPP"
88+
5389
# check meta files
5490
- uses: Cysharp/Actions/.github/actions/check-metas@main
5591
with:

.gitignore

+6-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _ReSharper*
5757
*.ncrunch*
5858
.*crunch*.local.xml
5959

60-
# Installshield output folder
60+
# Installshield output folder
6161
[Ee]xpress
6262

6363
# DocProject is a documentation generator add-in
@@ -121,13 +121,12 @@ sandbox/SandboxConsoleApp/MemoryPackLogs/
121121
/sandbox/SandboxWebApp/node_modules
122122

123123
# Unity
124-
124+
.vsconfig
125125
src/MemoryPack.Unity/Library/*
126126
src/MemoryPack.Unity/Temp/*
127127
src/MemoryPack.Unity/Logs/*
128-
129-
src/MemoryPack.Unity/*.csproj
128+
src/MemoryPack.Unity/[Uu]ser[Ss]ettings/
130129
src/MemoryPack.Unity/*.sln
131-
src/MemoryPack.Unity/MemoryPack.*.unitypackage
132-
133-
.DS_Store
130+
src/MemoryPack.Unity/*.csproj
131+
src/MemoryPack.Unity/*.unitypackage
132+
!src/MemoryPack.Unity/Packages/

src/MemoryPack.Unity/.vsconfig

-6
This file was deleted.

src/MemoryPack.Unity/Assets/RuntimeUnitTestToolkit.meta

-8
This file was deleted.

src/MemoryPack.Unity/Assets/RuntimeUnitTestToolkit/Editor.meta

-8
This file was deleted.

src/MemoryPack.Unity/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs

-133
This file was deleted.

src/MemoryPack.Unity/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta

-11
This file was deleted.

0 commit comments

Comments
 (0)