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

49 lines
990 B
TypeScript
Raw Normal View History

2020-01-29 21:22:26 +00:00
import path from 'path';
const Action = {
get supportedPlatforms() {
2020-01-29 21:22:26 +00:00
return ['linux'];
},
2020-01-29 21:22:26 +00:00
get isRunningLocally() {
2020-01-29 21:22:26 +00:00
return process.env.RUNNER_WORKSPACE === undefined;
},
2020-01-29 21:22:26 +00:00
get isRunningFromSource() {
2020-01-29 21:22:26 +00:00
return path.basename(__dirname) === 'model';
},
2020-01-29 21:22:26 +00:00
get canonicalName() {
2020-01-29 21:22:26 +00:00
return 'unity-test-runner';
},
2020-01-29 21:22:26 +00:00
get rootFolder() {
2020-01-29 21:22:26 +00:00
if (Action.isRunningFromSource) {
return path.dirname(path.dirname(path.dirname(__filename)));
}
return path.dirname(path.dirname(__filename));
},
2020-01-29 21:22:26 +00:00
get actionFolder() {
return `${Action.rootFolder}/dist`;
},
2020-01-29 21:22:26 +00:00
get dockerfile() {
2020-01-29 21:22:26 +00:00
return `${Action.actionFolder}/Dockerfile`;
},
2020-01-29 21:22:26 +00:00
get workspace() {
2020-01-29 21:22:26 +00:00
return process.env.GITHUB_WORKSPACE;
},
2020-01-29 21:22:26 +00:00
checkCompatibility() {
2020-01-29 21:22:26 +00:00
const currentPlatform = process.platform;
if (!Action.supportedPlatforms.includes(currentPlatform)) {
throw new Error(`Currently ${currentPlatform}-platform is not supported`);
}
},
};
2020-01-29 21:22:26 +00:00
export default Action;