Skip to content

Commit 9da9625

Browse files
committed
Merge remote-tracking branch 'origin/main' into mbg/start-proxy/deprecate-fallback
2 parents b67b5ab + 2b07ff4 commit 9da9625

17 files changed

Lines changed: 625 additions & 303 deletions

‎lib/entry-points.js‎

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

‎package-lock.json‎

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

‎package.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"@actions/artifact": "^5.0.3",
2424
"@actions/artifact-legacy": "npm:@actions/artifact@^1.1.2",
25-
"@actions/cache": "^5.2.0",
25+
"@actions/cache": "^5.3.0",
2626
"@actions/core": "^2.0.3",
2727
"@actions/exec": "^2.0.0",
2828
"@actions/github": "^8.0.1",
@@ -31,14 +31,14 @@
3131
"@actions/io": "^2.0.0",
3232
"@actions/tool-cache": "^3.0.1",
3333
"@octokit/core": "^7.0.8",
34-
"@octokit/plugin-paginate-rest": "^15.0.0",
34+
"@octokit/plugin-paginate-rest": "^16.0.0",
3535
"@octokit/plugin-rest-endpoint-methods": "^18.0.0",
3636
"@octokit/plugin-retry": "^8.1.1",
3737
"archiver": "^8.0.0",
38-
"follow-redirects": "^1.16.0",
38+
"follow-redirects": "^1.16.1",
3939
"get-folder-size": "^5.0.0",
4040
"https-proxy-agent": "^7.0.6",
41-
"js-yaml": "^5.4.2",
41+
"js-yaml": "^5.4.3",
4242
"jsonschema": "1.5.0",
4343
"long": "^5.3.2",
4444
"node-forge": "^1.4.0",
@@ -65,14 +65,14 @@
6565
"eslint-import-resolver-typescript": "^4.4.5",
6666
"eslint-plugin-github": "^6.1.2",
6767
"eslint-plugin-import-x": "^4.17.1",
68-
"eslint-plugin-jsdoc": "^65.0.1",
68+
"eslint-plugin-jsdoc": "^65.2.0",
6969
"eslint-plugin-no-async-foreach": "^0.1.1",
7070
"glob": "^13.0.6",
71-
"globals": "^17.12.0",
71+
"globals": "^17.13.0",
7272
"nock": "^14.0.17",
7373
"sinon": "^22.1.0",
7474
"typescript": "^6.0.3",
75-
"typescript-eslint": "^8.70.1"
75+
"typescript-eslint": "^8.71.1"
7676
},
7777
"overrides": {
7878
"@actions/tool-cache": {

‎pr-checks/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"@actions/core": "^2.0.3",
77
"@actions/github": "^8.0.1",
88
"@octokit/core": "^7.0.8",
9-
"@octokit/plugin-paginate-rest": ">=15.0.0",
9+
"@octokit/plugin-paginate-rest": ">=16.0.0",
1010
"@octokit/plugin-rest-endpoint-methods": "^18.0.0",
1111
"lite-matter": "^0.1.2",
12-
"mdast-util-from-markdown": "^2.0.3",
12+
"mdast-util-from-markdown": "^2.1.0",
1313
"semver": "^7.8.5",
1414
"yaml": "^2.9.1"
1515
},

‎src/action-common.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ import { getErrorMessage } from "./util";
1919

2020
setupTests(test);
2121

22+
for (const [key, displayName] of Object.entries(
23+
statusReport.ACTION_DISPLAY_NAMES,
24+
)) {
25+
test(`getDisplayActionName - '${displayName}' instead of '${key}'`, (t) => {
26+
t.is(statusReport.getDisplayActionName(key as ActionName), displayName);
27+
});
28+
}
29+
30+
test("getDisplayActionName - returns action name", (t) => {
31+
for (const actionName of Object.values(ActionName)) {
32+
if (statusReport.ACTION_DISPLAY_NAMES[actionName]) {
33+
continue;
34+
}
35+
36+
t.is(statusReport.getDisplayActionName(actionName), actionName);
37+
}
38+
});
39+
2240
interface RunInActionsTestOpts {
2341
runFn?: () => Promise<any>;
2442
expectedErrorMessage?: string;

‎src/actions-util.test.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import {
77
isAnalyzingPullRequest,
88
isDefaultSetup,
99
isDynamicWorkflow,
10+
printDebugLogs,
1011
} from "./actions-util";
1112
import { computeAutomationID } from "./api-client";
1213
import { EnvVar } from "./environment";
1314
import { getRunnerLogger } from "./logging";
14-
import { setupTests } from "./testing-utils";
15-
import { initializeEnvironment } from "./util";
15+
import { RecordingLogger, setupTests } from "./testing-utils";
16+
import { initializeEnvironment, withTmpDir } from "./util";
1617

1718
setupTests(test);
1819

@@ -100,6 +101,21 @@ test("computeAutomationID()", async (t) => {
100101
);
101102
});
102103

104+
test("printDebugLogs - doesn't throw when config doesn't have needed properties", async (t) => {
105+
const logger = new RecordingLogger();
106+
await t.notThrowsAsync(printDebugLogs(logger, {}));
107+
await t.notThrowsAsync(printDebugLogs(logger, { languages: [] }));
108+
await t.notThrowsAsync(printDebugLogs(logger, { dbLocation: "nowhere" }));
109+
});
110+
111+
test("printDebugLogs - doesn't throw when language db doesn't exist", async (t) =>
112+
withTmpDir(async (tmpDir) => {
113+
const logger = new RecordingLogger();
114+
await t.notThrowsAsync(
115+
printDebugLogs(logger, { dbLocation: tmpDir, languages: ["javascript"] }),
116+
);
117+
}));
118+
103119
test.serial("getPullRequestBranches() with pull request context", (t) => {
104120
withMockedContext(
105121
{

‎src/actions-util.ts‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as toolrunner from "@actions/exec/lib/toolrunner";
66
import * as github from "@actions/github";
77
import * as io from "@actions/io";
88

9-
import type { Config } from "./config-utils";
9+
import { hasConfigKey, type Config } from "./config/action-config";
1010
import { Env, EnvVar, ActionsEnvVars, ReadOnlyEnv } from "./environment";
1111
import { Logger } from "./logging";
1212
import {
@@ -131,28 +131,38 @@ export function getWorkflowEvent(env: Env = getEnv()): any {
131131
}
132132
}
133133

134-
export async function printDebugLogs(config: Config) {
134+
export async function printDebugLogs(logger: Logger, config: Partial<Config>) {
135+
if (
136+
!hasConfigKey(config, "languages") ||
137+
!hasConfigKey(config, "dbLocation")
138+
) {
139+
logger.debug(
140+
`Not printing debug logs, because the configuration does not include the 'languages' or 'dbLocation' fields.`,
141+
);
142+
return;
143+
}
144+
135145
for (const language of config.languages) {
136146
const databaseDirectory = getCodeQLDatabasePath(config, language);
137147
const logsDirectory = path.join(databaseDirectory, "log");
138148
if (!doesDirectoryExist(logsDirectory)) {
139-
core.info(`Directory ${logsDirectory} does not exist.`);
149+
logger.info(`Directory ${logsDirectory} does not exist.`);
140150
continue; // Skip this language database.
141151
}
142152

143153
const walkLogFiles = (dir: string) => {
144154
const entries = fs.readdirSync(dir, { withFileTypes: true });
145155
if (entries.length === 0) {
146-
core.info(`No debug logs found at directory ${logsDirectory}.`);
156+
logger.info(`No debug logs found at directory ${logsDirectory}.`);
147157
}
148158
for (const entry of entries) {
149159
if (entry.isFile()) {
150160
const absolutePath = path.resolve(dir, entry.name);
151-
core.startGroup(
161+
logger.startGroup(
152162
`CodeQL Debug Logs - ${language} - ${entry.name} from file at path ${absolutePath}`,
153163
);
154-
process.stdout.write(fs.readFileSync(absolutePath));
155-
core.endGroup();
164+
logger.info(fs.readFileSync(absolutePath, "utf-8"));
165+
logger.endGroup();
156166
} else if (entry.isDirectory()) {
157167
walkLogFiles(path.resolve(dir, entry.name));
158168
}

‎src/analyze.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getTemporaryDirectory } from "./actions-util";
99
import * as analyses from "./analyses";
1010
import { setupCppAutobuild } from "./autobuild";
1111
import { type CodeQL } from "./codeql";
12+
import type { ActionConfig } from "./config/action-config";
1213
import { defaultSuites } from "./config/db-config";
1314
import * as configUtils from "./config-utils";
1415
import {
@@ -171,7 +172,7 @@ async function shouldExtractLanguage(
171172
}
172173

173174
export function dbIsFinalized(
174-
config: configUtils.Config,
175+
config: ActionConfig<"dbLocation">,
175176
language: Language,
176177
logger: Logger,
177178
) {

‎src/codeql.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as api from "./api-client";
1515
import * as outputCache from "./cli/output-cache";
1616
import type { VersionInfo } from "./cli/types";
1717
import { CliError, wrapCliConfigurationError } from "./cli-errors";
18+
import type { ActionConfig } from "./config/action-config";
1819
import { appendExtraQueryExclusions, type Config } from "./config-utils";
1920
import { DocUrl } from "./doc-url";
2021
import { EnvVar, getEnv, exportEnvVar } from "./environment";
@@ -197,7 +198,7 @@ export interface CodeQL {
197198
diagnosticsExport(
198199
sarifFile: string,
199200
automationDetailsId: string | undefined,
200-
config: Config,
201+
config: ActionConfig<"tempDir">,
201202
): Promise<void>;
202203
/** Get the location of an extractor for the specified language. */
203204
resolveExtractor(language: Language): Promise<string>;
@@ -913,7 +914,7 @@ async function getCodeQLForCmd(
913914
async diagnosticsExport(
914915
sarifFile: string,
915916
automationDetailsId: string | undefined,
916-
config: Config,
917+
config: ActionConfig<"tempDir">,
917918
): Promise<void> {
918919
const args = [
919920
"diagnostics",
@@ -1237,7 +1238,9 @@ export async function getTrapCachingExtractorConfigArgsForLang(
12371238
*
12381239
* This will not exist if the configuration is being parsed in the Action.
12391240
*/
1240-
function getGeneratedCodeScanningConfigPath(config: Config): string {
1241+
function getGeneratedCodeScanningConfigPath(
1242+
config: ActionConfig<"tempDir">,
1243+
): string {
12411244
return path.resolve(config.tempDir, "user-config.yaml");
12421245
}
12431246

0 commit comments

Comments
 (0)