mirror of
https://github.com/github/codeql-action.git
synced 2025-12-29 02:30:11 +08:00
Add a new function used to determine where to retrieve config from
This commit is contained in:
@@ -152,6 +152,18 @@ test("Octokit not used when reading local config", async t => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Remote and local configuration paths correctly identified", t => {
|
||||
// If the path starts with ./, look locally
|
||||
t.assert(configUtils.isLocal('./file'));
|
||||
t.assert(configUtils.isLocal('./file@name'));
|
||||
|
||||
// Otherwise, if the path contains @ (branch specifier), assume it's a remote repo
|
||||
t.false(configUtils.isLocal('octo-org/codeql-config/config.yaml@main'));
|
||||
|
||||
// Otherwise look locally (this is the fallback)
|
||||
t.assert(configUtils.isLocal('file'));
|
||||
});
|
||||
|
||||
function doInvalidInputTest(
|
||||
testName: string,
|
||||
inputFileContents: string,
|
||||
|
||||
@@ -250,6 +250,15 @@ function initConfig(): Config {
|
||||
return config;
|
||||
}
|
||||
|
||||
export function isLocal(configPath: string): boolean {
|
||||
// If the path starts with ./, look locally
|
||||
if (configPath.indexOf("./") === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (configPath.indexOf("@") === -1);
|
||||
}
|
||||
|
||||
function getConfigFolder(): string {
|
||||
return util.getRequiredEnvParam('RUNNER_TEMP');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user