Add custom parameters
parent
686f633329
commit
3ccd77fd44
78
README.md
78
README.md
|
@ -1,25 +1,26 @@
|
||||||
# Unity - Test runner
|
# Unity - Test runner
|
||||||
|
|
||||||
[](https://github.com/webbertakken/unity-test-runner/actions?query=branch%3Amaster+workflow%3A%22Actions+%F0%9F%98%8E%22)
|
[](https://github.com/webbertakken/unity-test-runner/actions?query=branch%3Amaster+workflow%3A%22Actions+%F0%9F%98%8E%22)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
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
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||||
collection.
|
collection.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This is a recommended step to prepare your pipeline for using the
|
This is a recommended step to prepare your pipeline for using the
|
||||||
[Build](https://github.com/webbertakken/unity-actions#build)
|
[Build](https://github.com/webbertakken/unity-actions#build)
|
||||||
action.
|
action.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
See the
|
See the
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||||
collection repository for workflow documentation and reference implementation.
|
collection repository for workflow documentation and reference implementation.
|
||||||
|
|
||||||
|
@ -40,42 +41,63 @@ jobs:
|
||||||
Configure the test runner as follows:
|
Configure the test runner as follows:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Configure test runner
|
# Configure test runner
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
id: myTestStep
|
id: myTestStep
|
||||||
uses: webbertakken/unity-test-runner@v1.1
|
uses: webbertakken/unity-test-runner@v1.1
|
||||||
env:
|
env:
|
||||||
# Choose: "all", "playmode", "editmode"
|
# Choose: "all", "playmode", "editmode"
|
||||||
TEST_MODE: all
|
TEST_MODE: all
|
||||||
|
|
||||||
# Optional: Path to your project, leave blank for "./"
|
|
||||||
PROJECT_PATH: relative/path/to/your/project
|
|
||||||
|
|
||||||
# Optional: Artifacts path, leave blank for "artifacts"
|
# Optional: Path to your project, leave blank for "./"
|
||||||
ARTIFACTS_PATH: store/artifacts/here
|
PROJECT_PATH: relative/path/to/your/project
|
||||||
|
|
||||||
|
# Optional: Artifacts path, leave blank for "artifacts"
|
||||||
|
ARTIFACTS_PATH: store/artifacts/here
|
||||||
```
|
```
|
||||||
|
|
||||||
You use the id to **upload the artifacts** like so:
|
You use the id to **upload the artifacts** like so:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Upload artifacts
|
# Upload artifacts
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Test results
|
name: Test results
|
||||||
path: ${{ steps.myTestStep.outputs.artifactsPath }}
|
path: ${{ steps.myTestStep.outputs.artifactsPath }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### customParameters
|
||||||
|
|
||||||
|
Custom parameters to configure the test run.
|
||||||
|
|
||||||
|
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:** ""_
|
||||||
|
|
||||||
|
#### Save your workflow
|
||||||
|
|
||||||
Commit and push your workflow definition.
|
Commit and push your workflow definition.
|
||||||
|
|
||||||
## More actions
|
## More actions
|
||||||
|
|
||||||
Visit
|
Visit
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||||
to find related actions for Unity.
|
to find related actions for Unity.
|
||||||
|
|
||||||
Feel free to contribute.
|
Feel free to contribute.
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
[MIT](./LICENSE)
|
[MIT](./LICENSE)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,6 +14,11 @@ echo "Using project path \"$UNITY_PROJECT_PATH\"."
|
||||||
echo "Using build path \"$ARTIFACTS_PATH\" to save test results."
|
echo "Using build path \"$ARTIFACTS_PATH\" to save test results."
|
||||||
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
||||||
|
|
||||||
|
#
|
||||||
|
# Display custom parameters
|
||||||
|
#
|
||||||
|
echo "Using custom parameters \"$CUSTOM_PARAMETERS\"."
|
||||||
|
|
||||||
# Set the modes for testing
|
# Set the modes for testing
|
||||||
case $TEST_MODE in
|
case $TEST_MODE in
|
||||||
editmode)
|
editmode)
|
||||||
|
@ -76,7 +81,8 @@ if [ $EDIT_MODE = true ]; then
|
||||||
-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"
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
EDIT_MODE_EXIT_CODE=$?
|
EDIT_MODE_EXIT_CODE=$?
|
||||||
|
|
10
src/index.js
10
src/index.js
|
@ -5,14 +5,20 @@ async function action() {
|
||||||
Action.checkCompatibility();
|
Action.checkCompatibility();
|
||||||
|
|
||||||
const { dockerfile, workspace, actionFolder } = Action;
|
const { dockerfile, workspace, actionFolder } = Action;
|
||||||
const { unityVersion, projectPath, artifactsPath } = Input.getFromUser();
|
const { unityVersion, projectPath, artifactsPath, customParameters } = Input.getFromUser();
|
||||||
const baseImage = ImageTag.createForBase(unityVersion);
|
const baseImage = ImageTag.createForBase(unityVersion);
|
||||||
|
|
||||||
// Build docker image
|
// Build docker image
|
||||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
|
|
||||||
// Run docker image
|
// Run docker image
|
||||||
await Docker.run(actionImage, { workspace, unityVersion, projectPath, artifactsPath });
|
await Docker.run(actionImage, {
|
||||||
|
workspace,
|
||||||
|
unityVersion,
|
||||||
|
projectPath,
|
||||||
|
artifactsPath,
|
||||||
|
customParameters,
|
||||||
|
});
|
||||||
|
|
||||||
// Set output
|
// Set output
|
||||||
await Output.setArtifactsPath(artifactsPath);
|
await Output.setArtifactsPath(artifactsPath);
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Docker {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async run(image, parameters, silent = false) {
|
static async run(image, parameters, silent = false) {
|
||||||
const { unityVersion, workspace, projectPath, artifactsPath } = parameters;
|
const { unityVersion, workspace, projectPath, artifactsPath, customParameters } = parameters;
|
||||||
|
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
--workdir /github/workspace \
|
--workdir /github/workspace \
|
||||||
|
@ -29,7 +29,8 @@ class Docker {
|
||||||
--env UNITY_SERIAL \
|
--env UNITY_SERIAL \
|
||||||
--env UNITY_VERSION=${unityVersion} \
|
--env UNITY_VERSION=${unityVersion} \
|
||||||
--env PROJECT_PATH=${projectPath} \
|
--env PROJECT_PATH=${projectPath} \
|
||||||
--env ARTIFACTS_PATH=${artifactsPath}
|
--env ARTIFACTS_PATH=${artifactsPath} \
|
||||||
|
--env CUSTOM_PARAMETERS=${customParameters} \
|
||||||
--env HOME=/github/home \
|
--env HOME=/github/home \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_SHA \
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Input {
|
||||||
const testMode = getInput('testMode') || 'all';
|
const testMode = getInput('testMode') || 'all';
|
||||||
const rawProjectPath = getInput('testMode') || '.';
|
const rawProjectPath = getInput('testMode') || '.';
|
||||||
const rawArtifactsPath = getInput('testMode') || 'artifacts';
|
const rawArtifactsPath = getInput('testMode') || 'artifacts';
|
||||||
|
const customParameters = getInput('customParameters') || '';
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!includes(this.testModes, testMode)) {
|
if (!includes(this.testModes, testMode)) {
|
||||||
|
@ -42,6 +43,7 @@ class Input {
|
||||||
projectPath,
|
projectPath,
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
|
customParameters,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue