fix: broken husky hook

pull/179/head
Webber 2022-04-03 17:17:38 +02:00
parent 301fbaf78d
commit 8103154372
3 changed files with 57 additions and 48 deletions

View File

@ -8,4 +8,6 @@ fi
yarn lint-staged
yarn lint
yarn test
yarn build
git add dist

77
dist/index.js generated vendored
View File

@ -42,15 +42,13 @@ function run() {
try {
model_1.Action.checkCompatibility();
const { workspace, actionFolder } = model_1.Action;
const { unityVersion, customImage, projectPath, customParameters, testMode, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, } = model_1.Input.getFromUser();
const baseImage = new model_1.ImageTag({ editorVersion: unityVersion, customImage });
const runnerTempPath = process.env.RUNNER_TEMP;
const { editorVersion, customImage, projectPath, customParameters, testMode, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, } = model_1.Input.getFromUser();
const baseImage = new model_1.ImageTag({ editorVersion, customImage });
const runnerTemporaryPath = process.env.RUNNER_TEMP;
try {
// Build docker image
// Run docker image
yield model_1.Docker.run(baseImage, {
actionFolder,
unityVersion,
editorVersion,
workspace,
projectPath,
customParameters,
@ -60,11 +58,10 @@ function run() {
sshAgent,
gitPrivateToken,
githubToken,
runnerTempPath,
runnerTemporaryPath,
});
}
finally {
// Set output
yield model_1.Output.setArtifactsPath(artifactsPath);
}
if (githubToken) {
@ -155,11 +152,11 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
const Docker = {
run(image, parameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () {
const { actionFolder, unityVersion, workspace, projectPath, customParameters, testMode, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTempPath, } = parameters;
const githubHome = path_1.default.join(runnerTempPath, '_github_home');
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters;
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
if (!(0, fs_1.existsSync)(githubHome))
(0, fs_1.mkdirSync)(githubHome);
const githubWorkflow = path_1.default.join(runnerTempPath, '_github_workflow');
const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow');
if (!(0, fs_1.existsSync)(githubWorkflow))
(0, fs_1.mkdirSync)(githubWorkflow);
const command = `docker run \
@ -170,7 +167,7 @@ const Docker = {
--env UNITY_EMAIL \
--env UNITY_PASSWORD \
--env UNITY_SERIAL \
--env UNITY_VERSION="${unityVersion}" \
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_MODE="${testMode}" \
@ -224,22 +221,25 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const platform_1 = __importDefault(__nccwpck_require__(9707));
class ImageTag {
constructor(imageProperties) {
const { repository = 'unityci', name = 'editor', version = '2019.2.11f1', platform = platform_1.default.types.StandaloneLinux64, customImage, } = imageProperties;
if (!ImageTag.versionPattern.test(version)) {
throw new Error(`Invalid version "${version}".`);
const { editorVersion = '2019.2.11f1', targetPlatform = platform_1.default.types.StandaloneLinux64, customImage, } = imageProperties;
if (!ImageTag.versionPattern.test(editorVersion)) {
throw new Error(`Invalid version "${editorVersion}".`);
}
const builderPlatform = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
this.repository = repository;
this.name = name;
this.version = version;
this.platform = platform;
this.builderPlatform = builderPlatform;
// Either
this.customImage = customImage;
// Or
this.repository = 'unityci';
this.name = 'editor';
this.editorVersion = editorVersion;
this.targetPlatform = targetPlatform;
this.targetPlatformSuffix = ImageTag.getTargetPlatformSuffix(targetPlatform, editorVersion);
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefix(process.platform);
this.imageRollingVersion = 1;
}
static get versionPattern() {
return /^20\d{2}\.\d\.\w{3,4}|3$/;
}
static get imageSuffixes() {
static get targetPlatformSuffixes() {
return {
generic: '',
webgl: 'webgl',
@ -252,11 +252,19 @@ class ImageTag {
facebook: 'facebook',
};
}
static getTargetPlatformToImageSuffixMap(platform, version) {
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } = ImageTag.imageSuffixes;
const [major, minor] = version.split('.').map(digit => Number(digit));
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
static getImagePlatformPrefix(platform) {
switch (platform) {
case 'linux':
return 'ubuntu';
default:
throw new Error('The Operating System of this runner is not yet supported.');
}
}
static getTargetPlatformSuffix(targetPlatform, editorVersion) {
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } = ImageTag.targetPlatformSuffixes;
const [major, minor] = editorVersion.split('.').map(digit => Number(digit));
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
switch (targetPlatform) {
case platform_1.default.types.StandaloneOSX:
return mac;
case platform_1.default.types.StandaloneWindows:
@ -303,22 +311,21 @@ class ImageTag {
default:
throw new Error(`
Platform must be one of the ones described in the documentation.
"${platform}" is currently not supported.`);
"${targetPlatform}" is currently not supported.`);
}
}
get tag() {
return `${this.editorVersion}-${this.targetPlatformSuffix}`.replace(/-+$/, '');
const versionAndTarget = `${this.editorVersion}-${this.targetPlatformSuffix}`.replace(/-+$/, '');
return `${this.imagePlatformPrefix}-${versionAndTarget}-${this.imageRollingVersion}`;
}
get image() {
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
}
toString() {
const { image, tag, customImage } = this;
if (customImage && customImage !== '') {
if (customImage)
return customImage;
}
const dockerRepoVersion = 0;
return `${image}:${tag}-${dockerRepoVersion}`;
return `${image}:${tag}`;
}
}
exports["default"] = ImageTag;
@ -373,7 +380,7 @@ const Input = {
},
getFromUser() {
// Input variables specified in workflow using "with" prop.
const rawUnityVersion = (0, core_1.getInput)('unityVersion') || 'auto';
const unityVersion = (0, core_1.getInput)('unityVersion') || 'auto';
const customImage = (0, core_1.getInput)('customImage') || '';
const rawProjectPath = (0, core_1.getInput)('projectPath') || '.';
const customParameters = (0, core_1.getInput)('customParameters') || '';
@ -401,10 +408,10 @@ const Input = {
const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true';
const unityVersion = rawUnityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : rawUnityVersion;
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
// Return sanitised input
return {
unityVersion,
editorVersion,
customImage,
projectPath,
customParameters,

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long