Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4e81e29
Bump certifi in /python-setup/tests/poetry/python-3.8
dependabot[bot] Dec 8, 2022
6fec2ab
Merge pull request #1427 from github/dependabot/pip/python-setup/test…
aeisenberg Dec 8, 2022
0133049
Update changelog and version after v2.1.36
invalid-email-address Dec 8, 2022
e58b8d6
Update checked-in dependencies
invalid-email-address Dec 8, 2022
8960790
Merge pull request #1429 from github/mergeback/v2.1.36-to-main-a669cc59
cklin Dec 8, 2022
e67ad6a
Add telemetry for uploading failed runs
henrymercer Dec 8, 2022
a409f43
Handle non-string `with` inputs
henrymercer Dec 8, 2022
dc9c1c1
Add regression test for `upload: false`
henrymercer Dec 8, 2022
118e294
Record the stack trace if applicable
henrymercer Dec 8, 2022
5aced81
Update bundle version to `codeql-bundle-20221211`
henrymercer Dec 12, 2022
9438015
Add changelog note
henrymercer Dec 12, 2022
d827cf3
remove use of query-string package
nickfyson Dec 12, 2022
54d25f5
use .has for searchParams instead of checking for undefined
nickfyson Dec 12, 2022
53ab991
Merge pull request #1434 from github/nickfyson/remove-query-string
nickfyson Dec 12, 2022
b7b875e
Reuse existing fields in post-init status report
henrymercer Dec 12, 2022
dd7c3ef
Remove debugging log statements
henrymercer Dec 12, 2022
899bf9c
Merge pull request #1432 from github/henrymercer/init-post-telemetry
henrymercer Dec 12, 2022
ccee4c6
Add tests for CODE_SCANNING_REF
orhantoy Dec 13, 2022
f629dad
Merge branch 'main' into henrymercer/use-codeql-2.11.6
henrymercer Dec 13, 2022
b7028af
Make sure env is reset between tests
orhantoy Dec 13, 2022
37a4496
Merge pull request #1433 from github/henrymercer/use-codeql-2.11.6
henrymercer Dec 13, 2022
d58039a
Merge pull request #1435 from github/orhantoy/add-CODE_SCANNING_REF-t…
orhantoy Dec 13, 2022
10ca836
Update changelog for v2.1.37
invalid-email-address Dec 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add regression test for upload: false
  • Loading branch information
henrymercer committed Dec 9, 2022
commit dc9c1c1a512d194306b7db249b8a55b176c92d60
53 changes: 46 additions & 7 deletions lib/init-action-post-helper.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/init-action-post-helper.test.js.map

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

89 changes: 69 additions & 20 deletions src/init-action-post-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { parseRepositoryNwo } from "./repository";
import {
createFeatures,
getRecordingLogger,
LoggedMessage,
setupTests,
} from "./testing-utils";
import * as uploadLib from "./upload-lib";
Expand Down Expand Up @@ -111,6 +112,40 @@ test("uploads failed SARIF run for typical workflow", async (t) => {
await testFailedSarifUpload(t, actionsWorkflow, { category: "my-category" });
});

test("doesn't upload failed SARIF for workflow with upload: false", async (t) => {
const actionsWorkflow = createTestWorkflow([
{
name: "Checkout repository",
uses: "actions/checkout@v3",
},
{
name: "Initialize CodeQL",
uses: "github/codeql-action/init@v2",
with: {
languages: "javascript",
},
},
{
name: "Perform CodeQL Analysis",
uses: "github/codeql-action/analyze@v2",
with: {
category: "my-category",
upload: false,
},
},
]);
await testFailedSarifUpload(t, actionsWorkflow, {
expectedLogs: [
{
message:
"Won't upload a failed SARIF file since SARIF upload is disabled.",
type: "debug",
},
],
expectUpload: false,
});
});

test("uploading failed SARIF run fails when workflow does not reference github/codeql-action", async (t) => {
const actionsWorkflow = createTestWorkflow([
{
Expand Down Expand Up @@ -149,7 +184,15 @@ function createTestWorkflow(
async function testFailedSarifUpload(
t: ExecutionContext<unknown>,
actionsWorkflow: workflow.Workflow,
{ category }: { category?: string } = {}
{
category,
expectedLogs = [],
expectUpload = true,
}: {
category?: string;
expectedLogs?: LoggedMessage[];
expectUpload?: boolean;
} = {}
): Promise<void> {
const config = {
codeQLCmd: "codeql",
Expand Down Expand Up @@ -180,23 +223,29 @@ async function testFailedSarifUpload(
createFeatures([Feature.UploadFailedSarifEnabled]),
getRecordingLogger(messages)
);
t.deepEqual(messages, []);
t.true(
diagnosticsExportStub.calledOnceWith(sinon.match.string, category),
`Actual args were: ${diagnosticsExportStub.args}`
);
t.true(
uploadFromActions.calledOnceWith(
sinon.match.string,
sinon.match.string,
category,
sinon.match.any
),
`Actual args were: ${uploadFromActions.args}`
);
t.true(
waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
isUnsuccessfulExecution: true,
})
);
t.deepEqual(messages, expectedLogs);
if (expectUpload) {
t.true(
diagnosticsExportStub.calledOnceWith(sinon.match.string, category),
`Actual args were: ${diagnosticsExportStub.args}`
);
t.true(
uploadFromActions.calledOnceWith(
sinon.match.string,
sinon.match.string,
category,
sinon.match.any
),
`Actual args were: ${uploadFromActions.args}`
);
t.true(
waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
isUnsuccessfulExecution: true,
})
);
} else {
t.true(diagnosticsExportStub.notCalled);
t.true(uploadFromActions.notCalled);
t.true(waitForProcessing.notCalled);
}
}