Skip to content

Commit 527501d

Browse files
committed
Allow createStatusReportBase to accept a Partial<Config>
1 parent 8301b8b commit 527501d

File tree

9 files changed

+60
-17
lines changed

9 files changed

+60
-17
lines changed

lib/analyze-action.js

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

lib/autobuild-action.js

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

lib/init-action-post.js

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

lib/init-action.js

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

lib/resolve-environment-action.js

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

lib/start-proxy-action.js

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

lib/upload-sarif-action.js

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

src/status-report.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,49 @@ test("createStatusReportBase", async (t) => {
9292
});
9393
});
9494

95+
test("createStatusReportBase - empty configuration", async (t) => {
96+
await withTmpDir(async (tmpDir: string) => {
97+
setupEnvironmentAndStub(tmpDir);
98+
99+
const statusReport = await createStatusReportBase(
100+
ActionName.StartProxy,
101+
"success",
102+
new Date("May 19, 2023 05:19:00"),
103+
{},
104+
{ numAvailableBytes: 100, numTotalBytes: 500 },
105+
getRunnerLogger(false),
106+
);
107+
108+
if (t.truthy(statusReport)) {
109+
t.is(statusReport.action_name, ActionName.StartProxy);
110+
t.is(statusReport.status, "success");
111+
}
112+
});
113+
});
114+
115+
test("createStatusReportBase - partial configuration", async (t) => {
116+
await withTmpDir(async (tmpDir: string) => {
117+
setupEnvironmentAndStub(tmpDir);
118+
119+
const statusReport = await createStatusReportBase(
120+
ActionName.StartProxy,
121+
"success",
122+
new Date("May 19, 2023 05:19:00"),
123+
{
124+
languages: ["go"],
125+
},
126+
{ numAvailableBytes: 100, numTotalBytes: 500 },
127+
getRunnerLogger(false),
128+
);
129+
130+
if (t.truthy(statusReport)) {
131+
t.is(statusReport.action_name, ActionName.StartProxy);
132+
t.is(statusReport.status, "success");
133+
t.is(statusReport.languages, "go");
134+
}
135+
});
136+
});
137+
95138
test("createStatusReportBase_firstParty", async (t) => {
96139
await withTmpDir(async (tmpDir: string) => {
97140
setupEnvironmentAndStub(tmpDir);

src/status-report.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export async function createStatusReportBase(
260260
actionName: ActionName,
261261
status: ActionStatus,
262262
actionStartedAt: Date,
263-
config: Config | undefined,
263+
config: Partial<Config> | undefined,
264264
diskInfo: DiskUsage | undefined,
265265
logger: Logger,
266266
cause?: string,
@@ -299,7 +299,7 @@ export async function createStatusReportBase(
299299
action_ref: actionRef,
300300
action_started_at: actionStartedAt.toISOString(),
301301
action_version: getActionVersion(),
302-
analysis_kinds: config?.analysisKinds.join(","),
302+
analysis_kinds: config?.analysisKinds?.join(","),
303303
analysis_key,
304304
build_mode: config?.buildMode,
305305
commit_oid: commitOid,
@@ -324,7 +324,7 @@ export async function createStatusReportBase(
324324
}
325325

326326
if (config) {
327-
statusReport.languages = config.languages.join(",");
327+
statusReport.languages = config.languages?.join(",");
328328
}
329329

330330
if (diskInfo) {

0 commit comments

Comments
 (0)