mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-02-05 08:59:09 +08: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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user