run yarn build
parent
0061df2fca
commit
8bed00016b
|
@ -42,7 +42,7 @@ function run() {
|
||||||
try {
|
try {
|
||||||
model_1.Action.checkCompatibility();
|
model_1.Action.checkCompatibility();
|
||||||
const { workspace, actionFolder } = model_1.Action;
|
const { workspace, actionFolder } = model_1.Action;
|
||||||
const { editorVersion, customImage, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, chownFilesTo, } = model_1.Input.getFromUser();
|
const { editorVersion, customImage, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, packageMode, packageName, chownFilesTo, } = model_1.Input.getFromUser();
|
||||||
const baseImage = new model_1.ImageTag({ editorVersion, customImage });
|
const baseImage = new model_1.ImageTag({ editorVersion, customImage });
|
||||||
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
||||||
try {
|
try {
|
||||||
|
@ -57,6 +57,8 @@ function run() {
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
packageMode,
|
||||||
|
packageName,
|
||||||
gitPrivateToken,
|
gitPrivateToken,
|
||||||
githubToken,
|
githubToken,
|
||||||
runnerTemporaryPath,
|
runnerTemporaryPath,
|
||||||
|
@ -170,7 +172,7 @@ const Docker = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getLinuxCommand(image, parameters) {
|
getLinuxCommand(image, parameters) {
|
||||||
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, chownFilesTo, } = parameters;
|
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, packageMode, packageName, gitPrivateToken, githubToken, runnerTemporaryPath, chownFilesTo, } = parameters;
|
||||||
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
||||||
if (!(0, fs_1.existsSync)(githubHome))
|
if (!(0, fs_1.existsSync)(githubHome))
|
||||||
(0, fs_1.mkdirSync)(githubHome);
|
(0, fs_1.mkdirSync)(githubHome);
|
||||||
|
@ -193,6 +195,8 @@ const Docker = {
|
||||||
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
||||||
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
||||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||||
|
--env PACKAGE_MODE="${packageMode}" \
|
||||||
|
--env PACKAGE_NAME="${packageName}" \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_SHA \
|
||||||
--env GITHUB_REPOSITORY \
|
--env GITHUB_REPOSITORY \
|
||||||
|
@ -224,7 +228,7 @@ const Docker = {
|
||||||
/bin/bash -c /entrypoint.sh`;
|
/bin/bash -c /entrypoint.sh`;
|
||||||
},
|
},
|
||||||
getWindowsCommand(image, parameters) {
|
getWindowsCommand(image, parameters) {
|
||||||
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, chownFilesTo, } = parameters;
|
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, packageMode, packageName, gitPrivateToken, githubToken, runnerTemporaryPath, chownFilesTo, } = parameters;
|
||||||
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
||||||
if (!(0, fs_1.existsSync)(githubHome))
|
if (!(0, fs_1.existsSync)(githubHome))
|
||||||
(0, fs_1.mkdirSync)(githubHome);
|
(0, fs_1.mkdirSync)(githubHome);
|
||||||
|
@ -247,6 +251,8 @@ const Docker = {
|
||||||
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
||||||
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
||||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||||
|
--env PACKAGE_MODE="${packageMode}" \
|
||||||
|
--env PACKAGE_NAME="${packageName}" \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_SHA \
|
||||||
--env GITHUB_REPOSITORY \
|
--env GITHUB_REPOSITORY \
|
||||||
|
@ -457,6 +463,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const unity_version_parser_1 = __importDefault(__nccwpck_require__(7049));
|
const unity_version_parser_1 = __importDefault(__nccwpck_require__(7049));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const core_1 = __nccwpck_require__(2186);
|
const core_1 = __nccwpck_require__(2186);
|
||||||
const Input = {
|
const Input = {
|
||||||
get testModes() {
|
get testModes() {
|
||||||
|
@ -466,6 +473,41 @@ const Input = {
|
||||||
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?[\w~]+([ _-]?[\w~]+)*\/?)*$/);
|
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?[\w~]+([ _-]?[\w~]+)*\/?)*$/);
|
||||||
return validFolderName.test(folderName);
|
return validFolderName.test(folderName);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* When in package mode, we need to scrape the package's name from its package.json file
|
||||||
|
*/
|
||||||
|
getPackageNameFromPackageJson(packagePath) {
|
||||||
|
const packageJsonPath = `${packagePath}/package.json`;
|
||||||
|
if (!fs_1.default.existsSync(packageJsonPath)) {
|
||||||
|
throw new Error(`Invalid projectPath - Cannot find package.json at ${packageJsonPath}`);
|
||||||
|
}
|
||||||
|
let packageJson;
|
||||||
|
try {
|
||||||
|
packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath).toString());
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof SyntaxError) {
|
||||||
|
throw new SyntaxError(`Unable to parse package.json contents as JSON - ${error.message}`);
|
||||||
|
}
|
||||||
|
throw new Error(`Unable to parse package.json contents as JSON - unknown error ocurred`);
|
||||||
|
}
|
||||||
|
const rawPackageName = packageJson.name;
|
||||||
|
if (typeof rawPackageName !== 'string') {
|
||||||
|
throw new TypeError(`Unable to parse package name from package.json - package name should be string, but was ${typeof rawPackageName}`);
|
||||||
|
}
|
||||||
|
if (rawPackageName.length === 0) {
|
||||||
|
throw new Error(`Package name from package.json is a string, but is empty`);
|
||||||
|
}
|
||||||
|
return rawPackageName;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* When in package mode, we need to ensure that the Tests folder is present
|
||||||
|
*/
|
||||||
|
verifyTestsFolderIsPresent(packagePath) {
|
||||||
|
if (!fs_1.default.existsSync(`${packagePath}/Tests`)) {
|
||||||
|
throw new Error(`Invalid projectPath - Cannot find package tests folder at ${packagePath}/Tests`);
|
||||||
|
}
|
||||||
|
},
|
||||||
getFromUser() {
|
getFromUser() {
|
||||||
// Input variables specified in workflow using "with" prop.
|
// Input variables specified in workflow using "with" prop.
|
||||||
const unityVersion = (0, core_1.getInput)('unityVersion') || 'auto';
|
const unityVersion = (0, core_1.getInput)('unityVersion') || 'auto';
|
||||||
|
@ -480,6 +522,8 @@ const Input = {
|
||||||
const gitPrivateToken = (0, core_1.getInput)('gitPrivateToken') || '';
|
const gitPrivateToken = (0, core_1.getInput)('gitPrivateToken') || '';
|
||||||
const githubToken = (0, core_1.getInput)('githubToken') || '';
|
const githubToken = (0, core_1.getInput)('githubToken') || '';
|
||||||
const checkName = (0, core_1.getInput)('checkName') || 'Test Results';
|
const checkName = (0, core_1.getInput)('checkName') || 'Test Results';
|
||||||
|
const rawPackageMode = (0, core_1.getInput)('packageMode') || 'false';
|
||||||
|
let packageName = '';
|
||||||
const chownFilesTo = (0, core_1.getInput)('chownFilesTo') || '';
|
const chownFilesTo = (0, core_1.getInput)('chownFilesTo') || '';
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!this.testModes.includes(testMode)) {
|
if (!this.testModes.includes(testMode)) {
|
||||||
|
@ -494,8 +538,19 @@ const Input = {
|
||||||
if (rawUseHostNetwork !== 'true' && rawUseHostNetwork !== 'false') {
|
if (rawUseHostNetwork !== 'true' && rawUseHostNetwork !== 'false') {
|
||||||
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
|
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
|
||||||
}
|
}
|
||||||
// Sanitise input
|
if (rawPackageMode !== 'true' && rawPackageMode !== 'false') {
|
||||||
|
throw new Error(`Invalid packageMode "${rawPackageMode}"`);
|
||||||
|
}
|
||||||
|
// sanitize packageMode input and projectPath input since they are needed
|
||||||
|
// for input validation
|
||||||
|
const packageMode = rawPackageMode === 'true';
|
||||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||||
|
// if in package mode, attempt to get the package's name, and ensure tests are present
|
||||||
|
if (packageMode) {
|
||||||
|
packageName = this.getPackageNameFromPackageJson(projectPath);
|
||||||
|
this.verifyTestsFolderIsPresent(projectPath);
|
||||||
|
}
|
||||||
|
// Sanitise other input
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
const useHostNetwork = rawUseHostNetwork === 'true';
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
|
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
|
||||||
|
@ -513,6 +568,8 @@ const Input = {
|
||||||
gitPrivateToken,
|
gitPrivateToken,
|
||||||
githubToken,
|
githubToken,
|
||||||
checkName,
|
checkName,
|
||||||
|
packageMode,
|
||||||
|
packageName,
|
||||||
chownFilesTo,
|
chownFilesTo,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue