Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Feature to test Unity Packages #164

Merged
merged 115 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
db91528
(should fail) add jq install to docker image
trudeaua21 Oct 20, 2021
22f74eb
(might fail) remove rm rf call
trudeaua21 Oct 20, 2021
dff7de9
move things around to try to fix test
trudeaua21 Oct 20, 2021
c980404
Revert "(might fail) remove rm rf call"
trudeaua21 Oct 20, 2021
f9b9590
remove silent setting from docker test
trudeaua21 Oct 20, 2021
d9147cd
Fix failing test's Docker image
trudeaua21 Oct 21, 2021
1a54f84
Add new input and basic test
trudeaua21 Oct 21, 2021
b38a591
Add test package; start using jq cli
trudeaua21 Oct 21, 2021
d0b45c2
Use test package in test workflow
trudeaua21 Oct 21, 2021
1a9d374
Create temporary Unity Project and run tests
trudeaua21 Oct 21, 2021
6aa7a6f
Test removing jq install from Dockerfile
trudeaua21 Oct 21, 2021
635b692
Revert "Test removing jq install from Dockerfile"
trudeaua21 Oct 21, 2021
f5125f8
Remove mkdir call
trudeaua21 Oct 21, 2021
6da30c5
Merge branch 'main' of https://github.com/game-ci/unity-test-runner i…
trudeaua21 Jan 17, 2022
3b96124
Merge branch 'game-ci-main'
trudeaua21 Jan 17, 2022
19b81ef
remove duplicate command
trudeaua21 Jan 17, 2022
2a1d0bf
add packageMode option back in
trudeaua21 Jan 17, 2022
da456a3
build changes
trudeaua21 Jan 17, 2022
3f24118
check for apt-get before installing jq
trudeaua21 Jan 17, 2022
7a0e9c0
change apt-get version check message
trudeaua21 Jan 17, 2022
8e0b824
spelling and documentation fixes
trudeaua21 Jan 17, 2022
0555c18
add working example unity package with tests
trudeaua21 Jan 27, 2022
4f08cb5
add temp pwd call to help figure out absolute pathing
trudeaua21 Jan 27, 2022
798f66e
fix workflow package location
trudeaua21 Jan 27, 2022
39b63d9
add jq to add package to temp project packages
trudeaua21 Jan 27, 2022
f8810dc
try fixing jq calls
trudeaua21 Jan 27, 2022
bcf9542
clean up jq calls, fix variable expansion
trudeaua21 Jan 27, 2022
a023014
try renaming jq args
trudeaua21 Jan 27, 2022
f51a729
try using different arg syntax for jq
trudeaua21 Jan 27, 2022
e6dac78
try wrapping args in parentheses
trudeaua21 Jan 27, 2022
abfddf2
try using double quotes only
trudeaua21 Jan 27, 2022
feb610b
try changing up quoting
trudeaua21 Jan 27, 2022
f53e41c
try properly using string interpolation
trudeaua21 Jan 27, 2022
f8e2231
try removing colon
trudeaua21 Jan 27, 2022
592e959
add string interpolation to key
trudeaua21 Jan 27, 2022
16c034f
omit double quotes from jq call to retrieve package name
trudeaua21 Jan 27, 2022
4312493
clean up logging
trudeaua21 Jan 27, 2022
c0bb008
add rest of workflow tests
trudeaua21 Jan 27, 2022
9eabe57
Revert "add rest of workflow tests"
trudeaua21 Jan 27, 2022
963f4e5
add play mode test without cache
trudeaua21 Jan 27, 2022
522658a
add package mode all mode workflow step
trudeaua21 Jan 27, 2022
9f30148
add consecutive ppackage mode workflow step
trudeaua21 Jan 27, 2022
8938275
add package mode "like in the readme" test
trudeaua21 Feb 6, 2022
2742382
fix workflow syntax error
trudeaua21 Feb 6, 2022
ab1facd
try to fix syntax error again
trudeaua21 Feb 6, 2022
3a919c6
use correct folder
trudeaua21 Feb 6, 2022
9c6589d
*hopefully actually* use correct package path
trudeaua21 Feb 6, 2022
0dfba9d
try adding caching to "readme" test
trudeaua21 Feb 6, 2022
510d7f0
remove caching/mentions of caching from package mode tests
trudeaua21 Feb 6, 2022
5723ea9
fix artifacts paths
trudeaua21 Feb 6, 2022
980e6b7
fix artifacts pathing and names
trudeaua21 Feb 6, 2022
2011208
fix combined artifacts for package mode
trudeaua21 Feb 7, 2022
99e2333
clean up documentation and exit code
trudeaua21 Feb 7, 2022
3620484
clarify allowed docker images for packageMode
trudeaua21 Feb 23, 2022
7a6805e
update README to mention Unity packages
trudeaua21 Feb 23, 2022
a04ac83
move package name validation to TS part of action
trudeaua21 Mar 1, 2022
c984699
Merge branch 'game-ci:main' into main
trudeaua21 Mar 1, 2022
27b9700
Merge branch 'main' of https://github.com/trudeaua21/unity-test-runner
trudeaua21 Mar 1, 2022
7f6ed5d
improve logging for temp project creation failure
trudeaua21 Mar 1, 2022
140183d
make husky hook executable
trudeaua21 Mar 1, 2022
441ad80
add error for missing tests folder
trudeaua21 Mar 1, 2022
7338fb9
merge main and fix no-abbreviation eslint error
trudeaua21 Mar 25, 2022
acea6b6
update docs to reflect unsupported packages
trudeaua21 Mar 25, 2022
bd35ac8
remove jq install
trudeaua21 Mar 30, 2022
e3bac04
Revert "remove jq install"
trudeaua21 Mar 30, 2022
95722dc
TEMP log image in use
trudeaua21 Mar 30, 2022
2fe4078
Revert "TEMP log image in use"
trudeaua21 Mar 30, 2022
14f2743
Revert "Revert "remove jq install""
trudeaua21 Mar 31, 2022
db9c07d
TEMP list installed packages
trudeaua21 Mar 31, 2022
793451a
Merge remote-tracking branch 'upstream/main'
trudeaua21 Apr 26, 2022
d8ac8df
Revert "TEMP list installed packages"
trudeaua21 Apr 26, 2022
c942fae
TEMP log project's manifest
trudeaua21 Apr 26, 2022
1580d4c
add code coverage package to generated project
trudeaua21 Apr 26, 2022
c927250
remove temp project manifest log
trudeaua21 Apr 26, 2022
d0104eb
add coverage to package mode tests
trudeaua21 Apr 26, 2022
7eda874
update name of package coverage steps
trudeaua21 Apr 26, 2022
4b2c030
add codecoverage dependency to test package
trudeaua21 Apr 27, 2022
ebd7a75
Revert "add codecoverage dependency to test package"
trudeaua21 Apr 27, 2022
b47553a
add assembly filters for coverage
trudeaua21 Apr 27, 2022
411ec51
TEMP console log project folder
trudeaua21 May 11, 2022
139a8b1
Revert "TEMP console log project folder"
trudeaua21 May 11, 2022
b20d994
add logic to copy package to folder without activation file
trudeaua21 May 11, 2022
580c9c1
fix false positive activation file detection
trudeaua21 May 11, 2022
acb975b
fix improper bash "if" formatting
trudeaua21 May 11, 2022
4f12d83
TEMP remove conditional for package copying
trudeaua21 May 11, 2022
397d1ba
Revert "TEMP remove conditional for package copying"
trudeaua21 May 11, 2022
4895ba9
Revert "fix improper bash "if" formatting"
trudeaua21 May 11, 2022
0e7c6f9
Revert "fix false positive activation file detection"
trudeaua21 May 11, 2022
76e4fa8
Revert "add logic to copy package to folder without activation file"
trudeaua21 May 11, 2022
0061df2
merge main
trudeaua21 Jun 30, 2022
8bed000
run yarn build
trudeaua21 Jun 30, 2022
dbb5a4c
move package mode check lower in the file
trudeaua21 Jun 30, 2022
bd60170
throw error if unity version is auto in package mode
trudeaua21 Jun 30, 2022
9d2f6b8
fix unity version error wording
trudeaua21 Jun 30, 2022
6d87a92
try deleting activate license file
trudeaua21 Jul 1, 2022
1f56db9
try logging hidden package files
trudeaua21 Jul 1, 2022
9169a99
try deleting all non-package files
trudeaua21 Jul 1, 2022
c9301a2
fix license activation files deletion
trudeaua21 Jul 1, 2022
f75f0eb
scrap file removals and print dir permissions
trudeaua21 Jul 1, 2022
4025223
log permissions for package folder
trudeaua21 Jul 1, 2022
ffb0014
Merge in changes
trudeaua-vividream-software May 24, 2023
8ac6a10
Add packageMode inputs to main
trudeaua-vividream-software May 24, 2023
1afbd6b
fix fs mocks and run yarn build
trudeaua-vividream-software May 24, 2023
0df3ab6
fix documentation and add error message for missing jq
trudeaua-vividream-software Jun 7, 2023
fb62d36
add clarification on package mode caveats
trudeaua-vividream-software Jun 7, 2023
1cba302
fix line endings problem (?)
trudeaua-vividream-software Jun 7, 2023
c0e9729
Revert "fix line endings problem (?)"
trudeaua-vividream-software Jun 10, 2023
ed7bbc6
Revert "add clarification on package mode caveats"
trudeaua-vividream-software Jun 10, 2023
22d5420
Revert "fix documentation and add error message for missing jq"
trudeaua-vividream-software Jun 10, 2023
edae3e7
Redo the input docs fixes
trudeaua-vividream-software Jun 10, 2023
32aa19c
Redo the jq presence test
trudeaua-vividream-software Jun 10, 2023
a1b7bb8
update readme to indicate package mode caveats
trudeaua-vividream-software Jun 10, 2023
aed7ecd
fix wording on coverageOptions
trudeaua-vividream-software Jun 15, 2023
ad8643f
one more wording fix on coverageOptions
trudeaua-vividream-software Jun 16, 2023
70eaa73
move sample package to example.com domain
trudeaua-vividream-software Jun 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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".'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to detect that a Unity Package is tested instead of the regular case?

Perhaps we can just smoothen this over inside the auto strategy?

Perhaps something like this?

  if (input.packageMode) return

Copy link
Contributor Author

@trudeaua21 trudeaua21 Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a thrown error for this case on line 109 of input.ts:

    if (packageMode) {
      if (unityVersion === 'auto') {
        throw new Error(
          'Package Mode is enabled, but unityVersion is set to "auto". unityVersion must manually be set in Package Mode.',
        );
      }

      packageName = this.getPackageNameFromPackageJson(projectPath);
      this.verifyTestsFolderIsPresent(projectPath);
    }

Does this address the problem or no? Not totally sure if this is what you were going for.

I'd like to add an "auto" strategy for package mode, but not until after the base feature is released, if possible.

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