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 generated vendored
View File

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

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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