chore: load input from user and yaml
parent
f2868f89d8
commit
931dff7df8
|
|
@ -3,7 +3,7 @@ import * as assert from 'https://deno.land/std@0.144.0/testing/asserts.ts';
|
|||
import * as aws from 'https://deno.land/x/aws_api/client/mod.ts';
|
||||
import * as base64 from 'https://deno.land/std@0.145.0/encoding/base64.ts';
|
||||
import * as compress from 'https://deno.land/x/compress@v0.3.3/mod.ts';
|
||||
// import * as core from 'https://deno.land/x/deno_actions_core/mod.ts';
|
||||
// import * as core from 'https://deno.land/x/deno_actions_core@0.1.3/mod.ts';
|
||||
import * as fs from 'https://deno.land/std@0.142.0/node/fs/promises.ts';
|
||||
import * as fsSync from 'https://deno.land/std@0.142.0/fs/mod.ts';
|
||||
import * as k8s from 'https://deno.land/x/kubernetes_client/mod.ts';
|
||||
|
|
@ -17,11 +17,27 @@ import * as yaml from 'https://deno.land/std@0.145.0/encoding/yaml.ts';
|
|||
import { crypto } from 'https://deno.land/std@0.142.0/crypto/mod.ts';
|
||||
import { v4 as uuid } from 'https://deno.land/std@0.142.0/uuid/mod.ts';
|
||||
import * as http from 'https://deno.land/std@0.145.0/node/http.ts';
|
||||
import { Command } from 'https://deno.land/x/cmd@v1.2.0/commander/index.ts';
|
||||
|
||||
const core = {
|
||||
setFailed: () => {},
|
||||
info: () => {},
|
||||
error: () => {},
|
||||
info: console.log,
|
||||
error: (error) => console.error(error, error.stack),
|
||||
setFailed: (failure) => console.error('setFailed:', failure),
|
||||
|
||||
// Adapted from: https://github.com/actions/toolkit/blob/9b7bcb1567c9b7f134eb3c2d6bbf409a5106a956/packages/core/src/core.ts#L128
|
||||
getInput: (name, options) => {
|
||||
const val: string = Deno.env.get(`INPUT_${name.replace(/ /g, '_').toUpperCase()}`) || '';
|
||||
|
||||
if (options?.required && !val) {
|
||||
throw new Error(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
|
||||
if (options && options.trimWhitespace === false) {
|
||||
return val;
|
||||
}
|
||||
|
||||
return val.trim();
|
||||
},
|
||||
};
|
||||
|
||||
const exec = () => {
|
||||
|
|
@ -32,26 +48,17 @@ const getUnityChangeSet = () => {
|
|||
throw new Error('getUnityChangeSet is not implemented'); // unity-changeset'
|
||||
};
|
||||
|
||||
const waitUntil = async (function_: () => Promise, options = {}) => {
|
||||
const { timeout = 10000, interval = 1000 } = options;
|
||||
if (timeout || interval) {
|
||||
// TODO - do some timeout stuff here
|
||||
}
|
||||
|
||||
await function_();
|
||||
};
|
||||
|
||||
class Writable {
|
||||
constructor() {
|
||||
throw new Error('Writable is not implemented'); // stream
|
||||
}
|
||||
}
|
||||
|
||||
class Command {
|
||||
constructor() {
|
||||
throw new Error('Command is not implemented'); // commander-ts
|
||||
}
|
||||
}
|
||||
// class Command {
|
||||
// constructor() {
|
||||
// throw new Error('Command is not implemented'); // commander-ts
|
||||
// }
|
||||
// }
|
||||
|
||||
const __filename = path.fromFileUrl(import.meta.url);
|
||||
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ async function runMain() {
|
|||
// Set output
|
||||
await Output.setBuildVersion(buildParameters.buildVersion);
|
||||
} catch (error) {
|
||||
core.error(error);
|
||||
core.setFailed((error as Error).message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { path, __dirname } from '../dependencies.ts';
|
||||
import { path, __dirname, __filename } from '../dependencies.ts';
|
||||
|
||||
class Action {
|
||||
static get supportedPlatforms() {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ describe('Cloud Runner Caching', () => {
|
|||
await CloudRunnerSystem.Run(`tree ${cacheFolder}`);
|
||||
|
||||
// Compare validity to original hash
|
||||
expect(fs.readFileSync(path.resolve(testFolder, 'test.txt'), { encoding: 'utf8' }).toString()).toContain(
|
||||
expect(Deno.readTextFileSync(path.resolve(testFolder, 'test.txt'), { encoding: 'utf8' }).toString()).toContain(
|
||||
Cli.options.cacheKey,
|
||||
);
|
||||
fs.rmdirSync(testFolder, { recursive: true });
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { fs, assert, path } from '../../../dependencies.ts';
|
||||
import { fsSync as fs, assert, path } from '../../../dependencies.ts';
|
||||
import CloudRunner from '../cloud-runner.ts';
|
||||
import { CloudRunnerFolders } from '../services/cloud-runner-folders.ts';
|
||||
import { Caching } from './caching.ts';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export class ActionYamlReader {
|
|||
if (!fs.existsSync(filename)) {
|
||||
filename = path.join(__dirname, `..`, filename);
|
||||
}
|
||||
this.actionYamlParsed = yaml.parse(fs.readFileSync(filename).toString());
|
||||
this.actionYamlParsed = yaml.parse(Deno.readTextFileSync(filename));
|
||||
}
|
||||
public GetActionYamlValue(key: string) {
|
||||
return this.actionYamlParsed.inputs[key]?.description || 'No description found in action.yml';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { assert } from 'https://deno.land/std@0.142.0/testing/asserts.ts';
|
||||
import { fs } from '../../dependencies.ts';
|
||||
import { fsSync as fs } from '../../dependencies.ts';
|
||||
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system.ts';
|
||||
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger.ts';
|
||||
import Input from '../input.ts';
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ export function ReadLicense() {
|
|||
}
|
||||
const pipelineFile = path.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`);
|
||||
|
||||
return fs.existsSync(pipelineFile) ? yaml.parse(fs.readFileSync(pipelineFile, 'utf8')).env.UNITY_LICENSE : '';
|
||||
return fs.existsSync(pipelineFile) ? yaml.parse(Deno.readTextFileSync(pipelineFile, 'utf8')).env.UNITY_LICENSE : '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { fs, path, core } from '../dependencies.ts';
|
||||
import { fsSync as fs, path, core } from '../dependencies.ts';
|
||||
import { Cli } from './cli/cli.ts';
|
||||
import CloudRunnerQueryOverride from './cloud-runner/services/cloud-runner-query-override.ts';
|
||||
import Platform from './platform.ts';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { fs, path } from '../dependencies.ts';
|
||||
import { fsSync as fs, path } from '../dependencies.ts';
|
||||
|
||||
export default class UnityVersioning {
|
||||
static get versionPattern() {
|
||||
|
|
@ -19,7 +19,7 @@ export default class UnityVersioning {
|
|||
throw new Error(`Project settings file not found at "${filePath}". Have you correctly set the projectPath?`);
|
||||
}
|
||||
|
||||
return UnityVersioning.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
return UnityVersioning.parse(Deno.readTextFileSync(filePath, 'utf8'));
|
||||
}
|
||||
|
||||
static parse(projectVersionTxt) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue