mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-01-29 06:20:07 +08:00
Compare commits
26 Commits
v1.5
...
v2.0-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31cd755121 | ||
|
|
679222c549 | ||
|
|
29899d84e8 | ||
|
|
7d26e264b9 | ||
|
|
bac0f97d2f | ||
|
|
c4e44617e2 | ||
|
|
25e14f52b8 | ||
|
|
3a40ffcf5f | ||
|
|
3277792c11 | ||
|
|
ac2e8a74d0 | ||
|
|
8107d46ab7 | ||
|
|
a4e8475a2f | ||
|
|
f02586c1c9 | ||
|
|
31ae95179d | ||
|
|
cd86c7302b | ||
|
|
21831e61ad | ||
|
|
7c1cba9a39 | ||
|
|
29e179f50b | ||
|
|
2fa69494ad | ||
|
|
4e717f6c82 | ||
|
|
173716a8a9 | ||
|
|
3c915726f4 | ||
|
|
5cfdb7ee17 | ||
|
|
51648a5093 | ||
|
|
2297daa673 | ||
|
|
7711f454ba |
9
.github/pull_request_template.md
vendored
Normal file
9
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#### Changes
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
#### Checklist
|
||||||
|
|
||||||
|
- [x] Read the contribution [guide](../CONTRIBUTING.md) and accept the [code](../CODE_OF_CONDUCT.md) of conduct
|
||||||
|
- [ ] Readme (updated or not needed)
|
||||||
|
- [ ] Tests (added, updated or not needed)
|
||||||
272
README.md
272
README.md
@@ -1,262 +1,48 @@
|
|||||||
# Unity - Test runner
|
<div align="center">
|
||||||
|
<a href="https://github.com/marketplace/actions/unity-test-runner">
|
||||||
[](https://github.com/webbertakken/unity-test-runner/actions?query=branch%3Amaster+event%3Apush+workflow%3A"Actions%20%F0%9F%98%8E")
|
<img width="800" src="media/UnityTestRunner-Logo.png" alt="Unity Test Runner">
|
||||||
|
</a>
|
||||||
---
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
GitHub Action to
|
GitHub Action to
|
||||||
[run tests](https://github.com/marketplace/actions/unity-test-runner)
|
[run tests](https://github.com/marketplace/actions/unity-test-runner)
|
||||||
for any Unity project.
|
for any Unity project.
|
||||||
|
|
||||||
Part of the
|
Part of the <a href="https://unity-ci.com"><img height="30" src="media/UnityCI-ReferenceLogo.png" alt="Unity CI"></a> open source project.
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
<br />
|
||||||
collection.
|
<br />
|
||||||
|
|
||||||
---
|
[](https://github.com/webbertakken/unity-test-runner/actions?query=branch%3Amaster+event%3Apush+workflow%3A"Actions%20%F0%9F%98%8E")
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
This is a recommended step to prepare your pipeline for using the
|
</div>
|
||||||
[Build](https://github.com/webbertakken/unity-actions#build)
|
|
||||||
action.
|
|
||||||
|
|
||||||
## Documentation
|
## How to use
|
||||||
|
|
||||||
See the
|
Find the
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
[docs](https://unity-ci.com/docs/github)
|
||||||
collection repository for workflow documentation and reference implementation.
|
on the Unity CI
|
||||||
|
[website](https://unity-ci.com/).
|
||||||
|
|
||||||
## Usage
|
## Related actions
|
||||||
|
|
||||||
#### Setup test runner
|
Visit the
|
||||||
|
<a href="https://github.com/webbertakken/unity-actions"><img height="30" src="media/UnityActions-ReferenceLogo.png" alt="Unity Actions"></a>
|
||||||
|
status repository for related Actions.
|
||||||
|
|
||||||
By default the test runner will run all your playmode and editmode tests.
|
## Community
|
||||||
|
|
||||||
Create or edit the file called `.github/workflows/main.yml` and add a job to it.
|
Feel free to join us on
|
||||||
|
<a href="http://unity-ci.com/discord"><img height="30" src="media/Discord-Logo.svg" alt="Discord" /></a>
|
||||||
|
and engage with the community.
|
||||||
|
|
||||||
##### Personal License
|
## Contributing
|
||||||
|
|
||||||
Personal licenses require a one-time manual activation step (per unity version).
|
To help out sharpen the documentation, please find the docs [repository](https://github.com/Unity-CI/Website).
|
||||||
|
|
||||||
Make sure you
|
To contribute to this project, kindly read the [contribution guide](./CONTRIBUTING.md).
|
||||||
[acquire and activate](https://github.com/marketplace/actions/unity-request-activation-file)
|
|
||||||
your license file and add it as a secret.
|
|
||||||
|
|
||||||
Then, define the test step as follows:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: webbertakken/unity-test-runner@v1.4
|
|
||||||
env:
|
|
||||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
|
||||||
with:
|
|
||||||
projectPath: path/to/your/project
|
|
||||||
unityVersion: 20XX.X.XXXX
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Professional license
|
|
||||||
|
|
||||||
Professional licenses do not need any manual steps.
|
|
||||||
|
|
||||||
Instead, three variables will need to be set.
|
|
||||||
|
|
||||||
- `UNITY_EMAIL` (should contain the email address for your Unity account)
|
|
||||||
- `UNITY_PASSWORD` (the password that you use to login to Unity)
|
|
||||||
- `UNITY_SERIAL` (the serial provided by Unity)
|
|
||||||
|
|
||||||
Define the test step as follows:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: webbertakken/unity-test-runner@v1.4
|
|
||||||
env:
|
|
||||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
|
||||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
|
||||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
|
||||||
with:
|
|
||||||
projectPath: path/to/your/project
|
|
||||||
unityVersion: 20XX.X.XXXX
|
|
||||||
```
|
|
||||||
|
|
||||||
That is all you need to test your project.
|
|
||||||
|
|
||||||
#### Storing test results
|
|
||||||
|
|
||||||
To be able to access the test results,
|
|
||||||
they need to be uploaded as artifacts.
|
|
||||||
To do this it is recommended to use Github Actions official
|
|
||||||
[upload artifact action](https://github.com/marketplace/actions/upload-artifact)
|
|
||||||
after any test action.
|
|
||||||
|
|
||||||
###### Using defaults
|
|
||||||
|
|
||||||
By default, Test Runner outputs it's results to a folder named `artifacts`.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: Test results
|
|
||||||
path: artifacts
|
|
||||||
```
|
|
||||||
|
|
||||||
Test results can now be downloaded as Artifacts in the Actions tab.
|
|
||||||
|
|
||||||
###### Specifying artifacts folder
|
|
||||||
|
|
||||||
If a different `artifactsPath` was specified in the test runner,
|
|
||||||
you can reference this path using the `id` of the test step.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: webbertakken/unity-test-runner@v1.4
|
|
||||||
id: myTestStep
|
|
||||||
(...)
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: Test results
|
|
||||||
path: ${{ steps.myTestStep.outputs.artifactsPath }}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Caching
|
|
||||||
|
|
||||||
In order to make test runs (and builds) faster,
|
|
||||||
you can cache Library files from previous runs.
|
|
||||||
To do so, simply add Github Actions' official
|
|
||||||
[cache action](https://github.com/marketplace/actions/cache)
|
|
||||||
before any unity steps.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/cache@v1.1.0
|
|
||||||
with:
|
|
||||||
path: path/to/your/project/Library
|
|
||||||
key: Library-MyProjectName-TargetPlatform
|
|
||||||
restore-keys: |
|
|
||||||
Library-MyProjectName-
|
|
||||||
Library-
|
|
||||||
```
|
|
||||||
|
|
||||||
This simple addition could speed up your test runs by more than 50%.
|
|
||||||
|
|
||||||
#### Complete example
|
|
||||||
|
|
||||||
A complete workflow that tests all modes separately could look like this:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: Build project
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request: {}
|
|
||||||
push: { branches: [master] }
|
|
||||||
|
|
||||||
env:
|
|
||||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
testAllModes:
|
|
||||||
name: Test in ${{ matrix.testMode }} on version ${{ matrix.unityVersion }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
projectPath:
|
|
||||||
- path/to/your/project
|
|
||||||
unityVersion:
|
|
||||||
- 2019.2.11f1
|
|
||||||
testMode:
|
|
||||||
- playmode
|
|
||||||
- editmode
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
lfs: true
|
|
||||||
- uses: actions/cache@v1.1.0
|
|
||||||
with:
|
|
||||||
path: ${{ matrix.projectPath }}/Library
|
|
||||||
key: Library-${{ matrix.projectPath }}
|
|
||||||
restore-keys: |
|
|
||||||
Library-
|
|
||||||
- uses: webbertakken/unity-test-runner@v1.4
|
|
||||||
id: tests
|
|
||||||
with:
|
|
||||||
projectPath: ${{ matrix.projectPath }}
|
|
||||||
unityVersion: ${{ matrix.unityVersion }}
|
|
||||||
testMode: ${{ matrix.testMode }}
|
|
||||||
artifactsPath: ${{ matrix.testMode }}-artifacts
|
|
||||||
- uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: Test results for ${{ matrix.testMode }}
|
|
||||||
path: ${{ steps.tests.outputs.artifactsPath }}
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Note:** _Environment variables are set for all jobs in the workflow like this._
|
|
||||||
|
|
||||||
## Configuration options
|
|
||||||
|
|
||||||
Below options can be specified under `with:` for the `unity-test-runner` action.
|
|
||||||
|
|
||||||
#### projectPath
|
|
||||||
|
|
||||||
Specify the path to your Unity project to be tested.
|
|
||||||
The path should be relative to the root of your project.
|
|
||||||
|
|
||||||
_**required:** `false`_
|
|
||||||
_**default:** `<your project root>`_
|
|
||||||
|
|
||||||
#### unityVersion
|
|
||||||
|
|
||||||
Version of Unity to use for testing the project.
|
|
||||||
|
|
||||||
_**required:** `false`_
|
|
||||||
_**default:** `2019.2.1f11`_
|
|
||||||
|
|
||||||
#### testMode
|
|
||||||
|
|
||||||
The type of tests to be run by the test runner.
|
|
||||||
|
|
||||||
Options are: "all", "playmode", "editmode"
|
|
||||||
|
|
||||||
_**required:** `false`_
|
|
||||||
_**default:** `all`_
|
|
||||||
|
|
||||||
#### artifactsPath
|
|
||||||
|
|
||||||
Path where the test results should be stored.
|
|
||||||
|
|
||||||
In this folder a folder will be created for every test mode.
|
|
||||||
|
|
||||||
_**required:** `false`_
|
|
||||||
_**default:** `artifacts`_
|
|
||||||
|
|
||||||
#### customParameters
|
|
||||||
|
|
||||||
Custom parameters to configure the test runner.
|
|
||||||
|
|
||||||
Parameters must start with a hyphen (`-`) and may be followed by a value (without hyphen).
|
|
||||||
|
|
||||||
Parameters without a value will be considered booleans (with a value of true).
|
|
||||||
|
|
||||||
_**example:**_
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: webbertakken/unity-test-runner@master
|
|
||||||
with:
|
|
||||||
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
|
|
||||||
```
|
|
||||||
|
|
||||||
_**required:** `false`_
|
|
||||||
_**default:** ""_
|
|
||||||
|
|
||||||
## More actions
|
|
||||||
|
|
||||||
Visit
|
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
|
||||||
to find related actions for Unity.
|
|
||||||
|
|
||||||
Feel free to contribute.
|
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
|
|||||||
22
action.yml
22
action.yml
@@ -6,6 +6,28 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: '2019.2.11f1'
|
default: '2019.2.11f1'
|
||||||
description: 'Version of unity to use for testing the project.'
|
description: 'Version of unity to use for testing the project.'
|
||||||
|
customImage:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: 'Specific docker image that should be used for testing the project'
|
||||||
|
projectPath:
|
||||||
|
required: false
|
||||||
|
description: 'Path to the Unity project to be tested.'
|
||||||
|
testMode:
|
||||||
|
required: false
|
||||||
|
default: 'all'
|
||||||
|
description: 'The type of tests to be run by the test runner.'
|
||||||
|
artifactsPath:
|
||||||
|
required: false
|
||||||
|
default: 'artifacts'
|
||||||
|
description: 'Path where test artifacts should be stored.'
|
||||||
|
useNetworkHost:
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
description: 'Initialises Docker using the hosts network.'
|
||||||
|
customParameters:
|
||||||
|
required: false
|
||||||
|
description: 'Extra parameters to configure the Unity editor run.'
|
||||||
outputs:
|
outputs:
|
||||||
artifactsPath:
|
artifactsPath:
|
||||||
description: 'Path where the artifacts are stored'
|
description: 'Path where the artifacts are stored'
|
||||||
|
|||||||
@@ -8,6 +8,23 @@ source /steps/activate.sh
|
|||||||
source /steps/run_tests.sh
|
source /steps/run_tests.sh
|
||||||
source /steps/return_license.sh
|
source /steps/return_license.sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Instructions for debugging
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ $TEST_RUNNER_EXIT_CODE -gt 0 ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "###########################"
|
||||||
|
echo "# Failure #"
|
||||||
|
echo "###########################"
|
||||||
|
echo ""
|
||||||
|
echo "Please note that the exit code is not very descriptive."
|
||||||
|
echo "Most likely it will not help you solve the issue."
|
||||||
|
echo ""
|
||||||
|
echo "To find the reason for failure: please search for errors in the log above."
|
||||||
|
echo ""
|
||||||
|
fi;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Exit with code from the build step.
|
# Exit with code from the build step.
|
||||||
#
|
#
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ -n "$UNITY_LICENSE" ]]; then
|
if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||||
#
|
#
|
||||||
# PERSONAL LICENSE MODE
|
# PERSONAL LICENSE MODE
|
||||||
#
|
#
|
||||||
@@ -15,17 +15,21 @@ if [[ -n "$UNITY_LICENSE" ]]; then
|
|||||||
# Set the license file path
|
# Set the license file path
|
||||||
FILE_PATH=UnityLicenseFile.ulf
|
FILE_PATH=UnityLicenseFile.ulf
|
||||||
|
|
||||||
# Copy license file from Github variables
|
if [[ -n "$UNITY_LICENSE" ]]; then
|
||||||
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
|
# Copy license file from Github variables
|
||||||
|
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
|
||||||
|
elif [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||||
|
# Copy license file from file system
|
||||||
|
cat "$UNITY_LICENSE_FILE" | tr -d '\r' > $FILE_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
# Activate license
|
# Activate license
|
||||||
ACTIVATION_OUTPUT=$(xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
ACTIVATION_OUTPUT=$(unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-batchmode \
|
||||||
-batchmode \
|
-nographics \
|
||||||
-nographics \
|
-logFile /dev/stdout \
|
||||||
-logFile /dev/stdout \
|
-quit \
|
||||||
-quit \
|
-manualLicenseFile $FILE_PATH)
|
||||||
-manualLicenseFile $FILE_PATH)
|
|
||||||
|
|
||||||
# Store the exit code from the verify command
|
# Store the exit code from the verify command
|
||||||
UNITY_EXIT_CODE=$?
|
UNITY_EXIT_CODE=$?
|
||||||
@@ -58,15 +62,14 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
|
|||||||
echo "Requesting activation (professional license)"
|
echo "Requesting activation (professional license)"
|
||||||
|
|
||||||
# Activate license
|
# Activate license
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-batchmode \
|
||||||
-batchmode \
|
-nographics \
|
||||||
-nographics \
|
-logFile /dev/stdout \
|
||||||
-logFile /dev/stdout \
|
-quit \
|
||||||
-quit \
|
-serial "$UNITY_SERIAL" \
|
||||||
-serial "$UNITY_SERIAL" \
|
-username "$UNITY_EMAIL" \
|
||||||
-username "$UNITY_EMAIL" \
|
-password "$UNITY_PASSWORD"
|
||||||
-password "$UNITY_PASSWORD"
|
|
||||||
|
|
||||||
# Store the exit code from the verify command
|
# Store the exit code from the verify command
|
||||||
UNITY_EXIT_CODE=$?
|
UNITY_EXIT_CODE=$?
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ if [[ -n "$UNITY_SERIAL" ]]; then
|
|||||||
#
|
#
|
||||||
# This will return the license that is currently in use.
|
# This will return the license that is currently in use.
|
||||||
#
|
#
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-batchmode \
|
||||||
-batchmode \
|
-nographics \
|
||||||
-nographics \
|
-logFile /dev/stdout \
|
||||||
-logFile /dev/stdout \
|
-quit \
|
||||||
-quit \
|
-returnlicense
|
||||||
-returnlicense
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -74,19 +74,18 @@ if [ $EDIT_MODE = true ]; then
|
|||||||
echo "# Testing in EditMode #"
|
echo "# Testing in EditMode #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-batchmode \
|
||||||
-batchmode \
|
-logFile "$FULL_ARTIFACTS_PATH/editmode.log" \
|
||||||
-logFile "$FULL_ARTIFACTS_PATH/editmode.log" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-runTests \
|
||||||
-runTests \
|
-testPlatform editmode \
|
||||||
-testPlatform editmode \
|
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
|
||||||
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
|
$CUSTOM_PARAMETERS
|
||||||
$CUSTOM_PARAMETERS
|
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
EDIT_MODE_EXIT_CODE=$?
|
EDIT_MODE_EXIT_CODE=$?
|
||||||
|
|
||||||
# Print unity log output
|
# Print unity log output
|
||||||
cat "$FULL_ARTIFACTS_PATH/editmode.log"
|
cat "$FULL_ARTIFACTS_PATH/editmode.log"
|
||||||
|
|
||||||
@@ -112,16 +111,15 @@ if [ $PLAY_MODE = true ]; then
|
|||||||
echo "# Testing in PlayMode #"
|
echo "# Testing in PlayMode #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-batchmode \
|
||||||
-batchmode \
|
-logFile "$FULL_ARTIFACTS_PATH/playmode.log" \
|
||||||
-logFile "$FULL_ARTIFACTS_PATH/playmode.log" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-runTests \
|
||||||
-runTests \
|
-testPlatform playmode \
|
||||||
-testPlatform playmode \
|
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
|
||||||
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
|
$CUSTOM_PARAMETERS
|
||||||
$CUSTOM_PARAMETERS
|
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
PLAY_MODE_EXIT_CODE=$?
|
PLAY_MODE_EXIT_CODE=$?
|
||||||
|
|
||||||
|
|||||||
1
media/Discord-Logo.svg
Normal file
1
media/Discord-Logo.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 272.1"><style>.st0{fill:#7289DA;}</style><path class="st0" d="M142.8 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11s-4.6-11-10.2-11zM106.3 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11 .1-6.1-4.5-11-10.2-11z"/><path class="st0" d="M191.4 36.9h-134c-11.3 0-20.5 9.2-20.5 20.5v134c0 11.3 9.2 20.5 20.5 20.5h113.4l-5.3-18.3 12.8 11.8 12.1 11.1 21.6 18.7V57.4c-.1-11.3-9.3-20.5-20.6-20.5zm-38.6 129.5s-3.6-4.3-6.6-8c13.1-3.7 18.1-11.8 18.1-11.8-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.4-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.6-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.2-1.8-1-2.8-1.7-2.8-1.7s4.8 7.9 17.5 11.7c-3 3.8-6.7 8.2-6.7 8.2-22.1-.7-30.5-15.1-30.5-15.1 0-31.9 14.4-57.8 14.4-57.8 14.4-10.7 28-10.4 28-10.4l1 1.2c-18 5.1-26.2 13-26.2 13s2.2-1.2 5.9-2.8c10.7-4.7 19.2-5.9 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.5 0 0-7.9-7.5-24.9-12.6l1.4-1.6s13.7-.3 28 10.4c0 0 14.4 25.9 14.4 57.8 0-.1-8.4 14.3-30.5 15zM303.8 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1h33.2c17.8.1 34.5-8.8 34.5-29.2v-29.8c.1-20.8-16.6-29.9-34.4-29.9zm174 59.7v-30.6c0-11 19.8-13.5 25.8-2.5l18.3-7.4c-7.2-15.8-20.3-20.4-31.2-20.4-17.8 0-35.4 10.3-35.4 30.3v30.6c0 20.2 17.6 30.3 35 30.3 11.2 0 24.6-5.5 32-19.9l-19.6-9c-4.8 12.3-24.9 9.3-24.9-1.4zM417.3 113c-6.9-1.5-11.5-4-11.8-8.3.4-10.3 16.3-10.7 25.6-.8l14.7-11.3c-9.2-11.2-19.6-14.2-30.3-14.2-16.3 0-32.1 9.2-32.1 26.6 0 16.9 13 26 27.3 28.2 7.3 1 15.4 3.9 15.2 8.9-.6 9.5-20.2 9-29.1-1.8l-14.2 13.3c8.3 10.7 19.6 16.1 30.2 16.1 16.3 0 34.4-9.4 35.1-26.6 1-21.7-14.8-27.2-30.6-30.1zm-67 55.5h22.4V79.7h-22.4v88.8zM728 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1H728c17.8.1 34.5-8.8 34.5-29.2v-29.8c0-20.8-16.7-29.9-34.5-29.9zm-162.9-1.2c-18.4 0-36.7 10-36.7 30.5v30.3c0 20.3 18.4 30.5 36.9 30.5 18.4 0 36.7-10.2 36.7-30.5V109c0-20.4-18.5-30.5-36.9-30.5zm14.4 60.8c0 6.4-7.2 9.7-14.3 9.7-7.2 0-14.4-3.1-14.4-9.7V109c0-6.5 7-10 14-10 7.3 0 14.7 3.1 14.7 10v30.3zM682.4 109c-.5-20.8-14.7-29.2-33-29.2h-35.5v88.8h22.7v-28.2h4l20.6 28.2h28L665 138.1c10.7-3.4 17.4-12.7 17.4-29.1zm-32.6 12h-13.2v-20.3h13.2c14.1 0 14.1 20.3 0 20.3z"/></svg>
|
||||||
|
After Width: | Height: | Size: 2.3 KiB |
BIN
media/UnityActions-ReferenceLogo.png
Normal file
BIN
media/UnityActions-ReferenceLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
BIN
media/UnityCI-ReferenceLogo.png
Normal file
BIN
media/UnityCI-ReferenceLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
media/UnityTestRunner-Logo.png
Normal file
BIN
media/UnityTestRunner-Logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
13
package.json
13
package.json
@@ -7,6 +7,7 @@
|
|||||||
"author": "Webber <webber@takken.io>",
|
"author": "Webber <webber@takken.io>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"prebuild": "yarn",
|
||||||
"build": "ncc build src --out action --minify",
|
"build": "ncc build src --out action --minify",
|
||||||
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
@@ -14,14 +15,14 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.1",
|
"@actions/core": "^1.2.1",
|
||||||
"@actions/exec": "1.0.3",
|
"@actions/exec": "1.0.3",
|
||||||
"@actions/github": "^2.0.1"
|
"@actions/github": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "7.8.4",
|
"@babel/cli": "7.8.4",
|
||||||
"@babel/core": "7.8.4",
|
"@babel/core": "7.8.7",
|
||||||
"@babel/preset-env": "7.8.4",
|
"@babel/preset-env": "7.8.7",
|
||||||
"@zeit/ncc": "0.21.1",
|
"@zeit/ncc": "0.21.1",
|
||||||
"babel-eslint": "10.0.3",
|
"babel-eslint": "10.1.0",
|
||||||
"eslint": "6.8.0",
|
"eslint": "6.8.0",
|
||||||
"eslint-config-airbnb": "18.0.1",
|
"eslint-config-airbnb": "18.0.1",
|
||||||
"eslint-config-prettier": "6.10.0",
|
"eslint-config-prettier": "6.10.0",
|
||||||
@@ -29,11 +30,11 @@
|
|||||||
"eslint-plugin-import": "2.20.1",
|
"eslint-plugin-import": "2.20.1",
|
||||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||||
"eslint-plugin-prettier": "3.1.2",
|
"eslint-plugin-prettier": "3.1.2",
|
||||||
"eslint-plugin-react": "7.18.3",
|
"eslint-plugin-react": "7.19.0",
|
||||||
"eslint-plugin-unicorn": "16.1.1",
|
"eslint-plugin-unicorn": "16.1.1",
|
||||||
"husky": "4.2.3",
|
"husky": "4.2.3",
|
||||||
"jest": "25.1.0",
|
"jest": "25.1.0",
|
||||||
"lint-staged": "10.0.7",
|
"lint-staged": "10.0.8",
|
||||||
"lodash-es": "4.17.15",
|
"lodash-es": "4.17.15",
|
||||||
"prettier": "1.19.1"
|
"prettier": "1.19.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ async function action() {
|
|||||||
const { dockerfile, workspace, actionFolder } = Action;
|
const { dockerfile, workspace, actionFolder } = Action;
|
||||||
const {
|
const {
|
||||||
unityVersion,
|
unityVersion,
|
||||||
|
customImage,
|
||||||
projectPath,
|
projectPath,
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
|
useHostNetwork,
|
||||||
customParameters,
|
customParameters,
|
||||||
} = Input.getFromUser();
|
} = Input.getFromUser();
|
||||||
const baseImage = ImageTag.createForBase(unityVersion);
|
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
|
||||||
|
|
||||||
// Build docker image
|
// Build docker image
|
||||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
@@ -24,6 +26,7 @@ async function action() {
|
|||||||
projectPath,
|
projectPath,
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
|
useHostNetwork,
|
||||||
customParameters,
|
customParameters,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class Docker {
|
|||||||
projectPath,
|
projectPath,
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
|
useHostNetwork,
|
||||||
customParameters,
|
customParameters,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
@@ -31,6 +32,7 @@ class Docker {
|
|||||||
--workdir /github/workspace \
|
--workdir /github/workspace \
|
||||||
--rm \
|
--rm \
|
||||||
--env UNITY_LICENSE \
|
--env UNITY_LICENSE \
|
||||||
|
--env UNITY_LICENSE_FILE \
|
||||||
--env UNITY_EMAIL \
|
--env UNITY_EMAIL \
|
||||||
--env UNITY_PASSWORD \
|
--env UNITY_PASSWORD \
|
||||||
--env UNITY_SERIAL \
|
--env UNITY_SERIAL \
|
||||||
@@ -59,6 +61,7 @@ class Docker {
|
|||||||
--volume "/home/runner/work/_temp/_github_home":"/github/home" \
|
--volume "/home/runner/work/_temp/_github_home":"/github/home" \
|
||||||
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
|
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
|
||||||
--volume "${workspace}":"/github/workspace" \
|
--volume "${workspace}":"/github/workspace" \
|
||||||
|
${useHostNetwork ? '--net=host' : ''} \
|
||||||
${image}`;
|
${image}`;
|
||||||
|
|
||||||
await exec(command, null, { silent });
|
await exec(command, null, { silent });
|
||||||
|
|||||||
@@ -6,15 +6,20 @@ describe('Docker', () => {
|
|||||||
it('builds', async () => {
|
it('builds', async () => {
|
||||||
const path = Action.actionFolder;
|
const path = Action.actionFolder;
|
||||||
const dockerfile = `${path}/Dockerfile`;
|
const dockerfile = `${path}/Dockerfile`;
|
||||||
const baseImage = new ImageTag({
|
const image = new ImageTag({
|
||||||
repository: '',
|
repository: '',
|
||||||
name: 'alpine',
|
name: 'alpine',
|
||||||
version: '3',
|
version: '3',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const baseImage = {
|
||||||
|
toString: () => image.toString().slice(0, image.toString().lastIndexOf('-base-0')),
|
||||||
|
version: image.version,
|
||||||
|
};
|
||||||
|
|
||||||
const tag = await Docker.build({ path, dockerfile, baseImage }, true);
|
const tag = await Docker.build({ path, dockerfile, baseImage }, true);
|
||||||
|
|
||||||
expect(tag).toBeInstanceOf(ImageTag);
|
expect(tag).toBeInstanceOf(ImageTag);
|
||||||
expect(tag.toString()).toStrictEqual('unity-action:3');
|
expect(tag.toString()).toStrictEqual('unity-action:3-base-0');
|
||||||
}, 240000);
|
}, 240000);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { trimStart } from 'lodash-es';
|
import { trimStart } from 'lodash-es';
|
||||||
|
|
||||||
class ImageTag {
|
class ImageTag {
|
||||||
static createForBase(version) {
|
static createForBase({ version, customImage }) {
|
||||||
const repository = 'gableroux';
|
const repository = 'unityci';
|
||||||
const name = 'unity3d';
|
const name = 'editor';
|
||||||
return new this({ repository, name, version });
|
return new this({ repository, name, version, customImage });
|
||||||
}
|
}
|
||||||
|
|
||||||
static createForAction(version) {
|
static createForAction(version) {
|
||||||
@@ -13,12 +13,12 @@ class ImageTag {
|
|||||||
return new this({ repository, name, version });
|
return new this({ repository, name, version });
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor({ repository = '', name, version }) {
|
constructor({ repository = '', name, version, customImage }) {
|
||||||
if (!ImageTag.versionPattern.test(version)) {
|
if (!ImageTag.versionPattern.test(version)) {
|
||||||
throw new Error(`Invalid version "${version}".`);
|
throw new Error(`Invalid version "${version}".`);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(this, { repository, name, version });
|
Object.assign(this, { repository, name, version, customImage });
|
||||||
}
|
}
|
||||||
|
|
||||||
static get versionPattern() {
|
static get versionPattern() {
|
||||||
@@ -34,7 +34,11 @@ class ImageTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return `${this.image}:${this.tag}`;
|
if (this.customImage && this.customImage !== '') {
|
||||||
|
return this.customImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${this.image}:${this.tag}-base-0`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,18 @@ describe('UnityImageVersion', () => {
|
|||||||
|
|
||||||
describe('toString', () => {
|
describe('toString', () => {
|
||||||
it('returns the correct version', () => {
|
it('returns the correct version', () => {
|
||||||
const image = ImageTag.createForBase('2099.1.1111');
|
const image = ImageTag.createForBase({ version: '2099.1.1111' });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`gableroux/unity3d:2099.1.1111`);
|
expect(image.toString()).toStrictEqual(`unityci/editor:2099.1.1111-base-0`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns customImage if given', () => {
|
||||||
|
const image = ImageTag.createForBase({
|
||||||
|
version: '2099.1.1111',
|
||||||
|
customImage: 'unityci/editor:2099.1.1111-base-0',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(image.toString()).toStrictEqual(image.customImage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Input {
|
|||||||
const testMode = getInput('testMode') || 'all';
|
const testMode = getInput('testMode') || 'all';
|
||||||
const rawProjectPath = getInput('projectPath') || '.';
|
const rawProjectPath = getInput('projectPath') || '.';
|
||||||
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
||||||
|
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
||||||
const customParameters = getInput('customParameters') || '';
|
const customParameters = getInput('customParameters') || '';
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
@@ -33,9 +34,14 @@ class Input {
|
|||||||
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
|
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rawUseHostNetwork !== 'true' && rawUseHostNetwork !== 'false') {
|
||||||
|
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
|
||||||
|
}
|
||||||
|
|
||||||
// Sanitise input
|
// Sanitise input
|
||||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
|
|
||||||
// Return sanitised input
|
// Return sanitised input
|
||||||
return {
|
return {
|
||||||
@@ -43,6 +49,7 @@ class Input {
|
|||||||
projectPath,
|
projectPath,
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
|
useHostNetwork,
|
||||||
customParameters,
|
customParameters,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user