feat(precheck): now includes a precheck for more generic runner execution

This commit is contained in:
Philipp Kunz 2022-10-24 21:23:14 +02:00
parent ad0e12bf7b
commit 93c7af6c91
5 changed files with 35 additions and 5 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@shipzone/npmci',
version: '4.0.11',
version: '4.1.0',
description: 'node and docker in gitlab ci on steroids'
}

24
ts/mod_precheck/index.ts Normal file
View File

@ -0,0 +1,24 @@
import * as plugins from './plugins.js';
import * as paths from '../npmci.paths.js';
import { logger } from '../npmci.logging.js';
import { Npmci } from '../npmci.classes.npmci.js';
export const handleCli = async (npmciRefArg: Npmci, argvArg: any) => {
logger.log('info', 'checking execution context');
const presentRunnerTags = process.env.CI_RUNNER_TAGS.split(',').map((stringArg) =>
stringArg.trim()
);
let allDesiredGitlabRunnerTagsPresent = true;
for (const desiredRunnerTag of npmciRefArg.npmciConfig.getConfig().gitlabRunnerTags) {
if (!presentRunnerTags.includes(desiredRunnerTag)) {
allDesiredGitlabRunnerTagsPresent = false;
logger.log(
'error',
`Desired runnerRag ${desiredRunnerTag} is missing in current execution context.`
);
}
}
if (!allDesiredGitlabRunnerTagsPresent) {
process.exit(1);
}
};

View File

@ -0,0 +1 @@
export * from '../npmci.plugins.js';

View File

@ -79,15 +79,16 @@ export class NpmciCli {
}
);
this.smartcli.addCommand('precheck').subscribe(async (argvArg) => {
const modPrecheck = await import('./mod_precheck/index.js');
await modPrecheck.handleCli(this.npmciRef, argvArg);
})
// trigger
this.smartcli.addCommand('ssh').subscribe(
async (argvArg) => {
const modSsh = await import('./mod_ssh/index.js');
await modSsh.handleCli(argvArg);
},
(err) => {
console.log(err);
process.exit(1);
}
);

View File

@ -20,6 +20,9 @@ export interface INpmciOptions {
dockerRegistryRepoMap: { [key: string]: string };
dockerBuildargEnvMap: { [key: string]: string };
// gitlab
gitlabRunnerTags: string[];
// urls
urlCloudly: string;
}
@ -57,6 +60,7 @@ export class NpmciConfig {
dockerRegistryRepoMap: {},
npmAccessLevel: 'private',
npmRegistryUrl: 'registry.npmjs.org',
gitlabRunnerTags: [],
dockerBuildargEnvMap: {},
urlCloudly: this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY'),
};