Skip to content

Commit

Permalink
Add Feature to test Unity Packages (#164)
Browse files Browse the repository at this point in the history
* (should fail) add jq install to docker image

* (might fail) remove rm rf call

* move things around to try to fix test

* Revert "(might fail) remove rm rf call"

This reverts commit 22f74eb.

* remove silent setting from docker test

* Fix failing test's Docker image

* Add new input and basic test

* Add test package; start using jq cli

* Use test package in test workflow

* Create temporary Unity Project and run tests

* Test removing jq install from Dockerfile

* Revert "Test removing jq install from Dockerfile"

This reverts commit 6aa7a6f.

* Remove mkdir call

* remove duplicate command

* add packageMode option back in

* build changes

* check for apt-get before installing jq

* change apt-get version check message

* spelling and documentation fixes

* add working example unity package with tests

* add temp pwd call to help figure out absolute pathing

* fix workflow package location

* add jq to add package to temp project packages

* try fixing jq calls

* clean up jq calls, fix variable expansion

* try renaming jq args

* try using different arg syntax for jq

* try wrapping args in parentheses

* try using double quotes only

* try changing up quoting

* try properly using string interpolation

* try removing colon

* add string interpolation to key

* omit double quotes from jq call to retrieve package name

* clean up logging

* add rest of workflow tests

* Revert "add rest of workflow tests"

This reverts commit c0bb008.

* add play mode test without cache

* add package mode all mode workflow step

* add consecutive ppackage mode workflow step

* add package mode "like in the readme" test

* fix workflow syntax error

* try to fix syntax error again

* use correct folder

* *hopefully actually* use correct package path

* try adding caching to "readme" test

* remove caching/mentions of caching from package mode tests

* fix artifacts paths

* fix artifacts pathing and names

* fix combined artifacts for package mode

* clean up documentation and exit code

* clarify allowed docker images for packageMode

* update README to mention Unity packages

* move package name validation to TS part of action

* improve logging for temp project creation failure

* make husky hook executable

* add error for missing tests folder

* update docs to reflect unsupported packages

* remove jq install

* Revert "remove jq install"

This reverts commit bd35ac8.

* TEMP log image in use

* Revert "TEMP log image in use"

This reverts commit 95722dc.

* Revert "Revert "remove jq install""

This reverts commit e3bac04.

* TEMP list installed packages

* Revert "TEMP list installed packages"

This reverts commit db9c07d.

* TEMP log project's manifest

* add code coverage package to generated project

* remove temp project manifest log

* add coverage to package mode tests

* update name of package coverage steps

* add codecoverage dependency to test package

* Revert "add codecoverage dependency to test package"

This reverts commit 4b2c030.

* add assembly filters for coverage

* TEMP console log project folder

* Revert "TEMP console log project folder"

This reverts commit 411ec51.

* add logic to copy package to folder without activation file

* fix false positive activation file detection

* fix improper bash "if" formatting

* TEMP remove conditional for package copying

* Revert "TEMP remove conditional for package copying"

This reverts commit 4f12d83.

* Revert "fix improper bash "if" formatting"

This reverts commit acb975b.

* Revert "fix false positive activation file detection"

This reverts commit 580c9c1.

* Revert "add logic to copy package to folder without activation file"

This reverts commit b20d994.

* run yarn build

* move package mode check lower in the file

* throw error if unity version is auto in package mode

* fix unity version error wording

* try deleting activate license file

* try logging hidden package files

* try deleting all non-package files

* fix license activation files deletion

* scrap file removals and print dir permissions

* log permissions for package folder

* Add packageMode inputs to main

* fix fs mocks and run yarn build

* fix documentation and add error message for missing jq

* add clarification on package mode caveats

* fix line endings problem (?)

* Revert "fix line endings problem (?)"

This reverts commit 1cba302.

* Revert "add clarification on package mode caveats"

This reverts commit fb62d36.

* Revert "fix documentation and add error message for missing jq"

This reverts commit 0df3ab6.

* Redo the input docs fixes

* Redo the jq presence test

* update readme to indicate package mode caveats

* fix wording on coverageOptions

* one more wording fix on coverageOptions

* move sample package to example.com domain

---------

Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
  • Loading branch information
trudeaua21 and trudeaua-vividream-software authored Jul 3, 2023
1 parent 31086d9 commit 7787abf
Show file tree
Hide file tree
Showing 45 changed files with 1,058 additions and 11 deletions.
223 changes: 223 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,226 @@ jobs:
name: Test results (combined)
path: artifacts/
retention-days: 14

testAllPackageModesLikeInTheReadme:
name: Test package mode 📦 in ${{ matrix.testMode }} on version ${{ matrix.unityVersion }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- unity-package-with-correct-tests/com.example.testpackage
unityVersion:
- 2019.2.11f1
testMode:
- playmode
- editmode

steps:
###########################
# Checkout #
###########################
- name: Checkout
uses: actions/checkout@v2
with:
lfs: true

- uses: ./
id: packageTests
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: ${{ matrix.testMode }}
artifactsPath: ${{ matrix.testMode }}-packageArtifacts
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
packageMode: true

- uses: actions/upload-artifact@v2
with:
name: Package test results for ${{ matrix.testMode }}
path: ${{ steps.packageTests.outputs.artifactsPath }}
retention-days: 14

testPackageRunnerInAllModes:
name: Test package mode in all modes 📦✨
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- unity-package-with-correct-tests/com.example.testpackage
unityVersion:
- 2019.2.11f1
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v2
with:
lfs: true

# Configure test runner
- name: Run tests
id: packageAllTests
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: all
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+example.testpackage.*,-*Tests*'
packageMode: true
# Test implicit artifactsPath, by not setting it

# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: Package test results (all)
path: ${{ steps.packageAllTests.outputs.artifactsPath }}
retention-days: 14

# Upload coverage
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: Package Coverage results (all)
path: ${{ steps.packageAllTests.outputs.coveragePath }}
retention-days: 14

testPackageRunnerInEditMode:
name: Test package mode in edit mode 📦📝
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unityVersion:
- 2019.2.11f1
projectPath:
- unity-package-with-correct-tests/com.example.testpackage
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v2
with:
lfs: true

# Configure test runner
- name: Run tests
id: packageEditMode
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: editmode
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+example.testpackage.*,-*Tests*'
artifactsPath: artifacts/packageeditmode
packageMode: true

# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: Package test results (edit mode)
path: ${{ steps.packageEditMode.outputs.artifactsPath }}
retention-days: 14

# Upload coverage
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: Package Coverage results (edit mode)
path: ${{ steps.packageEditMode.outputs.coveragePath }}
retention-days: 14

testPackageRunnerInPlayMode:
name: Test package mode in play mode 📦📺
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- unity-package-with-correct-tests/com.example.testpackage
unityVersion:
- 2019.2.11f1
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v2
with:
lfs: true

# Configure test runner
- name: Run tests
id: packagePlayMode
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: playmode
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+example.testpackage.*,-*Tests*'
artifactsPath: artifacts/packageplaymode
packageMode: true

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

# Upload coverage
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: Package Coverage results (play mode)
path: ${{ steps.packagePlayMode.outputs.coveragePath }}
retention-days: 14

testPackageModeEachModeSequentially:
name: Test package mode in 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
projectPath:
- unity-package-with-correct-tests/com.example.testpackage
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v2
with:
lfs: true

# Configure first test runner
- name: Test package mode in editmode 📦📝
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: editmode
artifactsPath: packageArtifacts/editmode
packageMode: true

# Configure second test runner
- name: Test package mode in playmode 📦📺
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: playmode
artifactsPath: packageArtifacts/playmode
packageMode: true

# Upload combined artifacts
- name: Upload combined test results
uses: actions/upload-artifact@v2
with:
name: Package test results (combined)
path: packageArtifacts/
retention-days: 14
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

GitHub Action to
[run tests](https://github.com/marketplace/actions/unity-test-runner)
for any Unity project.
for any Unity project and _some_ Unity packages.

Part of the <a href="https://game.ci">GameCI</a> open source project.
<br />
Expand Down
12 changes: 8 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ inputs:
unityVersion:
required: false
default: 'auto'
description: 'Version of unity to use for testing the project. Use "auto" to get from your ProjectSettings/ProjectVersion.txt'
description: 'Version of unity to use for testing the project. Use "auto" to get from your ProjectSettings/ProjectVersion.txt. ⚠️ If testing a Unity Package, this field is required and cannot be set to "auto".'
customImage:
required: false
default: ''
description: 'Specific docker image that should be used for testing the project'
description: 'Specific docker image that should be used for testing the project. If packageMode is true, this image must have jq installed.'
projectPath:
required: false
description: 'Path to the Unity project to be tested.'
description: 'Path to the Unity project or package to be tested.'
customParameters:
required: false
description: 'Extra parameters to configure the Unity editor run.'
Expand All @@ -23,7 +23,7 @@ inputs:
coverageOptions:
required: false
default: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;dontClear'
description: 'Optional coverage parameters for the -coverageOptions argument.'
description: 'Optional coverage parameters for the -coverageOptions argument. To get coverage in Package Mode, pass assemblies from the package you want covered to the assemblyFilters option.'
artifactsPath:
required: false
default: 'artifacts'
Expand All @@ -48,6 +48,10 @@ inputs:
required: false
default: 'Test Results'
description: 'Name for the check run that is created when a github token is provided.'
packageMode:
required: false
default: false
description: 'Whether the tests are being run for a Unity package instead of a Unity project. If true, the action can only be run on Linux runners, and any custom docker image passed to this action must have `jq` installed. NOTE: may not work properly for packages with dependencies outside of the Unity Registry.'
chownFilesTo:
required: false
default: ''
Expand Down
Loading

0 comments on commit 7787abf

Please sign in to comment.