Skip to content

Commit

Permalink
Merge pull request #312 from Cysharp/feature/unittest
Browse files Browse the repository at this point in the history
ci: Change Unity UnitTest from Mono to IL2CPP and enabled on CI
  • Loading branch information
neuecc authored Sep 10, 2024
2 parents 753a555 + 1f5a9a7 commit dcfe341
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 3,393 deletions.
72 changes: 43 additions & 29 deletions .github/workflows/build-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,58 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: dotnet build -c Debug
- run: dotnet test -c Debug --no-build

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

- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
- uses: actions/checkout@v4

# Run SourceGenerater to generate serialization code
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: dotnet build -c Debug # require build before run
- name: Make sure generated files are exists.
run: ls -lR "src/MemoryPack/bin/Debug/netstandard2.1"

# Execute Unittest
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend IL2CPP /BuildTarget StandaloneLinux64
- name: Build UnitTest
uses: Cysharp/Actions/.github/actions/unity-builder@main
env:
UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }}
with:
directory: src/MemoryPack.Unity
projectPath: src/MemoryPack.Unity
unityVersion: ${{ matrix.unity }}
targetPlatform: StandaloneLinux64
buildMethod: UnitTestBuilder.BuildUnitTest
customParameters: "/headless /ScriptBackend IL2CPP"
- name: Check UnitTest file is generated
run: ls -lR ./src/MemoryPack.Unity/bin/UnitTest
- name: Execute UnitTest
run: ./src/MemoryPack.Unity/bin/UnitTest/StandaloneLinux64_IL2CPP/test

# Store artifacts.
- uses: actions/upload-artifact@v3
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
with:
name: MemoryPack.${{ matrix.unity }}.unitypackage
path: ./src/MemoryPack.Unity/*.unitypackage
directory: src/MemoryPack.Unity
40 changes: 38 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
timeout-minutes: 10
steps:
- run: echo ${{ needs.update-packagejson.outputs.sha }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ needs.update-packagejson.outputs.sha }}
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
Expand All @@ -43,13 +43,49 @@ jobs:

build-unity:
needs: [update-packagejson]
strategy:
matrix:
unity: ["2022.3.39f1"]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Load secrets
id: op-load-secret
uses: 1password/load-secrets-action@v2
with:
export-env: false
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }}
UNITY_EMAIL: "op://GitHubActionsPublic/UNITY_LICENSE/username"
UNITY_PASSWORD: "op://GitHubActionsPublic/UNITY_LICENSE/credential"
UNITY_SERIAL: "op://GitHubActionsPublic/UNITY_LICENSE/serial"

- run: echo ${{ needs.update-packagejson.outputs.sha }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ needs.update-packagejson.outputs.sha }}

# Run SourceGenerater to generate serialization code
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: dotnet build -c Debug # require build before run
- name: Make sure generated files are exists.
run: ls -lR "src/MemoryPack/bin/Debug/netstandard2.1"

# Execute Unittest
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend IL2CPP /BuildTarget StandaloneLinux64
- name: Build UnitTest
uses: Cysharp/Actions/.github/actions/unity-builder@main
env:
UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }}
with:
projectPath: src/MemoryPack.Unity
unityVersion: ${{ matrix.unity }}
targetPlatform: StandaloneLinux64
buildMethod: UnitTestBuilder.BuildUnitTest
customParameters: "/headless /ScriptBackend IL2CPP"

# check meta files
- uses: Cysharp/Actions/.github/actions/check-metas@main
with:
Expand Down
13 changes: 6 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ _ReSharper*
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
Expand Down Expand Up @@ -121,13 +121,12 @@ sandbox/SandboxConsoleApp/MemoryPackLogs/
/sandbox/SandboxWebApp/node_modules

# Unity

.vsconfig
src/MemoryPack.Unity/Library/*
src/MemoryPack.Unity/Temp/*
src/MemoryPack.Unity/Logs/*

src/MemoryPack.Unity/*.csproj
src/MemoryPack.Unity/[Uu]ser[Ss]ettings/
src/MemoryPack.Unity/*.sln
src/MemoryPack.Unity/MemoryPack.*.unitypackage

.DS_Store
src/MemoryPack.Unity/*.csproj
src/MemoryPack.Unity/*.unitypackage
!src/MemoryPack.Unity/Packages/
6 changes: 0 additions & 6 deletions src/MemoryPack.Unity/.vsconfig

This file was deleted.

8 changes: 0 additions & 8 deletions src/MemoryPack.Unity/Assets/RuntimeUnitTestToolkit.meta

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit dcfe341

Please sign in to comment.