rename CLI to runner

This commit is contained in:
Robert Brignull 2020-08-24 14:21:03 +01:00
parent fe756603d9
commit 09677dada5
23 changed files with 56 additions and 56 deletions

View file

@ -4,7 +4,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as fingerprints from './fingerprints';
import { getCLILogger } from './logging';
import { getRunnerLogger } from './logging';
import {setupTests} from './testing-utils';
setupTests(test);
@ -116,7 +116,7 @@ test('hash', (t: ava.Assertions) => {
function testResolveUriToFile(uri: any, index: any, artifactsURIs: any[]) {
const location = { "uri": uri, "index": index };
const artifacts = artifactsURIs.map(uri => ({ "location": { "uri": uri } }));
return fingerprints.resolveUriToFile(location, artifacts, getCLILogger());
return fingerprints.resolveUriToFile(location, artifacts, getRunnerLogger());
}
test('resolveUriToFile', t => {
@ -175,7 +175,7 @@ test('addFingerprints', t => {
// The URIs in the SARIF files resolve to files in the testdata directory
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
t.deepEqual(fingerprints.addFingerprints(input, getCLILogger()), expected);
t.deepEqual(fingerprints.addFingerprints(input, getRunnerLogger()), expected);
});
test('missingRegions', t => {
@ -190,5 +190,5 @@ test('missingRegions', t => {
// The URIs in the SARIF files resolve to files in the testdata directory
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
t.deepEqual(fingerprints.addFingerprints(input, getCLILogger()), expected);
t.deepEqual(fingerprints.addFingerprints(input, getRunnerLogger()), expected);
});

View file

@ -14,7 +14,7 @@ export function getActionsLogger(): Logger {
return core;
}
export function getCLILogger(): Logger {
export function getRunnerLogger(): Logger {
return {
debug: console.debug,
info: console.info,

View file

@ -1,7 +1,7 @@
import { Command } from 'commander';
import * as path from 'path';
import { getCLILogger } from './logging';
import { getRunnerLogger } from './logging';
import { parseRepositoryNwo } from './repository';
import * as upload_lib from './upload-lib';
@ -40,7 +40,7 @@ function parseGithubApiUrl(inputUrl: string): string {
}
}
const logger = getCLILogger();
const logger = getRunnerLogger();
program
.command('upload')
@ -66,7 +66,7 @@ program
undefined,
cmd.githubAuth,
parseGithubApiUrl(cmd.githubUrl),
'cli',
'runner',
logger);
} catch (e) {
logger.error('Upload failed');

View file

@ -1,6 +1,6 @@
import test from 'ava';
import { getCLILogger } from './logging';
import { getRunnerLogger } from './logging';
import {setupTests} from './testing-utils';
import * as uploadLib from './upload-lib';
@ -8,10 +8,10 @@ setupTests(test);
test('validateSarifFileSchema - valid', t => {
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, getCLILogger()));
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger()));
});
test('validateSarifFileSchema - invalid', t => {
const inputFile = __dirname + '/../src/testdata/invalid-sarif.sarif';
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, getCLILogger()));
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger()));
});

View file

@ -12,7 +12,7 @@ import { RepositoryNwo } from './repository';
import * as sharedEnv from './shared-environment';
import * as util from './util';
type UploadMode = 'actions' | 'cli';
type UploadMode = 'actions' | 'runner';
// Takes a list of paths to sarif files and combines them together,
// returning the contents of the combined sarif file.
@ -221,7 +221,7 @@ async function uploadFiles(
logger.info("Uploading sarif files: " + JSON.stringify(sarifFiles));
if (mode === 'actions') {
// This check only works on actions as env vars don't persist between calls to the CLI
// This check only works on actions as env vars don't persist between calls to the runner
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
if (process.env[sentinelEnvVar]) {
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");