Skip to content

Commit

Permalink
Add standalone testmode support (#219)
Browse files Browse the repository at this point in the history
* Add standalone support.

* Add standalone tests.

* UnityStandaloneScripts volume on windows

* Update test framework in test project.

* Revert IL2CPP setting in test project.
Add test for IL2CPP.

* Update dist/test-standalone-scripts/Assets/Player/UnityTestRunnerAction/TestRunCallback.cs

Co-authored-by: Webber Takken <[email protected]>

* Use 2019.2.21f1

* Unity is being dumb, use 2019.4.40f1 for all workflows.

* Disable PlayerConnection on build.
Print player log.

* Add comment about code coverage support in standalone.

* Update node-version in test

---------

Co-authored-by: Webber Takken <[email protected]>
  • Loading branch information
timcassell and webbertakken authored Apr 21, 2023
1 parent cfa9076 commit 31086d9
Show file tree
Hide file tree
Showing 40 changed files with 3,882 additions and 2,698 deletions.
123 changes: 117 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 18.x
- run: yarn
- run: yarn lint
- run: yarn test
Expand All @@ -32,10 +32,11 @@ jobs:
projectPath:
- unity-project-with-correct-tests
unityVersion:
- 2019.2.11f1
- 2019.4.40f1
testMode:
- playmode
- editmode
- standalone
steps:
###########################
# Checkout #
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
projectPath:
- unity-project-with-correct-tests
unityVersion:
- 2019.2.11f1
- 2019.4.40f1
steps:
###########################
# Checkout #
Expand Down Expand Up @@ -131,7 +132,7 @@ jobs:
fail-fast: false
matrix:
unityVersion:
- 2019.2.11f1
- 2019.4.40f1
projectPath:
- unity-project-with-correct-tests
steps:
Expand Down Expand Up @@ -188,7 +189,7 @@ jobs:
projectPath:
- unity-project-with-correct-tests
unityVersion:
- 2019.2.11f1
- 2019.4.40f1
steps:
###########################
# Checkout #
Expand Down Expand Up @@ -234,14 +235,115 @@ jobs:
path: ${{ steps.playMode.outputs.coveragePath }}
retention-days: 14

testRunnerInStandalone:
name: Test standalone 📺
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- unity-project-with-correct-tests
unityVersion:
- 2019.4.40f1
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v3
with:
lfs: true

###########################
# Cache #
###########################
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
# Configure test runner
- name: Run tests
id: standalone
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: standalone
artifactsPath: artifacts/standalone

# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test results (play mode)
path: ${{ steps.standalone.outputs.artifactsPath }}
retention-days: 14

testRunnerInStandaloneWithIL2CPP:
name: Test standalone with IL2CPP 📺
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- unity-project-with-correct-tests
unityVersion:
- 2019.4.40f1 # Only 2019.4+ docker images contain the IL2CPP backend installed.
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v3
with:
lfs: true

###########################
# Cache #
###########################
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
# Set scripting backend to IL2CPP
- name: Rewrite ProjectSettings
run: |
DefineOriginal=" scriptingBackend: {}"
DefineReplace=" scriptingBackend: \\n Standalone: 1"
sed -i "{s/$DefineOriginal/$DefineReplace/g}" ${{ matrix.projectPath }}/ProjectSettings/ProjectSettings.asset
# Configure test runner
- name: Run tests
id: standalone
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: standalone
artifactsPath: artifacts/standalone

# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test results (play mode)
path: ${{ steps.standalone.outputs.artifactsPath }}
retention-days: 14

testEachModeSequentially:
name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unityVersion:
- 2019.2.11f1
- 2019.4.40f1
projectPath:
- unity-project-with-correct-tests
steps:
Expand Down Expand Up @@ -281,6 +383,15 @@ jobs:
testMode: playmode
artifactsPath: artifacts/playmode

# Configure third test runner
- name: Tests in standalone 📺
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: standalone
artifactsPath: artifacts/playmode

# Upload combined artifacts
- name: Upload combined test results
uses: actions/upload-artifact@v3
Expand Down
Loading

0 comments on commit 31086d9

Please sign in to comment.