Add custom parameters

pull/11/head
Webber 2020-01-29 23:54:44 +01:00 committed by Webber Takken
parent 686f633329
commit 3ccd77fd44
6 changed files with 71 additions and 34 deletions

View File

@ -1,25 +1,26 @@
# Unity - Test runner
[![Actions status](https://github.com/webbertakken/unity-test-runner/workflows/Actions%20%F0%9F%98%8E/badge.svg)](https://github.com/webbertakken/unity-test-runner/actions?query=branch%3Amaster+workflow%3A%22Actions+%F0%9F%98%8E%22)
---
GitHub Action to
[run tests](https://github.com/marketplace/actions/unity-test-runner)
for any Unity project.
GitHub Action to
[run tests](https://github.com/marketplace/actions/unity-test-runner)
for any Unity project.
Part of the
[Unity Actions](https://github.com/webbertakken/unity-actions)
Part of the
[Unity Actions](https://github.com/webbertakken/unity-actions)
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)
action.
## Documentation
See the
See the
[Unity Actions](https://github.com/webbertakken/unity-actions)
collection repository for workflow documentation and reference implementation.
@ -40,42 +41,63 @@ jobs:
Configure the test runner as follows:
```yaml
# Configure test runner
- name: Run tests
id: myTestStep
uses: webbertakken/unity-test-runner@v1.1
env:
# Choose: "all", "playmode", "editmode"
TEST_MODE: all
# Optional: Path to your project, leave blank for "./"
PROJECT_PATH: relative/path/to/your/project
# Configure test runner
- name: Run tests
id: myTestStep
uses: webbertakken/unity-test-runner@v1.1
env:
# Choose: "all", "playmode", "editmode"
TEST_MODE: all
# Optional: Artifacts path, leave blank for "artifacts"
ARTIFACTS_PATH: store/artifacts/here
# Optional: Path to your project, leave blank for "./"
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:
```yaml
# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v1
with:
name: Test results
path: ${{ steps.myTestStep.outputs.artifactsPath }}
# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v1
with:
name: Test results
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.
## More actions
Visit
[Unity Actions](https://github.com/webbertakken/unity-actions)
Visit
[Unity Actions](https://github.com/webbertakken/unity-actions)
to find related actions for Unity.
Feel free to contribute.
## Licence
## Licence
[MIT](./LICENSE)

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,11 @@ echo "Using project path \"$UNITY_PROJECT_PATH\"."
echo "Using build path \"$ARTIFACTS_PATH\" to save test results."
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
#
# Display custom parameters
#
echo "Using custom parameters \"$CUSTOM_PARAMETERS\"."
# Set the modes for testing
case $TEST_MODE in
editmode)
@ -76,7 +81,8 @@ if [ $EDIT_MODE = true ]; then
-projectPath "$UNITY_PROJECT_PATH" \
-runTests \
-testPlatform editmode \
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml"
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
"$CUSTOM_PARAMETERS"
# Catch exit code
EDIT_MODE_EXIT_CODE=$?

View File

@ -5,14 +5,20 @@ async function action() {
Action.checkCompatibility();
const { dockerfile, workspace, actionFolder } = Action;
const { unityVersion, projectPath, artifactsPath } = Input.getFromUser();
const { unityVersion, projectPath, artifactsPath, customParameters } = Input.getFromUser();
const baseImage = ImageTag.createForBase(unityVersion);
// Build docker image
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
// Run docker image
await Docker.run(actionImage, { workspace, unityVersion, projectPath, artifactsPath });
await Docker.run(actionImage, {
workspace,
unityVersion,
projectPath,
artifactsPath,
customParameters,
});
// Set output
await Output.setArtifactsPath(artifactsPath);

View File

@ -18,7 +18,7 @@ class Docker {
}
static async run(image, parameters, silent = false) {
const { unityVersion, workspace, projectPath, artifactsPath } = parameters;
const { unityVersion, workspace, projectPath, artifactsPath, customParameters } = parameters;
const command = `docker run \
--workdir /github/workspace \
@ -29,7 +29,8 @@ class Docker {
--env UNITY_SERIAL \
--env UNITY_VERSION=${unityVersion} \
--env PROJECT_PATH=${projectPath} \
--env ARTIFACTS_PATH=${artifactsPath}
--env ARTIFACTS_PATH=${artifactsPath} \
--env CUSTOM_PARAMETERS=${customParameters} \
--env HOME=/github/home \
--env GITHUB_REF \
--env GITHUB_SHA \

View File

@ -18,6 +18,7 @@ class Input {
const testMode = getInput('testMode') || 'all';
const rawProjectPath = getInput('testMode') || '.';
const rawArtifactsPath = getInput('testMode') || 'artifacts';
const customParameters = getInput('customParameters') || '';
// Validate input
if (!includes(this.testModes, testMode)) {
@ -42,6 +43,7 @@ class Input {
projectPath,
testMode,
artifactsPath,
customParameters,
};
}
}