Skip to content

Commit

Permalink
Showing 9 changed files with 59 additions and 26 deletions.
18 changes: 9 additions & 9 deletions lib/config-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/external-queries.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/external-queries.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/external-queries.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/external-queries.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 35 additions & 6 deletions src/config-utils.ts
@@ -214,6 +214,7 @@ async function addRemoteQueries(
queryUses: string,
tempDir: string,
githubUrl: string,
logger: Logger,
configFile?: string) {

let tok = queryUses.split('@');
@@ -241,7 +242,8 @@ async function addRemoteQueries(
nwo,
ref,
githubUrl,
tempDir);
tempDir,
logger);

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

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

// Otherwise, must be a reference to another repo
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, githubUrl, configFile);
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, githubUrl, logger, configFile);
}

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

for (const query of queriesInput.split(',')) {
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, checkoutPath, githubUrl);
await parseQueryUses(
languages,
codeQL,
resultMap,
query,
tempDir,
checkoutPath,
githubUrl,
logger);
}
}

@@ -578,7 +590,15 @@ export async function getDefaultConfig(
const queries = {};
await addDefaultQueries(codeQL, languages, queries);
if (queriesInput) {
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl);
await addQueriesFromWorkflow(
codeQL,
queriesInput,
languages,
queries,
tempDir,
checkoutPath,
githubUrl,
logger);
}

return {
@@ -658,7 +678,15 @@ async function loadConfig(
// If queries were provided using `with` in the action configuration,
// they should take precedence over the queries in the config file
if (queriesInput) {
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl);
await addQueriesFromWorkflow(
codeQL,
queriesInput,
languages,
queries,
tempDir,
checkoutPath,
githubUrl,
logger);
} else if (QUERIES_PROPERTY in parsedYAML) {
if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) {
throw new Error(getQueriesInvalid(configFile));
@@ -675,6 +703,7 @@ async function loadConfig(
tempDir,
checkoutPath,
githubUrl,
logger,
configFile);
}
}
4 changes: 3 additions & 1 deletion src/external-queries.test.ts
@@ -3,6 +3,7 @@ import * as fs from "fs";
import * as path from "path";

import * as externalQueries from "./external-queries";
import { getRunnerLogger } from './logging';
import {setupTests} from './testing-utils';
import * as util from "./util";

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

// COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in the default branch
t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", ref, "COPYRIGHT")));
8 changes: 5 additions & 3 deletions src/external-queries.ts
@@ -1,18 +1,20 @@
import * as core from '@actions/core';
import * as toolrunnner from '@actions/exec/lib/toolrunner';
import * as fs from 'fs';
import * as path from 'path';

import { Logger } from './logging';

/**
* Check out repository at the given ref, and return the directory of the checkout.
*/
export async function checkoutExternalRepository(
repository: string,
ref: string,
githubUrl: string,
tempDir: string): Promise<string> {
tempDir: string,
logger: Logger): Promise<string> {

core.info('Checking out ' + repository);
logger.info('Checking out ' + repository);

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

0 comments on commit 8a821a9

Please sign in to comment.