Compare commits

..

5 Commits

Author SHA1 Message Date
Devashish Lal
31cd755121 docker repo migrated (#77) 2020-11-26 18:19:17 +01:00
mob-sakai
679222c549 Update action.yml
Co-authored-by: Webber Takken <webber@takken.io>
2020-11-26 14:15:18 +01:00
mob-sakai
29899d84e8 feat: support custom image 2020-11-26 14:15:18 +01:00
Webber Takken
7d26e264b9 Switch to British english. 2020-11-10 18:18:18 +01:00
David LeGare
bac0f97d2f Add all parameters to action.yml
The added parameters were already supported but weren't listed, resulting in warnings for projects that use those parameters.
2020-11-10 18:18:18 +01:00
9 changed files with 93 additions and 57 deletions

View File

@@ -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

View File

@@ -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=$?

View File

@@ -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

View File

@@ -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=$?

View File

@@ -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 });

View File

@@ -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);
}); });

View File

@@ -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`;
} }
} }

View File

@@ -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);
}); });
}); });
}); });