Add new input and basic test

pull/164/head
Aaron Trudeau 2021-10-21 00:10:08 -04:00
parent d9147cdc1d
commit 1a54f845f3
No known key found for this signature in database
GPG Key ID: 29F89A9BDAAF7BDE
7 changed files with 85 additions and 5 deletions

View File

@ -263,3 +263,44 @@ jobs:
name: Test results (combined)
path: artifacts/
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-project-with-correct-tests
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v2
with:
lfs: true
###########################
# Cache(don't use yet) #
###########################
# Configure test runner
- name: Run tests
id: editMode
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: editmode
artifactsPath: artifacts/editmode
packageMode: true
# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: Test results (edit mode)
path: ${{ steps.editMode.outputs.artifactsPath }}
retention-days: 14

View File

@ -12,7 +12,7 @@ inputs:
description: 'Specific docker image that should be used for testing the project'
projectPath:
required: false
description: 'Path to the Unity project to be tested.'
description: 'Path to the Unity project (or, in package mode, the path to the package directory) to be tested.'
testMode:
required: false
default: 'all'
@ -40,6 +40,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. Not needed for packages located within a Unity Project.'
outputs:
artifactsPath:
description: 'Path where the artifacts are stored'

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,5 @@
#!/usr/bin/env bash
echo "TEMP should print the jq version"
jq --version
#
# Set and display project path
#
@ -10,6 +7,33 @@ jq --version
UNITY_PROJECT_PATH="$GITHUB_WORKSPACE/$PROJECT_PATH"
echo "Using project path \"$UNITY_PROJECT_PATH\"."
#
# Create an empty project for testing if in package mode
#
if [ "$PACKAGE_MODE" = "true" ]; then
echo "Running tests on a Unity package rather than a Unity project."
echo ""
echo "###########################"
echo "# Package Folder #"
echo "###########################"
echo ""
cat UNITY_PROJECT_PATH
echo "Creating an empty Unity project to add the package to."
# unity-editor \
# -batchMode \
# -createProject "./TempProject" \
# -quit
jq --version
# UNITY_PROJECT_PATH="./TempProject"
fi
#
# Set and display the artifacts path
#

View File

@ -16,6 +16,7 @@ async function action() {
sshAgent,
githubToken,
checkName,
packageMode,
} = Input.getFromUser();
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
@ -33,6 +34,7 @@ async function action() {
useHostNetwork,
customParameters,
sshAgent,
packageMode,
githubToken,
});
} finally {

View File

@ -27,6 +27,7 @@ class Docker {
useHostNetwork,
customParameters,
sshAgent,
packageMode,
githubToken,
} = parameters;
@ -43,6 +44,7 @@ class Docker {
--env TEST_MODE="${testMode}" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env PACKAGE_MODE="${packageMode}" \
--env GITHUB_REF \
--env GITHUB_SHA \
--env GITHUB_REPOSITORY \

View File

@ -25,6 +25,7 @@ class Input {
const sshAgent = getInput('sshAgent') || '';
const githubToken = getInput('githubToken') || '';
const checkName = getInput('checkName') || 'Test Results';
const rawPackageMode = getInput('packageMode') || 'false';
// Validate input
if (!includes(this.testModes, testMode)) {
@ -43,12 +44,17 @@ class Input {
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
}
if (rawPackageMode !== 'true' && rawPackageMode !== 'false') {
throw new Error(`Invalid packageMode "${rawPackageMode}"`);
}
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true';
const unityVersion =
rawUnityVersion === 'auto' ? UnityVersionParser.read(projectPath) : rawUnityVersion;
const packageMode = rawPackageMode === 'true';
// Return sanitised input
return {
@ -62,6 +68,7 @@ class Input {
sshAgent,
githubToken,
checkName,
packageMode,
};
}
}