improve locking naming

pull/524/head
Frostebite 2023-03-20 05:38:35 +00:00
parent ba3580c9c4
commit d6b5303493
6 changed files with 44 additions and 46 deletions

24
dist/index.js vendored
View File

@ -295,7 +295,7 @@ class BuildParameters {
pullInputList: cloud_runner_options_1.default.pullInputList, pullInputList: cloud_runner_options_1.default.pullInputList,
kubeStorageClass: cloud_runner_options_1.default.kubeStorageClass, kubeStorageClass: cloud_runner_options_1.default.kubeStorageClass,
cacheKey: cloud_runner_options_1.default.cacheKey, cacheKey: cloud_runner_options_1.default.cacheKey,
maxRetainedWorkspaces: cloud_runner_options_1.default.maxRetainedWorkspaces, maxRetainedWorkspaces: Number.parseInt(cloud_runner_options_1.default.maxRetainedWorkspaces),
useLargePackages: cloud_runner_options_1.default.useLargePackages, useLargePackages: cloud_runner_options_1.default.useLargePackages,
useCompressionStrategy: cloud_runner_options_1.default.useCompressionStrategy, useCompressionStrategy: cloud_runner_options_1.default.useCompressionStrategy,
garbageMaxAge: cloud_runner_options_1.default.garbageMaxAge, garbageMaxAge: cloud_runner_options_1.default.garbageMaxAge,
@ -761,10 +761,10 @@ class CloudRunnerOptions {
} }
static get branch() { static get branch() {
if (CloudRunnerOptions.getInput(`GITHUB_REF`)) { if (CloudRunnerOptions.getInput(`GITHUB_REF`)) {
return CloudRunnerOptions.getInput(`GITHUB_REF`).replace('refs/', '').replace(`head/`, '').replace(`heads/`, ''); return (CloudRunnerOptions.getInput(`GITHUB_REF`)?.replace('refs/', '').replace(`head/`, '').replace(`heads/`, '') || ``);
} }
else if (CloudRunnerOptions.getInput('branch')) { else if (CloudRunnerOptions.getInput('branch')) {
return CloudRunnerOptions.getInput('branch'); return CloudRunnerOptions.getInput('branch') || ``;
} }
else { else {
return ''; return '';
@ -781,7 +781,7 @@ class CloudRunnerOptions {
if (CloudRunnerOptions.providerStrategy !== 'local') { if (CloudRunnerOptions.providerStrategy !== 'local') {
return 'linux'; return 'linux';
} }
return; return ``;
} }
static get cloudRunnerBranch() { static get cloudRunnerBranch() {
return CloudRunnerOptions.getInput('cloudRunnerBranch') || 'main'; return CloudRunnerOptions.getInput('cloudRunnerBranch') || 'main';
@ -794,10 +794,10 @@ class CloudRunnerOptions {
return provider || 'local'; return provider || 'local';
} }
static get containerCpu() { static get containerCpu() {
return CloudRunnerOptions.getInput('containerCpu'); return CloudRunnerOptions.getInput('containerCpu') || `1024`;
} }
static get containerMemory() { static get containerMemory() {
return CloudRunnerOptions.getInput('containerMemory'); return CloudRunnerOptions.getInput('containerMemory') || `3072`;
} }
static get customJob() { static get customJob() {
return CloudRunnerOptions.getInput('customJob') || ''; return CloudRunnerOptions.getInput('customJob') || '';
@ -901,7 +901,7 @@ class CloudRunnerOptions {
// Retained Workspace // Retained Workspace
// ### ### ### // ### ### ###
static get maxRetainedWorkspaces() { static get maxRetainedWorkspaces() {
return CloudRunnerOptions.getInput(`maxRetainedWorkspaces`) || 0; return CloudRunnerOptions.getInput(`maxRetainedWorkspaces`) || `0`;
} }
// ### ### ### // ### ### ###
// Garbage Collection // Garbage Collection
@ -1405,14 +1405,12 @@ class AWSJobStack {
async setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) { async setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
const taskDefStackName = `${this.baseStackName}-${buildGuid}`; const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
let taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.readTaskCloudFormationTemplate(); let taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.readTaskCloudFormationTemplate();
const cpu = cloud_runner_1.default.buildParameters.containerCpu || '1024';
const memory = cloud_runner_1.default.buildParameters.containerMemory || '3072';
taskDefCloudFormation = taskDefCloudFormation.replace(`ContainerCpu: taskDefCloudFormation = taskDefCloudFormation.replace(`ContainerCpu:
Default: 1024`, `ContainerCpu: Default: 1024`, `ContainerCpu:
Default: ${Number.parseInt(cpu)}`); Default: ${Number.parseInt(cloud_runner_1.default.buildParameters.containerCpu)}`);
taskDefCloudFormation = taskDefCloudFormation.replace(`ContainerMemory: taskDefCloudFormation = taskDefCloudFormation.replace(`ContainerMemory:
Default: 2048`, `ContainerMemory: Default: 2048`, `ContainerMemory:
Default: ${Number.parseInt(memory)}`); Default: ${Number.parseInt(cloud_runner_1.default.buildParameters.containerMemory)}`);
if (!cloud_runner_options_1.default.asyncCloudRunner) { if (!cloud_runner_options_1.default.asyncCloudRunner) {
taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.insertAtTemplate(taskDefCloudFormation, '# template resources logstream', task_definition_formation_1.TaskDefinitionFormation.streamLogs); taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.insertAtTemplate(taskDefCloudFormation, '# template resources logstream', task_definition_formation_1.TaskDefinitionFormation.streamLogs);
} }
@ -3408,8 +3406,8 @@ class KubernetesJobSpecFactory {
workingDir: `${workingDirectory}`, workingDir: `${workingDirectory}`,
resources: { resources: {
requests: { requests: {
memory: buildParameters.containerMemory || '750M', memory: `${Number.parseInt(buildParameters.containerMemory) / 1024}G` || '750M',
cpu: buildParameters.containerCpu || '1', cpu: Number.parseInt(buildParameters.containerCpu) / 1024 || '1',
}, },
}, },
env: [ env: [

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -45,8 +45,8 @@ class BuildParameters {
public gitPrivateToken!: string; public gitPrivateToken!: string;
public awsStackName!: string; public awsStackName!: string;
public kubeConfig!: string; public kubeConfig!: string;
public containerMemory!: string | undefined; public containerMemory!: string;
public containerCpu!: string | undefined; public containerCpu!: string;
public kubeVolumeSize!: string; public kubeVolumeSize!: string;
public kubeVolume!: string; public kubeVolume!: string;
public kubeStorageClass!: string; public kubeStorageClass!: string;
@ -174,7 +174,7 @@ class BuildParameters {
pullInputList: CloudRunnerOptions.pullInputList, pullInputList: CloudRunnerOptions.pullInputList,
kubeStorageClass: CloudRunnerOptions.kubeStorageClass, kubeStorageClass: CloudRunnerOptions.kubeStorageClass,
cacheKey: CloudRunnerOptions.cacheKey, cacheKey: CloudRunnerOptions.cacheKey,
maxRetainedWorkspaces: CloudRunnerOptions.maxRetainedWorkspaces, maxRetainedWorkspaces: Number.parseInt(CloudRunnerOptions.maxRetainedWorkspaces),
useLargePackages: CloudRunnerOptions.useLargePackages, useLargePackages: CloudRunnerOptions.useLargePackages,
useCompressionStrategy: CloudRunnerOptions.useCompressionStrategy, useCompressionStrategy: CloudRunnerOptions.useCompressionStrategy,
garbageMaxAge: CloudRunnerOptions.garbageMaxAge, garbageMaxAge: CloudRunnerOptions.garbageMaxAge,

View File

@ -7,7 +7,7 @@ class CloudRunnerOptions {
// ### ### ### // ### ### ###
// Input Handling // Input Handling
// ### ### ### // ### ### ###
public static getInput(query: string) { public static getInput(query: string): string | undefined {
if (GitHub.githubInputEnabled) { if (GitHub.githubInputEnabled) {
const coreInput = core.getInput(query); const coreInput = core.getInput(query);
if (coreInput && coreInput !== '') { if (coreInput && coreInput !== '') {
@ -38,7 +38,7 @@ class CloudRunnerOptions {
} }
} }
public static ToEnvVarFormat(input: string) { public static ToEnvVarFormat(input: string): string {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;
} }
@ -91,9 +91,11 @@ class CloudRunnerOptions {
} }
static get branch(): string { static get branch(): string {
if (CloudRunnerOptions.getInput(`GITHUB_REF`)) { if (CloudRunnerOptions.getInput(`GITHUB_REF`)) {
return CloudRunnerOptions.getInput(`GITHUB_REF`).replace('refs/', '').replace(`head/`, '').replace(`heads/`, ''); return (
CloudRunnerOptions.getInput(`GITHUB_REF`)?.replace('refs/', '').replace(`head/`, '').replace(`heads/`, '') || ``
);
} else if (CloudRunnerOptions.getInput('branch')) { } else if (CloudRunnerOptions.getInput('branch')) {
return CloudRunnerOptions.getInput('branch'); return CloudRunnerOptions.getInput('branch') || ``;
} else { } else {
return ''; return '';
} }
@ -103,7 +105,7 @@ class CloudRunnerOptions {
// Cloud Runner parameters // Cloud Runner parameters
// ### ### ### // ### ### ###
static get buildPlatform() { static get buildPlatform(): string {
const input = CloudRunnerOptions.getInput('buildPlatform'); const input = CloudRunnerOptions.getInput('buildPlatform');
if (input) { if (input) {
return input; return input;
@ -112,14 +114,14 @@ class CloudRunnerOptions {
return 'linux'; return 'linux';
} }
return; return ``;
} }
static get cloudRunnerBranch() { static get cloudRunnerBranch(): string {
return CloudRunnerOptions.getInput('cloudRunnerBranch') || 'main'; return CloudRunnerOptions.getInput('cloudRunnerBranch') || 'main';
} }
static get providerStrategy() { static get providerStrategy(): string {
const provider = const provider =
CloudRunnerOptions.getInput('cloudRunnerCluster') || CloudRunnerOptions.getInput('providerStrategy'); CloudRunnerOptions.getInput('cloudRunnerCluster') || CloudRunnerOptions.getInput('providerStrategy');
if (Cli.isCliMode) { if (Cli.isCliMode) {
@ -129,15 +131,15 @@ class CloudRunnerOptions {
return provider || 'local'; return provider || 'local';
} }
static get containerCpu() { static get containerCpu(): string {
return CloudRunnerOptions.getInput('containerCpu'); return CloudRunnerOptions.getInput('containerCpu') || `1024`;
} }
static get containerMemory() { static get containerMemory(): string {
return CloudRunnerOptions.getInput('containerMemory'); return CloudRunnerOptions.getInput('containerMemory') || `3072`;
} }
static get customJob() { static get customJob(): string {
return CloudRunnerOptions.getInput('customJob') || ''; return CloudRunnerOptions.getInput('customJob') || '';
} }
@ -145,11 +147,11 @@ class CloudRunnerOptions {
// Custom commands from files parameters // Custom commands from files parameters
// ### ### ### // ### ### ###
static get customStepFiles() { static get customStepFiles(): string[] {
return CloudRunnerOptions.getInput('customStepFiles')?.split(`,`) || []; return CloudRunnerOptions.getInput('customStepFiles')?.split(`,`) || [];
} }
static get customHookFiles() { static get customHookFiles(): string[] {
return CloudRunnerOptions.getInput('customHookFiles')?.split(`,`) || []; return CloudRunnerOptions.getInput('customHookFiles')?.split(`,`) || [];
} }
@ -157,15 +159,15 @@ class CloudRunnerOptions {
// Custom commands from yaml parameters // Custom commands from yaml parameters
// ### ### ### // ### ### ###
static get commandHooks() { static get commandHooks(): string {
return CloudRunnerOptions.getInput('commandHooks') || ''; return CloudRunnerOptions.getInput('commandHooks') || '';
} }
static get postBuildSteps() { static get postBuildSteps(): string {
return CloudRunnerOptions.getInput('postBuildSteps') || ''; return CloudRunnerOptions.getInput('postBuildSteps') || '';
} }
static get preBuildSteps() { static get preBuildSteps(): string {
return CloudRunnerOptions.getInput('preBuildSteps') || ''; return CloudRunnerOptions.getInput('preBuildSteps') || '';
} }
@ -201,15 +203,15 @@ class CloudRunnerOptions {
// K8s // K8s
// ### ### ### // ### ### ###
static get kubeConfig() { static get kubeConfig(): string {
return CloudRunnerOptions.getInput('kubeConfig') || ''; return CloudRunnerOptions.getInput('kubeConfig') || '';
} }
static get kubeVolume() { static get kubeVolume(): string {
return CloudRunnerOptions.getInput('kubeVolume') || ''; return CloudRunnerOptions.getInput('kubeVolume') || '';
} }
static get kubeVolumeSize() { static get kubeVolumeSize(): string {
return CloudRunnerOptions.getInput('kubeVolumeSize') || '5Gi'; return CloudRunnerOptions.getInput('kubeVolumeSize') || '5Gi';
} }
@ -269,8 +271,8 @@ class CloudRunnerOptions {
// Retained Workspace // Retained Workspace
// ### ### ### // ### ### ###
public static get maxRetainedWorkspaces(): number { public static get maxRetainedWorkspaces(): string {
return CloudRunnerOptions.getInput(`maxRetainedWorkspaces`) || 0; return CloudRunnerOptions.getInput(`maxRetainedWorkspaces`) || `0`;
} }
// ### ### ### // ### ### ###

View File

@ -27,19 +27,17 @@ export class AWSJobStack {
): Promise<CloudRunnerAWSTaskDef> { ): Promise<CloudRunnerAWSTaskDef> {
const taskDefStackName = `${this.baseStackName}-${buildGuid}`; const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
let taskDefCloudFormation = AWSCloudFormationTemplates.readTaskCloudFormationTemplate(); let taskDefCloudFormation = AWSCloudFormationTemplates.readTaskCloudFormationTemplate();
const cpu = CloudRunner.buildParameters.containerCpu || '1024';
const memory = CloudRunner.buildParameters.containerMemory || '3072';
taskDefCloudFormation = taskDefCloudFormation.replace( taskDefCloudFormation = taskDefCloudFormation.replace(
`ContainerCpu: `ContainerCpu:
Default: 1024`, Default: 1024`,
`ContainerCpu: `ContainerCpu:
Default: ${Number.parseInt(cpu)}`, Default: ${Number.parseInt(CloudRunner.buildParameters.containerCpu)}`,
); );
taskDefCloudFormation = taskDefCloudFormation.replace( taskDefCloudFormation = taskDefCloudFormation.replace(
`ContainerMemory: `ContainerMemory:
Default: 2048`, Default: 2048`,
`ContainerMemory: `ContainerMemory:
Default: ${Number.parseInt(memory)}`, Default: ${Number.parseInt(CloudRunner.buildParameters.containerMemory)}`,
); );
if (!CloudRunnerOptions.asyncCloudRunner) { if (!CloudRunnerOptions.asyncCloudRunner) {
taskDefCloudFormation = AWSCloudFormationTemplates.insertAtTemplate( taskDefCloudFormation = AWSCloudFormationTemplates.insertAtTemplate(

View File

@ -110,8 +110,8 @@ class KubernetesJobSpecFactory {
workingDir: `${workingDirectory}`, workingDir: `${workingDirectory}`,
resources: { resources: {
requests: { requests: {
memory: buildParameters.containerMemory || '750M', memory: `${Number.parseInt(buildParameters.containerMemory) / 1024}G` || '750M',
cpu: buildParameters.containerCpu || '1', cpu: Number.parseInt(buildParameters.containerCpu) / 1024 || '1',
}, },
}, },
env: [ env: [