mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-02-05 12:36:37 +08:00
Compare commits
5 Commits
v1.7
...
v2.0-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31cd755121 | ||
|
|
679222c549 | ||
|
|
29899d84e8 | ||
|
|
7d26e264b9 | ||
|
|
bac0f97d2f |
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'
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -24,13 +24,12 @@ if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
|||||||
fi
|
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=$?
|
||||||
@@ -63,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=$?
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +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,
|
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 });
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user