unity-test-runner/src/model/input.ts

168 lines
5.6 KiB
TypeScript
Raw Normal View History

import UnityVersionParser from './unity-version-parser';
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
import fs from 'fs';
import { getInput } from '@actions/core';
2020-01-29 21:22:26 +00:00
const Input = {
get testModes() {
return ['all', 'playmode', 'editmode', 'standalone'];
},
2020-01-29 21:22:26 +00:00
isValidFolderName(folderName) {
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?[\w~]+([ _-]?[\w~]+)*\/?)*$/);
2020-01-29 22:42:41 +00:00
return validFolderName.test(folderName);
},
2020-01-29 22:42:41 +00:00
isValidGlobalFolderName(folderName) {
const validFolderName = new RegExp(/^(\.|\.\/|\/)?(\.?[\w~]+([ _-]?[\w~]+)*\/?)*$/);
return validFolderName.test(folderName);
},
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
/**
* 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.existsSync(packageJsonPath)) {
throw new Error(`Invalid projectPath - Cannot find package.json at ${packageJsonPath}`);
}
let packageJson;
try {
packageJson = JSON.parse(fs.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.existsSync(`${packagePath}/Tests`)) {
throw new Error(
`Invalid projectPath - Cannot find package tests folder at ${packagePath}/Tests`,
);
}
},
getFromUser() {
2020-01-29 21:22:26 +00:00
// Input variables specified in workflow using "with" prop.
const unityVersion = getInput('unityVersion') || 'auto';
const customImage = getInput('customImage') || '';
2020-01-30 07:51:15 +00:00
const rawProjectPath = getInput('projectPath') || '.';
const unityLicensingServer = getInput('unityLicensingServer') || '';
2022-01-01 20:38:47 +00:00
const customParameters = getInput('customParameters') || '';
const testMode = (getInput('testMode') || 'all').toLowerCase();
const coverageOptions = getInput('coverageOptions') || '';
2020-01-30 07:51:15 +00:00
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
2020-04-01 20:24:13 +00:00
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
const sshAgent = getInput('sshAgent') || '';
const rawSshPublicKeysDirectoryPath = getInput('sshPublicKeysDirectoryPath') || '';
2022-01-01 20:38:47 +00:00
const gitPrivateToken = getInput('gitPrivateToken') || '';
const githubToken = getInput('githubToken') || '';
const checkName = getInput('checkName') || 'Test Results';
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
const rawPackageMode = getInput('packageMode') || 'false';
let packageName = '';
const chownFilesTo = getInput('chownFilesTo') || '';
2020-01-29 21:22:26 +00:00
// Validate input
if (!this.testModes.includes(testMode)) {
2020-01-29 21:22:26 +00:00
throw new Error(`Invalid testMode ${testMode}`);
}
2020-01-29 22:42:41 +00:00
if (!this.isValidFolderName(rawProjectPath)) {
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
}
2022-01-01 20:38:47 +00:00
if (!this.isValidFolderName(rawArtifactsPath)) {
throw new Error(`Invalid artifactsPath "${rawArtifactsPath}"`);
}
if (!this.isValidGlobalFolderName(rawSshPublicKeysDirectoryPath)) {
throw new Error(`Invalid sshPublicKeysDirectoryPath "${rawSshPublicKeysDirectoryPath}"`);
}
2020-04-01 20:24:13 +00:00
if (rawUseHostNetwork !== 'true' && rawUseHostNetwork !== 'false') {
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
}
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
if (rawPackageMode !== 'true' && rawPackageMode !== 'false') {
throw new Error(`Invalid packageMode "${rawPackageMode}"`);
}
if (rawSshPublicKeysDirectoryPath !== '' && sshAgent === '') {
throw new Error(
'sshPublicKeysDirectoryPath is set, but sshAgent is not set. sshPublicKeysDirectoryPath is useful only when using sshAgent.',
);
}
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
// sanitize packageMode input and projectPath input since they are needed
// for input validation
const packageMode = rawPackageMode === 'true';
2020-01-29 21:22:26 +00:00
const projectPath = rawProjectPath.replace(/\/$/, '');
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
// if in package mode, attempt to get the package's name, and ensure tests are present
if (packageMode) {
if (unityVersion === 'auto') {
throw new Error(
'Package Mode is enabled, but unityVersion is set to "auto". unityVersion must manually be set in Package Mode.',
);
}
packageName = this.getPackageNameFromPackageJson(projectPath);
this.verifyTestsFolderIsPresent(projectPath);
}
// Sanitise other input
2020-01-29 21:22:26 +00:00
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const sshPublicKeysDirectoryPath = rawSshPublicKeysDirectoryPath.replace(/\/$/, '');
2020-04-01 20:24:13 +00:00
const useHostNetwork = rawUseHostNetwork === 'true';
const editorVersion =
unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion;
2020-01-29 21:22:26 +00:00
// Return sanitised input
return {
editorVersion,
customImage,
2020-01-29 21:22:26 +00:00
projectPath,
2022-01-01 20:38:47 +00:00
customParameters,
2020-01-29 21:22:26 +00:00
testMode,
coverageOptions,
2020-01-29 21:22:26 +00:00
artifactsPath,
2020-04-01 20:24:13 +00:00
useHostNetwork,
sshAgent,
sshPublicKeysDirectoryPath,
2022-01-01 20:38:47 +00:00
gitPrivateToken,
githubToken,
checkName,
Add Feature to test Unity Packages (#164) * (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit 22f74ebca711c6c66d7b9d217954a19edc7db5fb. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit 6aa7a6f44365495960f1e470e9fcf90f369683f0. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commit c0bb008b2c9740559dec0fb7374428d45ff46df8. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commit bd35ac8f6f48c7c01456e70855d4109dba8cffdf. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit 95722dcab432168201bf69e20ad7bf8b8a48d3fa. * Revert "Revert "remove jq install"" This reverts commit e3bac048b1dfb51270b469c0a5e649e9c7a8acce. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commit db9c07da38fd4cdf1f738696766fda1706e8e8e9. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit 4b2c03069d3aacf4b3fc683b70dcd5019778a5c7. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit 411ec51817f805f1177681a619e51384ff66e808. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit 4f12d83889dbbfe24d1c13ba2e1d95e3aaff9693. * Revert "fix improper bash "if" formatting" This reverts commit acb975bcea47fc55f2cb6192b0adfc8640379143. * Revert "fix false positive activation file detection" This reverts commit 580c9c14a019bc4a16ca265af7be75cb04102b8f. * Revert "add logic to copy package to folder without activation file" This reverts commit b20d994b5d0c745b58c3a22c92fb757211591f6f. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit 1cba302bc47081c4958c01bcf13092517679b7af. * Revert "add clarification on package mode caveats" This reverts commit fb62d36ba1cfebaabfa9eced695a203c68a0662c. * Revert "fix documentation and add error message for missing jq" This reverts commit 0df3ab6b88fe7f787c692d1b3f3f857636e166be. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
2023-07-03 15:09:20 +00:00
packageMode,
packageName,
chownFilesTo,
unityLicensingServer,
2020-01-29 21:22:26 +00:00
};
},
};
2020-01-29 21:22:26 +00:00
export default Input;