Skip to content

Commit 8a821a9

Browse files
Add logger to checkoutExternalRepository
1 parent 1548b77 commit 8a821a9

9 files changed

Lines changed: 59 additions & 26 deletions

lib/config-utils.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/external-queries.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/external-queries.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/external-queries.test.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/external-queries.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ async function addRemoteQueries(
214214
queryUses: string,
215215
tempDir: string,
216216
githubUrl: string,
217+
logger: Logger,
217218
configFile?: string) {
218219

219220
let tok = queryUses.split('@');
@@ -241,7 +242,8 @@ async function addRemoteQueries(
241242
nwo,
242243
ref,
243244
githubUrl,
244-
tempDir);
245+
tempDir,
246+
logger);
245247

246248
const queryPath = tok.length > 2
247249
? path.join(checkoutPath, tok.slice(2).join('/'))
@@ -266,6 +268,7 @@ async function parseQueryUses(
266268
tempDir: string,
267269
checkoutPath: string,
268270
githubUrl: string,
271+
logger: Logger,
269272
configFile?: string) {
270273

271274
queryUses = queryUses.trim();
@@ -286,7 +289,7 @@ async function parseQueryUses(
286289
}
287290

288291
// Otherwise, must be a reference to another repo
289-
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, githubUrl, configFile);
292+
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, githubUrl, logger, configFile);
290293
}
291294

292295
// Regex validating stars in paths or paths-ignore entries.
@@ -547,10 +550,19 @@ async function addQueriesFromWorkflow(
547550
resultMap: { [language: string]: string[] },
548551
tempDir: string,
549552
checkoutPath: string,
550-
githubUrl: string) {
553+
githubUrl: string,
554+
logger: Logger) {
551555

552556
for (const query of queriesInput.split(',')) {
553-
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, checkoutPath, githubUrl);
557+
await parseQueryUses(
558+
languages,
559+
codeQL,
560+
resultMap,
561+
query,
562+
tempDir,
563+
checkoutPath,
564+
githubUrl,
565+
logger);
554566
}
555567
}
556568

@@ -578,7 +590,15 @@ export async function getDefaultConfig(
578590
const queries = {};
579591
await addDefaultQueries(codeQL, languages, queries);
580592
if (queriesInput) {
581-
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl);
593+
await addQueriesFromWorkflow(
594+
codeQL,
595+
queriesInput,
596+
languages,
597+
queries,
598+
tempDir,
599+
checkoutPath,
600+
githubUrl,
601+
logger);
582602
}
583603

584604
return {
@@ -658,7 +678,15 @@ async function loadConfig(
658678
// If queries were provided using `with` in the action configuration,
659679
// they should take precedence over the queries in the config file
660680
if (queriesInput) {
661-
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl);
681+
await addQueriesFromWorkflow(
682+
codeQL,
683+
queriesInput,
684+
languages,
685+
queries,
686+
tempDir,
687+
checkoutPath,
688+
githubUrl,
689+
logger);
662690
} else if (QUERIES_PROPERTY in parsedYAML) {
663691
if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) {
664692
throw new Error(getQueriesInvalid(configFile));
@@ -675,6 +703,7 @@ async function loadConfig(
675703
tempDir,
676704
checkoutPath,
677705
githubUrl,
706+
logger,
678707
configFile);
679708
}
680709
}

src/external-queries.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fs from "fs";
33
import * as path from "path";
44

55
import * as externalQueries from "./external-queries";
6+
import { getRunnerLogger } from './logging';
67
import {setupTests} from './testing-utils';
78
import * as util from "./util";
89

@@ -15,7 +16,8 @@ test("checkoutExternalQueries", async t => {
1516
"github/codeql-go",
1617
ref,
1718
'https://github.com',
18-
tmpDir);
19+
tmpDir,
20+
getRunnerLogger(true));
1921

2022
// COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in the default branch
2123
t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", ref, "COPYRIGHT")));

src/external-queries.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import * as core from '@actions/core';
21
import * as toolrunnner from '@actions/exec/lib/toolrunner';
32
import * as fs from 'fs';
43
import * as path from 'path';
54

5+
import { Logger } from './logging';
6+
67
/**
78
* Check out repository at the given ref, and return the directory of the checkout.
89
*/
910
export async function checkoutExternalRepository(
1011
repository: string,
1112
ref: string,
1213
githubUrl: string,
13-
tempDir: string): Promise<string> {
14+
tempDir: string,
15+
logger: Logger): Promise<string> {
1416

15-
core.info('Checking out ' + repository);
17+
logger.info('Checking out ' + repository);
1618

1719
const checkoutLocation = path.join(tempDir, repository, ref);
1820

0 commit comments

Comments
 (0)