mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-11 08:23:56 -07:00
Code cleanup (#511)
* Enable noImplicitAny Add types to all implicit any variables Bump target to ES2020 for recent language features (optional chaining) Code cleanup Add debug configuration for vscode Remove autorun flag from jest to remove warning Bump packages to fix dependency version mismatch warning Changed @arkweid/lefthook to @evilmartians/lefthook as @arkweid/lefthook has been deprecated in favor of @evilmartians/lefthook Added concurrency groups to integrity check and build workflows. New commits to branches will cancel superseded runs on the same branch/pr Update imports to not use require syntax Use node packages (ie node:fs rather than fs) AndroidVersionCode is now a string rather than a number as it gets converted to a string when passed out of the system Reduce timeout for windows builds Remove 2020.1.17f1 from windows builds due to repeated license activation errors Update naming scheme of workflows for consistency Update build names so target platform and unity version aren't cut off by github actions UI * Add exclude to test matrix for 2022.2 on android until Unity bug is fixed --------- Co-authored-by: AndrewKahr <AndrewKahr@users.noreply.github.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { Cli } from '../cli/cli';
|
||||
import CloudRunnerQueryOverride from './services/cloud-runner-query-override';
|
||||
import GitHub from '../github';
|
||||
const core = require('@actions/core');
|
||||
import * as core from '@actions/core';
|
||||
|
||||
class CloudRunnerOptions {
|
||||
// ### ### ###
|
||||
// Input Handling
|
||||
// ### ### ###
|
||||
public static getInput(query) {
|
||||
public static getInput(query: string): string | undefined {
|
||||
if (GitHub.githubInputEnabled) {
|
||||
const coreInput = core.getInput(query);
|
||||
if (coreInput && coreInput !== '') {
|
||||
@@ -32,11 +32,9 @@ class CloudRunnerOptions {
|
||||
if (alternativeQuery !== query && process.env[alternativeQuery] !== undefined) {
|
||||
return process.env[alternativeQuery];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static ToEnvVarFormat(input: string) {
|
||||
public static ToEnvVarFormat(input: string): string {
|
||||
if (input.toUpperCase() === input) {
|
||||
return input;
|
||||
}
|
||||
@@ -60,39 +58,40 @@ class CloudRunnerOptions {
|
||||
// GitHub parameters
|
||||
// ### ### ###
|
||||
static get githubChecks(): boolean {
|
||||
return CloudRunnerOptions.getInput('githubChecks') || false;
|
||||
return CloudRunnerOptions.getInput('githubChecks') === 'true' || false;
|
||||
}
|
||||
|
||||
static get githubOwner() {
|
||||
return CloudRunnerOptions.getInput('githubOwner') || CloudRunnerOptions.githubRepo.split(`/`)[0] || false;
|
||||
static get githubOwner(): string {
|
||||
return CloudRunnerOptions.getInput('githubOwner') || CloudRunnerOptions.githubRepo?.split(`/`)[0] || '';
|
||||
}
|
||||
|
||||
static get githubRepoName() {
|
||||
return CloudRunnerOptions.getInput('githubRepoName') || CloudRunnerOptions.githubRepo.split(`/`)[1] || false;
|
||||
static get githubRepoName(): string {
|
||||
return CloudRunnerOptions.getInput('githubRepoName') || CloudRunnerOptions.githubRepo?.split(`/`)[1] || '';
|
||||
}
|
||||
|
||||
// ### ### ###
|
||||
// Git syncronization parameters
|
||||
// ### ### ###
|
||||
|
||||
static get githubRepo() {
|
||||
static get githubRepo(): string | undefined {
|
||||
return CloudRunnerOptions.getInput('GITHUB_REPOSITORY') || CloudRunnerOptions.getInput('GITHUB_REPO') || undefined;
|
||||
}
|
||||
static get branch() {
|
||||
|
||||
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 '';
|
||||
}
|
||||
}
|
||||
|
||||
static get gitSha() {
|
||||
static get gitSha(): string | undefined {
|
||||
if (CloudRunnerOptions.getInput(`GITHUB_SHA`)) {
|
||||
return CloudRunnerOptions.getInput(`GITHUB_SHA`);
|
||||
return CloudRunnerOptions.getInput(`GITHUB_SHA`)!;
|
||||
} else if (CloudRunnerOptions.getInput(`GitSHA`)) {
|
||||
return CloudRunnerOptions.getInput(`GitSHA`);
|
||||
return CloudRunnerOptions.getInput(`GitSHA`)!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +99,7 @@ class CloudRunnerOptions {
|
||||
// Cloud Runner parameters
|
||||
// ### ### ###
|
||||
|
||||
static get cloudRunnerBuilderPlatform() {
|
||||
static get cloudRunnerBuilderPlatform(): string | undefined {
|
||||
const input = CloudRunnerOptions.getInput('cloudRunnerBuilderPlatform');
|
||||
if (input) {
|
||||
return input;
|
||||
@@ -112,11 +111,11 @@ class CloudRunnerOptions {
|
||||
return;
|
||||
}
|
||||
|
||||
static get cloudRunnerBranch() {
|
||||
static get cloudRunnerBranch(): string {
|
||||
return CloudRunnerOptions.getInput('cloudRunnerBranch') || 'main';
|
||||
}
|
||||
|
||||
static get cloudRunnerCluster() {
|
||||
static get cloudRunnerCluster(): string {
|
||||
if (Cli.isCliMode) {
|
||||
return CloudRunnerOptions.getInput('cloudRunnerCluster') || 'aws';
|
||||
}
|
||||
@@ -124,15 +123,15 @@ class CloudRunnerOptions {
|
||||
return CloudRunnerOptions.getInput('cloudRunnerCluster') || 'local';
|
||||
}
|
||||
|
||||
static get cloudRunnerCpu() {
|
||||
static get cloudRunnerCpu(): string | undefined {
|
||||
return CloudRunnerOptions.getInput('cloudRunnerCpu');
|
||||
}
|
||||
|
||||
static get cloudRunnerMemory() {
|
||||
static get cloudRunnerMemory(): string | undefined {
|
||||
return CloudRunnerOptions.getInput('cloudRunnerMemory');
|
||||
}
|
||||
|
||||
static get customJob() {
|
||||
static get customJob(): string {
|
||||
return CloudRunnerOptions.getInput('customJob') || '';
|
||||
}
|
||||
|
||||
@@ -140,11 +139,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(`,`) || [];
|
||||
}
|
||||
|
||||
@@ -152,15 +151,15 @@ class CloudRunnerOptions {
|
||||
// Custom commands from yaml parameters
|
||||
// ### ### ###
|
||||
|
||||
static customJobHooks() {
|
||||
static customJobHooks(): string {
|
||||
return CloudRunnerOptions.getInput('customJobHooks') || '';
|
||||
}
|
||||
|
||||
static get postBuildSteps() {
|
||||
static get postBuildSteps(): string {
|
||||
return CloudRunnerOptions.getInput('postBuildSteps') || '';
|
||||
}
|
||||
|
||||
static get preBuildSteps() {
|
||||
static get preBuildSteps(): string {
|
||||
return CloudRunnerOptions.getInput('preBuildSteps') || '';
|
||||
}
|
||||
|
||||
@@ -168,11 +167,11 @@ class CloudRunnerOptions {
|
||||
// Input override handling
|
||||
// ### ### ###
|
||||
|
||||
static readInputFromOverrideList() {
|
||||
static readInputFromOverrideList(): string {
|
||||
return CloudRunnerOptions.getInput('readInputFromOverrideList') || '';
|
||||
}
|
||||
|
||||
static readInputOverrideCommand() {
|
||||
static readInputOverrideCommand(): string {
|
||||
const value = CloudRunnerOptions.getInput('readInputOverrideCommand');
|
||||
|
||||
if (value === 'gcp-secret-manager') {
|
||||
@@ -188,7 +187,7 @@ class CloudRunnerOptions {
|
||||
// Aws
|
||||
// ### ### ###
|
||||
|
||||
static get awsBaseStackName() {
|
||||
static get awsBaseStackName(): string {
|
||||
return CloudRunnerOptions.getInput('awsBaseStackName') || 'game-ci';
|
||||
}
|
||||
|
||||
@@ -196,15 +195,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';
|
||||
}
|
||||
|
||||
@@ -225,12 +224,16 @@ class CloudRunnerOptions {
|
||||
// ### ### ###
|
||||
|
||||
static get cloudRunnerDebug(): boolean {
|
||||
return CloudRunnerOptions.getInput(`cloudRunnerTests`) || CloudRunnerOptions.getInput(`cloudRunnerDebug`) || false;
|
||||
return (
|
||||
CloudRunnerOptions.getInput(`cloudRunnerTests`) === 'true' ||
|
||||
CloudRunnerOptions.getInput(`cloudRunnerDebug`) === 'true' ||
|
||||
false
|
||||
);
|
||||
}
|
||||
static get cloudRunnerDebugTree(): boolean {
|
||||
static get cloudRunnerDebugTree(): string | boolean {
|
||||
return CloudRunnerOptions.getInput(`cloudRunnerDebugTree`) || false;
|
||||
}
|
||||
static get cloudRunnerDebugEnv(): boolean {
|
||||
static get cloudRunnerDebugEnv(): string | boolean {
|
||||
return CloudRunnerOptions.getInput(`cloudRunnerDebugEnv`) || false;
|
||||
}
|
||||
|
||||
@@ -239,7 +242,7 @@ class CloudRunnerOptions {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CloudRunnerOptions.getInput(`watchToEnd`) || true;
|
||||
return CloudRunnerOptions.getInput(`watchToEnd`) === 'true' || true;
|
||||
}
|
||||
|
||||
static get asyncCloudRunner(): boolean {
|
||||
@@ -267,7 +270,7 @@ class CloudRunnerOptions {
|
||||
// ### ### ###
|
||||
|
||||
public static get retainWorkspaces(): boolean {
|
||||
return CloudRunnerOptions.getInput(`retainWorkspaces`) || false;
|
||||
return CloudRunnerOptions.getInput(`retainWorkspaces`) === 'true' || false;
|
||||
}
|
||||
|
||||
static get maxRetainedWorkspaces(): number {
|
||||
@@ -279,7 +282,7 @@ class CloudRunnerOptions {
|
||||
// ### ### ###
|
||||
|
||||
static get constantGarbageCollection(): boolean {
|
||||
return CloudRunnerOptions.getInput(`constantGarbageCollection`) || true;
|
||||
return CloudRunnerOptions.getInput(`constantGarbageCollection`) === 'true' || true;
|
||||
}
|
||||
|
||||
static get garbageCollectionMaxAge(): number {
|
||||
|
||||
@@ -23,7 +23,8 @@ class CloudRunner {
|
||||
private static cloudRunnerEnvironmentVariables: CloudRunnerEnvironmentVariable[];
|
||||
static lockedWorkspace: string | undefined;
|
||||
public static readonly retainedWorkspacePrefix: string = `retained-workspace`;
|
||||
public static githubCheckId;
|
||||
public static githubCheckId: number | string;
|
||||
|
||||
public static setup(buildParameters: BuildParameters) {
|
||||
CloudRunnerLogger.setup();
|
||||
CloudRunnerLogger.log(`Setting up cloud runner`);
|
||||
|
||||
@@ -2,7 +2,7 @@ import CloudRunnerLogger from '../../services/cloud-runner-logger';
|
||||
import * as core from '@actions/core';
|
||||
import * as SDK from 'aws-sdk';
|
||||
import { BaseStackFormation } from './cloud-formations/base-stack-formation';
|
||||
const crypto = require('crypto');
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
export class AWSBaseStack {
|
||||
constructor(baseStackName: string) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TaskDefinitionFormation } from './cloud-formations/task-definition-formation';
|
||||
|
||||
export class AWSCloudFormationTemplates {
|
||||
public static getParameterTemplate(p1) {
|
||||
public static getParameterTemplate(p1: string) {
|
||||
return `
|
||||
${p1}:
|
||||
Type: String
|
||||
@@ -9,7 +9,7 @@ export class AWSCloudFormationTemplates {
|
||||
`;
|
||||
}
|
||||
|
||||
public static getSecretTemplate(p1) {
|
||||
public static getSecretTemplate(p1: string) {
|
||||
return `
|
||||
${p1}Secret:
|
||||
Type: AWS::SecretsManager::Secret
|
||||
@@ -19,14 +19,14 @@ export class AWSCloudFormationTemplates {
|
||||
`;
|
||||
}
|
||||
|
||||
public static getSecretDefinitionTemplate(p1, p2) {
|
||||
public static getSecretDefinitionTemplate(p1: string, p2: string) {
|
||||
return `
|
||||
- Name: '${p1}'
|
||||
ValueFrom: !Ref ${p2}Secret
|
||||
`;
|
||||
}
|
||||
|
||||
public static insertAtTemplate(template, insertionKey, insertion) {
|
||||
public static insertAtTemplate(template: string, insertionKey: string, insertion: string) {
|
||||
const index = template.search(insertionKey) + insertionKey.length + '\n'.length;
|
||||
template = [template.slice(0, index), insertion, template.slice(index)].join('');
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as AWS from 'aws-sdk';
|
||||
import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable';
|
||||
import * as core from '@actions/core';
|
||||
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
|
||||
import * as zlib from 'zlib';
|
||||
import * as zlib from 'node:zlib';
|
||||
import CloudRunnerLogger from '../../services/cloud-runner-logger';
|
||||
import { Input } from '../../..';
|
||||
import CloudRunner from '../../cloud-runner';
|
||||
@@ -192,22 +192,19 @@ class AWSTaskRunner {
|
||||
}
|
||||
|
||||
private static logRecords(
|
||||
records,
|
||||
records: AWS.Kinesis.GetRecordsOutput,
|
||||
iterator: string,
|
||||
shouldReadLogs: boolean,
|
||||
output: string,
|
||||
shouldCleanup: boolean,
|
||||
) {
|
||||
if (records.Records.length > 0 && iterator) {
|
||||
for (let index = 0; index < records.Records.length; index++) {
|
||||
const json = JSON.parse(
|
||||
zlib.gunzipSync(Buffer.from(records.Records[index].Data as string, 'base64')).toString('utf8'),
|
||||
);
|
||||
for (const record of records.Records) {
|
||||
const json = JSON.parse(zlib.gunzipSync(Buffer.from(record.Data as string, 'base64')).toString('utf8'));
|
||||
if (json.messageType === 'DATA_MESSAGE') {
|
||||
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
||||
const message = json.logEvents[logEventsIndex].message;
|
||||
for (const logEvent of json.logEvents) {
|
||||
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
|
||||
message,
|
||||
logEvent.message,
|
||||
shouldReadLogs,
|
||||
shouldCleanup,
|
||||
output,
|
||||
@@ -226,7 +223,7 @@ class AWSTaskRunner {
|
||||
}).promise();
|
||||
}
|
||||
|
||||
private static async getLogIterator(stream) {
|
||||
private static async getLogIterator(stream: AWS.Kinesis.DescribeStreamOutput) {
|
||||
return (
|
||||
(
|
||||
await AWSTaskRunner.Kinesis.getShardIterator({
|
||||
|
||||
@@ -4,7 +4,7 @@ import CloudRunnerLogger from '../../../services/cloud-runner-logger';
|
||||
import { TaskService } from './task-service';
|
||||
|
||||
export class GarbageCollectionService {
|
||||
static isOlderThan1day(date: any) {
|
||||
static isOlderThan1day(date: Date) {
|
||||
const ageDate = new Date(date.getTime() - Date.now());
|
||||
|
||||
return ageDate.getDay() > 0;
|
||||
@@ -17,14 +17,16 @@ export class GarbageCollectionService {
|
||||
const cwl = new AWS.CloudWatchLogs();
|
||||
const taskDefinitionsInUse = new Array();
|
||||
const tasks = await TaskService.getTasks();
|
||||
|
||||
for (const task of tasks) {
|
||||
const { taskElement, element } = task;
|
||||
taskDefinitionsInUse.push(taskElement.taskDefinitionArn);
|
||||
if (deleteResources && (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(taskElement.CreatedAt))) {
|
||||
if (deleteResources && (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(taskElement.createdAt!))) {
|
||||
CloudRunnerLogger.log(`Stopping task ${taskElement.containers?.[0].name}`);
|
||||
await ecs.stopTask({ task: taskElement.taskArn || '', cluster: element }).promise();
|
||||
}
|
||||
}
|
||||
|
||||
const jobStacks = await TaskService.getCloudFormationJobStacks();
|
||||
for (const element of jobStacks) {
|
||||
if (
|
||||
@@ -36,13 +38,15 @@ export class GarbageCollectionService {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (deleteResources && (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(element.CreationTime))) {
|
||||
if (element.StackName === 'game-ci' || element.TemplateDescription === 'Game-CI base stack') {
|
||||
CloudRunnerLogger.log(`Skipping ${element.StackName} ignore list`);
|
||||
|
||||
return;
|
||||
}
|
||||
CloudRunnerLogger.log(`Deleting ${element.logGroupName}`);
|
||||
|
||||
CloudRunnerLogger.log(`Deleting ${element.StackName}`);
|
||||
const deleteStackInput: AWS.CloudFormation.DeleteStackInput = { StackName: element.StackName };
|
||||
await CF.deleteStack(deleteStackInput).promise();
|
||||
}
|
||||
@@ -51,7 +55,7 @@ export class GarbageCollectionService {
|
||||
for (const element of logGroups) {
|
||||
if (
|
||||
deleteResources &&
|
||||
(!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(new Date(element.createdAt)))
|
||||
(!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(new Date(element.creationTime!)))
|
||||
) {
|
||||
CloudRunnerLogger.log(`Deleting ${element.logGroupName}`);
|
||||
await cwl.deleteLogGroup({ logGroupName: element.logGroupName || '' }).promise();
|
||||
|
||||
@@ -5,6 +5,8 @@ import { BaseStackFormation } from '../cloud-formations/base-stack-formation';
|
||||
import AwsTaskRunner from '../aws-task-runner';
|
||||
import { ListObjectsRequest } from 'aws-sdk/clients/s3';
|
||||
import CloudRunner from '../../../cloud-runner';
|
||||
import { StackSummaries } from 'aws-sdk/clients/cloudformation';
|
||||
import { LogGroups } from 'aws-sdk/clients/cloudwatchlogs';
|
||||
|
||||
export class TaskService {
|
||||
static async watch() {
|
||||
@@ -18,7 +20,7 @@ export class TaskService {
|
||||
return output;
|
||||
}
|
||||
public static async getCloudFormationJobStacks() {
|
||||
const result: any[] = [];
|
||||
const result: StackSummaries = [];
|
||||
CloudRunnerLogger.log(``);
|
||||
CloudRunnerLogger.log(`List Cloud Formation Stacks`);
|
||||
process.env.AWS_REGION = Input.region;
|
||||
@@ -62,7 +64,7 @@ export class TaskService {
|
||||
return result;
|
||||
}
|
||||
public static async getTasks() {
|
||||
const result: any[] = [];
|
||||
const result: { taskElement: AWS.ECS.Task; element: string }[] = [];
|
||||
CloudRunnerLogger.log(``);
|
||||
CloudRunnerLogger.log(`List Tasks`);
|
||||
process.env.AWS_REGION = Input.region;
|
||||
@@ -123,7 +125,7 @@ export class TaskService {
|
||||
return message;
|
||||
}
|
||||
public static async getLogGroups() {
|
||||
const result: any[] = [];
|
||||
const result: LogGroups = [];
|
||||
process.env.AWS_REGION = Input.region;
|
||||
const ecs = new AWS.CloudWatchLogs();
|
||||
let logStreamInput: AWS.CloudWatchLogs.DescribeLogGroupsRequest = {
|
||||
|
||||
@@ -10,7 +10,8 @@ import CloudRunner from '../../cloud-runner';
|
||||
import { ProviderResource } from '../provider-resource';
|
||||
import { ProviderWorkflow } from '../provider-workflow';
|
||||
import { CloudRunnerSystem } from '../../services/cloud-runner-system';
|
||||
import * as fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
import { StringKeyValuePair } from '../../../shared-types';
|
||||
|
||||
class LocalDockerCloudRunner implements ProviderInterface {
|
||||
public buildParameters: BuildParameters | undefined;
|
||||
@@ -86,7 +87,7 @@ class LocalDockerCloudRunner implements ProviderInterface {
|
||||
CloudRunnerLogger.log(commands);
|
||||
|
||||
const { workspace, actionFolder } = Action;
|
||||
const content: any[] = [];
|
||||
const content: StringKeyValuePair[] = [];
|
||||
for (const x of secrets) {
|
||||
content.push({ name: x.EnvironmentVariable, value: x.ParameterValue });
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ class KubernetesJobSpecFactory {
|
||||
secrets: CloudRunnerSecret[],
|
||||
buildGuid: string,
|
||||
buildParameters: BuildParameters,
|
||||
secretName,
|
||||
pvcName,
|
||||
jobName,
|
||||
k8s,
|
||||
secretName: string,
|
||||
pvcName: string,
|
||||
jobName: string,
|
||||
k8s: any,
|
||||
) {
|
||||
environment.push(
|
||||
...[
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CoreV1Api } from '@kubernetes/client-node';
|
||||
import CloudRunnerSecret from '../../services/cloud-runner-secret';
|
||||
import * as k8s from '@kubernetes/client-node';
|
||||
import CloudRunnerLogger from '../../services/cloud-runner-logger';
|
||||
const base64 = require('base-64');
|
||||
import * as base64 from 'base-64';
|
||||
|
||||
class KubernetesSecret {
|
||||
static async createSecret(
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as core from '@actions/core';
|
||||
import * as k8s from '@kubernetes/client-node';
|
||||
import BuildParameters from '../../../build-parameters';
|
||||
import CloudRunnerLogger from '../../services/cloud-runner-logger';
|
||||
import { IncomingMessage } from 'http';
|
||||
import { IncomingMessage } from 'node:http';
|
||||
import GitHub from '../../../github';
|
||||
|
||||
class KubernetesStorage {
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface ProviderInterface {
|
||||
branchName: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||
);
|
||||
): any;
|
||||
setupWorkflow(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
buildGuid: string,
|
||||
@@ -24,7 +24,7 @@ export interface ProviderInterface {
|
||||
branchName: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||
);
|
||||
): any;
|
||||
runTaskInWorkflow(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
buildGuid: string,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { assert } from 'console';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { assert } from 'node:console';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import CloudRunner from '../cloud-runner';
|
||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||
import { CloudRunnerFolders } from '../services/cloud-runner-folders';
|
||||
@@ -10,7 +10,7 @@ import { RemoteClientLogger } from './remote-client-logger';
|
||||
import { Cli } from '../../cli/cli';
|
||||
import { CliFunction } from '../../cli/cli-functions-repository';
|
||||
// eslint-disable-next-line github/no-then
|
||||
const fileExists = async (fpath) => !!(await fs.promises.stat(fpath).catch(() => false));
|
||||
const fileExists = async (fpath: fs.PathLike) => !!(await fs.promises.stat(fpath).catch(() => false));
|
||||
|
||||
export class Caching {
|
||||
@CliFunction(`cache-push`, `push to cache`)
|
||||
@@ -19,9 +19,9 @@ export class Caching {
|
||||
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
||||
CloudRunner.buildParameters = buildParameter;
|
||||
await Caching.PushToCache(
|
||||
Cli.options['cachePushTo'],
|
||||
Cli.options['cachePushFrom'],
|
||||
Cli.options['artifactName'] || '',
|
||||
Cli.options!['cachePushTo'],
|
||||
Cli.options!['cachePushFrom'],
|
||||
Cli.options!['artifactName'] || '',
|
||||
);
|
||||
} catch (error: any) {
|
||||
CloudRunnerLogger.log(`${error}`);
|
||||
@@ -34,9 +34,9 @@ export class Caching {
|
||||
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
||||
CloudRunner.buildParameters = buildParameter;
|
||||
await Caching.PullFromCache(
|
||||
Cli.options['cachePushFrom'],
|
||||
Cli.options['cachePushTo'],
|
||||
Cli.options['artifactName'] || '',
|
||||
Cli.options!['cachePushFrom'],
|
||||
Cli.options!['cachePushTo'],
|
||||
Cli.options!['artifactName'] || '',
|
||||
);
|
||||
} catch (error: any) {
|
||||
CloudRunnerLogger.log(`${error}`);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
import CloudRunner from '../cloud-runner';
|
||||
import { CloudRunnerFolders } from '../services/cloud-runner-folders';
|
||||
import { Caching } from './caching';
|
||||
import { LfsHashing } from '../services/lfs-hashing';
|
||||
import { RemoteClientLogger } from './remote-client-logger';
|
||||
import path from 'path';
|
||||
import { assert } from 'console';
|
||||
import path from 'node:path';
|
||||
import { assert } from 'node:console';
|
||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||
import { CliFunction } from '../../cli/cli-functions-repository';
|
||||
import { CloudRunnerSystem } from '../services/cloud-runner-system';
|
||||
|
||||
@@ -13,7 +13,7 @@ export class RemoteClientLogger {
|
||||
CloudRunnerLogger.log(`[Client][Diagnostic] ${message}`);
|
||||
}
|
||||
|
||||
public static logWarning(message) {
|
||||
public static logWarning(message: string) {
|
||||
CloudRunnerLogger.logWarning(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import { BuildParameters, Input } from '../..';
|
||||
import YAML from 'yaml';
|
||||
import CloudRunnerSecret from './cloud-runner-secret';
|
||||
import { RemoteClientLogger } from '../remote-client/remote-client-logger';
|
||||
import path from 'path';
|
||||
import path from 'node:path';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import * as fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
|
||||
// import CloudRunnerLogger from './cloud-runner-logger';
|
||||
|
||||
@@ -24,15 +24,11 @@ export class CloudRunnerCustomHooks {
|
||||
echo "---${buildParameters.logId}"`;
|
||||
}
|
||||
|
||||
public static getHooks(customJobHooks): Hook[] {
|
||||
public static getHooks(customJobHooks: string): Hook[] {
|
||||
const experimentHooks = customJobHooks;
|
||||
let output = new Array<Hook>();
|
||||
if (experimentHooks && experimentHooks !== '') {
|
||||
try {
|
||||
output = YAML.parse(experimentHooks);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
output = YAML.parse(experimentHooks);
|
||||
}
|
||||
|
||||
return output.filter((x) => x.step !== undefined && x.hook !== undefined && x.hook.length > 0);
|
||||
@@ -62,7 +58,7 @@ export class CloudRunnerCustomHooks {
|
||||
return results;
|
||||
}
|
||||
|
||||
private static ConvertYamlSecrets(object) {
|
||||
private static ConvertYamlSecrets(object: Hook) {
|
||||
if (object.secrets === undefined) {
|
||||
object.secrets = [];
|
||||
|
||||
@@ -70,9 +66,9 @@ export class CloudRunnerCustomHooks {
|
||||
}
|
||||
object.secrets = object.secrets.map((x) => {
|
||||
return {
|
||||
ParameterKey: x.name,
|
||||
EnvironmentVariable: Input.ToEnvVarFormat(x.name),
|
||||
ParameterValue: x.value,
|
||||
ParameterKey: x.ParameterKey,
|
||||
EnvironmentVariable: Input.ToEnvVarFormat(x.ParameterKey),
|
||||
ParameterValue: x.ParameterValue,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -102,7 +98,7 @@ export class CloudRunnerCustomHooks {
|
||||
return object;
|
||||
}
|
||||
|
||||
public static getSecrets(hooks) {
|
||||
public static getSecrets(hooks: Hook[]) {
|
||||
const secrets = hooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
|
||||
|
||||
// eslint-disable-next-line unicorn/no-array-reduce
|
||||
@@ -110,9 +106,9 @@ export class CloudRunnerCustomHooks {
|
||||
}
|
||||
}
|
||||
export class Hook {
|
||||
public commands;
|
||||
public commands!: string[];
|
||||
public secrets: CloudRunnerSecret[] = new Array<CloudRunnerSecret>();
|
||||
public name;
|
||||
public name!: string;
|
||||
public hook!: string[];
|
||||
public step!: string[];
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ import CloudRunner from '../cloud-runner';
|
||||
import * as core from '@actions/core';
|
||||
import { CustomWorkflow } from '../workflows/custom-workflow';
|
||||
import { RemoteClientLogger } from '../remote-client/remote-client-logger';
|
||||
import path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import Input from '../../input';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import CloudRunnerLogger from './cloud-runner-logger';
|
||||
import { CustomStep } from './custom-step';
|
||||
import { CloudRunnerStepState } from '../cloud-runner-step-state';
|
||||
|
||||
export class CloudRunnerCustomSteps {
|
||||
static GetCustomStepsFromFiles(hookLifecycle: string): CustomStep[] {
|
||||
@@ -182,13 +183,13 @@ export class CloudRunnerCustomSteps {
|
||||
return results;
|
||||
}
|
||||
|
||||
private static ConvertYamlSecrets(object) {
|
||||
private static ConvertYamlSecrets(object: CustomStep) {
|
||||
if (object.secrets === undefined) {
|
||||
object.secrets = [];
|
||||
|
||||
return;
|
||||
}
|
||||
object.secrets = object.secrets.map((x) => {
|
||||
object.secrets = object.secrets.map((x: { [key: string]: any }) => {
|
||||
return {
|
||||
ParameterKey: x.name,
|
||||
EnvironmentVariable: Input.ToEnvVarFormat(x.name),
|
||||
@@ -228,7 +229,7 @@ export class CloudRunnerCustomSteps {
|
||||
return object;
|
||||
}
|
||||
|
||||
static async RunPostBuildSteps(cloudRunnerStepState) {
|
||||
static async RunPostBuildSteps(cloudRunnerStepState: CloudRunnerStepState) {
|
||||
let output = ``;
|
||||
const steps: CustomStep[] = [
|
||||
...CloudRunnerCustomSteps.ParseSteps(CloudRunner.buildParameters.postBuildSteps),
|
||||
@@ -247,7 +248,7 @@ export class CloudRunnerCustomSteps {
|
||||
|
||||
return output;
|
||||
}
|
||||
static async RunPreBuildSteps(cloudRunnerStepState) {
|
||||
static async RunPreBuildSteps(cloudRunnerStepState: CloudRunnerStepState) {
|
||||
let output = ``;
|
||||
const steps: CustomStep[] = [
|
||||
...CloudRunnerCustomSteps.ParseSteps(CloudRunner.buildParameters.preBuildSteps),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from 'path';
|
||||
import path from 'node:path';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import CloudRunner from './../cloud-runner';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Input from '../../input';
|
||||
import { GenericInputReader } from '../../input-readers/generic-input-reader';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
|
||||
const formatFunction = (value, arguments_) => {
|
||||
const formatFunction = (value: string, arguments_: any[]) => {
|
||||
for (const element of arguments_) {
|
||||
value = value.replace(`{${element.key}}`, element.value);
|
||||
}
|
||||
@@ -11,11 +11,11 @@ const formatFunction = (value, arguments_) => {
|
||||
};
|
||||
|
||||
class CloudRunnerQueryOverride {
|
||||
static queryOverrides: any;
|
||||
static queryOverrides: { [key: string]: string } | undefined;
|
||||
|
||||
// TODO accept premade secret sources or custom secret source definition yamls
|
||||
|
||||
public static query(key, alternativeKey) {
|
||||
public static query(key: string, alternativeKey: string) {
|
||||
if (CloudRunnerQueryOverride.queryOverrides && CloudRunnerQueryOverride.queryOverrides[key] !== undefined) {
|
||||
return CloudRunnerQueryOverride.queryOverrides[key];
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class CloudRunnerQueryOverride {
|
||||
return;
|
||||
}
|
||||
|
||||
private static shouldUseOverride(query) {
|
||||
private static shouldUseOverride(query: string) {
|
||||
if (CloudRunnerOptions.readInputOverrideCommand() !== '') {
|
||||
if (CloudRunnerOptions.readInputFromOverrideList() !== '') {
|
||||
const doesInclude =
|
||||
@@ -44,7 +44,7 @@ class CloudRunnerQueryOverride {
|
||||
}
|
||||
}
|
||||
|
||||
private static async queryOverride(query) {
|
||||
private static async queryOverride(query: string) {
|
||||
if (!this.shouldUseOverride(query)) {
|
||||
throw new Error(`Should not be trying to run override query on ${query}`);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class CloudRunnerQueryOverride {
|
||||
|
||||
public static async PopulateQueryOverrideInput() {
|
||||
const queries = CloudRunnerOptions.readInputFromOverrideList().split(',');
|
||||
CloudRunnerQueryOverride.queryOverrides = new Array();
|
||||
CloudRunnerQueryOverride.queryOverrides = {};
|
||||
for (const element of queries) {
|
||||
if (CloudRunnerQueryOverride.shouldUseOverride(element)) {
|
||||
CloudRunnerQueryOverride.queryOverrides[element] = await CloudRunnerQueryOverride.queryOverride(element);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import CloudRunnerSecret from './cloud-runner-secret';
|
||||
|
||||
export class CustomStep {
|
||||
public commands;
|
||||
public commands!: string;
|
||||
public secrets: CloudRunnerSecret[] = new Array<CloudRunnerSecret>();
|
||||
public name;
|
||||
public name!: string;
|
||||
public image: string = `ubuntu`;
|
||||
public hook!: string;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { CloudRunnerStatics } from '../cloud-runner-statics';
|
||||
import GitHub from '../../github';
|
||||
|
||||
export class FollowLogStreamService {
|
||||
public static handleIteration(message, shouldReadLogs, shouldCleanup, output) {
|
||||
public static handleIteration(message: string, shouldReadLogs: boolean, shouldCleanup: boolean, output: string) {
|
||||
if (message.includes(`---${CloudRunner.buildParameters.logId}`)) {
|
||||
CloudRunnerLogger.log('End of log transmission received');
|
||||
shouldReadLogs = false;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import path from 'path';
|
||||
import path from 'node:path';
|
||||
import { CloudRunnerFolders } from './cloud-runner-folders';
|
||||
import { CloudRunnerSystem } from './cloud-runner-system';
|
||||
import fs from 'fs';
|
||||
import { assert } from 'console';
|
||||
import fs from 'node:fs';
|
||||
import { assert } from 'node:console';
|
||||
import { Cli } from '../../cli/cli';
|
||||
import { CliFunction } from '../../cli/cli-functions-repository';
|
||||
|
||||
@@ -41,7 +41,7 @@ export class LfsHashing {
|
||||
|
||||
@CliFunction(`hash`, `hash all folder contents`)
|
||||
static async hash() {
|
||||
const folder = Cli.options['cachePushFrom'];
|
||||
const folder = Cli.options!['cachePushFrom'];
|
||||
LfsHashing.hashAllFiles(folder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CloudRunnerSystem } from './cloud-runner-system';
|
||||
import * as fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
import CloudRunnerLogger from './cloud-runner-logger';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import BuildParameters from '../../build-parameters';
|
||||
|
||||
@@ -44,20 +44,21 @@ export class TaskParameterSerializer {
|
||||
x.name = TaskParameterSerializer.ToEnvVarFormat(x.name);
|
||||
x.value = `${x.value}`;
|
||||
|
||||
if (buildParameters.cloudRunnerDebug && Number(x.name) === Number.NaN) {
|
||||
if (buildParameters.cloudRunnerDebug && Number.isNaN(Number(x.name))) {
|
||||
core.info(`[ERROR] found a number in task param serializer ${JSON.stringify(x)}`);
|
||||
}
|
||||
|
||||
return x;
|
||||
}),
|
||||
(item) => item.name,
|
||||
(item: CloudRunnerEnvironmentVariable) => item.name,
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static uniqBy(a, key) {
|
||||
const seen = {};
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
static uniqBy(a: CloudRunnerEnvironmentVariable[], key: (parameters: CloudRunnerEnvironmentVariable) => string) {
|
||||
const seen: { [key: string]: boolean } = {};
|
||||
|
||||
return a.filter(function (item) {
|
||||
const k = key(item);
|
||||
@@ -89,23 +90,23 @@ export class TaskParameterSerializer {
|
||||
return TaskParameterSerializer.serializeFromType(Input);
|
||||
}
|
||||
|
||||
public static ToEnvVarFormat(input): string {
|
||||
public static ToEnvVarFormat(input: string): string {
|
||||
return CloudRunnerOptions.ToEnvVarFormat(input);
|
||||
}
|
||||
|
||||
public static UndoEnvVarFormat(element): string {
|
||||
public static UndoEnvVarFormat(element: string): string {
|
||||
return this.camelize(element.replace('GAMECI_', '').toLowerCase().replace(/_+/g, ' '));
|
||||
}
|
||||
|
||||
private static camelize(string) {
|
||||
private static camelize(string: string) {
|
||||
return string
|
||||
.replace(/^\w|[A-Z]|\b\w/g, function (word, index) {
|
||||
.replace(/(^\w)|([A-Z])|(\b\w)/g, function (word: string, index: number) {
|
||||
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
||||
})
|
||||
.replace(/\s+/g, '');
|
||||
}
|
||||
|
||||
private static serializeFromObject(buildParameters) {
|
||||
private static serializeFromObject(buildParameters: any) {
|
||||
const array: any[] = [];
|
||||
const keys = Object.getOwnPropertyNames(buildParameters).filter((x) => !this.blocked.has(x));
|
||||
for (const element of keys) {
|
||||
@@ -124,7 +125,7 @@ export class TaskParameterSerializer {
|
||||
return array;
|
||||
}
|
||||
|
||||
private static serializeFromType(type) {
|
||||
private static serializeFromType(type: any) {
|
||||
const array: any[] = [];
|
||||
const input = CloudRunnerOptionsReader.GetProperties();
|
||||
for (const element of input) {
|
||||
@@ -149,14 +150,15 @@ export class TaskParameterSerializer {
|
||||
|
||||
return array;
|
||||
}
|
||||
private static getValue(key) {
|
||||
|
||||
private static getValue(key: string) {
|
||||
return CloudRunnerQueryOverride.queryOverrides !== undefined &&
|
||||
CloudRunnerQueryOverride.queryOverrides[key] !== undefined
|
||||
? CloudRunnerQueryOverride.queryOverrides[key]
|
||||
: process.env[key];
|
||||
}
|
||||
s;
|
||||
private static tryAddInput(array, key): CloudRunnerSecret[] {
|
||||
|
||||
private static tryAddInput(array: CloudRunnerSecret[], key: string): CloudRunnerSecret[] {
|
||||
const value = TaskParameterSerializer.getValue(key);
|
||||
if (value !== undefined && value !== '' && value !== 'null') {
|
||||
array.push({
|
||||
|
||||
@@ -4,8 +4,9 @@ import UnityVersioning from '../../unity-versioning';
|
||||
import { Cli } from '../../cli/cli';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) Cli.options = overrides;
|
||||
|
||||
return BuildParameters.create();
|
||||
|
||||
@@ -4,8 +4,9 @@ import UnityVersioning from '../../unity-versioning';
|
||||
import { Cli } from '../../cli/cli';
|
||||
import GitHub from '../../github';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) {
|
||||
Cli.options = overrides;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import BuildParameters from '../../build-parameters';
|
||||
import { Cli } from '../../cli/cli';
|
||||
import UnityVersioning from '../../unity-versioning';
|
||||
|
||||
@@ -7,8 +7,9 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import { CloudRunnerCustomSteps } from '../services/cloud-runner-custom-steps';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) {
|
||||
Cli.options = overrides;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import * as fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) {
|
||||
Cli.options = overrides;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import * as fs from 'fs';
|
||||
import path from 'path';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { CloudRunnerFolders } from '../services/cloud-runner-folders';
|
||||
import SharedWorkspaceLocking from '../services/shared-workspace-locking';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) {
|
||||
Cli.options = overrides;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import { CloudRunnerSystem } from '../services/cloud-runner-system';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) {
|
||||
Cli.options = overrides;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@ import { Cli } from '../../cli/cli';
|
||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import setups from './cloud-runner-suite.test';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) Cli.options = overrides;
|
||||
|
||||
return BuildParameters.create();
|
||||
|
||||
@@ -7,8 +7,9 @@ import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import UnityVersioning from '../../unity-versioning';
|
||||
import BuildParameters from '../../build-parameters';
|
||||
import CloudRunner from '../cloud-runner';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
async function CreateParameters(overrides) {
|
||||
async function CreateParameters(overrides: OptionValues | undefined) {
|
||||
if (overrides) {
|
||||
Cli.options = overrides;
|
||||
}
|
||||
@@ -21,7 +22,7 @@ describe('Cloud Runner Locking', () => {
|
||||
it('Responds', () => {});
|
||||
if (CloudRunnerOptions.cloudRunnerDebug) {
|
||||
it(`Simple Locking Flow`, async () => {
|
||||
Cli.options.retainWorkspaces = true;
|
||||
Cli.options!.retainWorkspaces = true;
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
@@ -53,8 +54,8 @@ describe('Cloud Runner Locking', () => {
|
||||
expect(isExpectedLockedAfterReleasing).toBeTruthy();
|
||||
}, 150000);
|
||||
it.skip('All Locking Actions', async () => {
|
||||
Cli.options.retainWorkspaces = true;
|
||||
const overrides: any = {
|
||||
Cli.options!.retainWorkspaces = true;
|
||||
const overrides: OptionValues = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
||||
|
||||
@@ -4,56 +4,48 @@ import { CloudRunnerStepState } from '../cloud-runner-step-state';
|
||||
import { WorkflowInterface } from './workflow-interface';
|
||||
import * as core from '@actions/core';
|
||||
import { CloudRunnerCustomHooks } from '../services/cloud-runner-custom-hooks';
|
||||
import path from 'path';
|
||||
import path from 'node:path';
|
||||
import CloudRunner from '../cloud-runner';
|
||||
import CloudRunnerOptions from '../cloud-runner-options';
|
||||
import { CloudRunnerCustomSteps } from '../services/cloud-runner-custom-steps';
|
||||
|
||||
export class BuildAutomationWorkflow implements WorkflowInterface {
|
||||
async run(cloudRunnerStepState: CloudRunnerStepState) {
|
||||
try {
|
||||
return await BuildAutomationWorkflow.standardBuildAutomation(cloudRunnerStepState.image, cloudRunnerStepState);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
return await BuildAutomationWorkflow.standardBuildAutomation(cloudRunnerStepState.image, cloudRunnerStepState);
|
||||
}
|
||||
|
||||
private static async standardBuildAutomation(baseImage: any, cloudRunnerStepState: CloudRunnerStepState) {
|
||||
private static async standardBuildAutomation(baseImage: string, cloudRunnerStepState: CloudRunnerStepState) {
|
||||
// TODO accept post and pre build steps as yaml files in the repo
|
||||
try {
|
||||
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
|
||||
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
|
||||
|
||||
let output = '';
|
||||
let output = '';
|
||||
|
||||
output += await CloudRunnerCustomSteps.RunPreBuildSteps(cloudRunnerStepState);
|
||||
CloudRunnerLogger.logWithTime('Configurable pre build step(s) time');
|
||||
output += await CloudRunnerCustomSteps.RunPreBuildSteps(cloudRunnerStepState);
|
||||
CloudRunnerLogger.logWithTime('Configurable pre build step(s) time');
|
||||
|
||||
if (!CloudRunner.buildParameters.isCliMode) core.startGroup('build');
|
||||
CloudRunnerLogger.log(baseImage.toString());
|
||||
CloudRunnerLogger.logLine(` `);
|
||||
CloudRunnerLogger.logLine('Starting build automation job');
|
||||
if (!CloudRunner.buildParameters.isCliMode) core.startGroup('build');
|
||||
CloudRunnerLogger.log(baseImage);
|
||||
CloudRunnerLogger.logLine(` `);
|
||||
CloudRunnerLogger.logLine('Starting build automation job');
|
||||
|
||||
output += await CloudRunner.Provider.runTaskInWorkflow(
|
||||
CloudRunner.buildParameters.buildGuid,
|
||||
baseImage.toString(),
|
||||
BuildAutomationWorkflow.BuildWorkflow,
|
||||
`/${CloudRunnerFolders.buildVolumeFolder}`,
|
||||
`/${CloudRunnerFolders.buildVolumeFolder}/`,
|
||||
cloudRunnerStepState.environment,
|
||||
cloudRunnerStepState.secrets,
|
||||
);
|
||||
if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
|
||||
CloudRunnerLogger.logWithTime('Build time');
|
||||
output += await CloudRunner.Provider.runTaskInWorkflow(
|
||||
CloudRunner.buildParameters.buildGuid,
|
||||
baseImage.toString(),
|
||||
BuildAutomationWorkflow.BuildWorkflow,
|
||||
`/${CloudRunnerFolders.buildVolumeFolder}`,
|
||||
`/${CloudRunnerFolders.buildVolumeFolder}/`,
|
||||
cloudRunnerStepState.environment,
|
||||
cloudRunnerStepState.secrets,
|
||||
);
|
||||
if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
|
||||
CloudRunnerLogger.logWithTime('Build time');
|
||||
|
||||
output += await CloudRunnerCustomSteps.RunPostBuildSteps(cloudRunnerStepState);
|
||||
CloudRunnerLogger.logWithTime('Configurable post build step(s) time');
|
||||
output += await CloudRunnerCustomSteps.RunPostBuildSteps(cloudRunnerStepState);
|
||||
CloudRunnerLogger.logWithTime('Configurable post build step(s) time');
|
||||
|
||||
CloudRunnerLogger.log(`Cloud Runner finished running standard build automation`);
|
||||
CloudRunnerLogger.log(`Cloud Runner finished running standard build automation`);
|
||||
|
||||
return output;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private static get BuildWorkflow() {
|
||||
@@ -85,7 +77,7 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
|
||||
${BuildAutomationWorkflow.TreeCommand}`;
|
||||
}
|
||||
|
||||
private static setupCommands(builderPath) {
|
||||
private static setupCommands(builderPath: string) {
|
||||
const commands = `mkdir -p ${CloudRunnerFolders.ToLinuxFolder(
|
||||
CloudRunnerFolders.builderPathAbsolute,
|
||||
)} && git clone -q -b ${CloudRunner.buildParameters.cloudRunnerBranch} ${
|
||||
@@ -112,7 +104,7 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
|
||||
node ${builderPath} -m remote-cli-pre-build`;
|
||||
}
|
||||
|
||||
private static BuildCommands(builderPath) {
|
||||
private static BuildCommands(builderPath: string) {
|
||||
const distFolder = path.join(CloudRunnerFolders.builderPathAbsolute, 'dist');
|
||||
const ubuntuPlatformsFolder = path.join(CloudRunnerFolders.builderPathAbsolute, 'dist', 'platforms', 'ubuntu');
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ export interface WorkflowInterface {
|
||||
run(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
cloudRunnerStepState: CloudRunnerStepState,
|
||||
);
|
||||
): Promise<string>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user