Address comments
This commit is contained in:
parent
aa53f64b85
commit
cd7eedd4a5
8 changed files with 20 additions and 7 deletions
2
lib/actions-util.js
generated
2
lib/actions-util.js
generated
|
|
@ -363,7 +363,7 @@ exports.getAutomationID = getAutomationID;
|
|||
function computeAutomationID(analysis_key, environment) {
|
||||
let automationID = `${analysis_key}/`;
|
||||
// the id has to be deterministic so we sort the fields
|
||||
if (environment !== undefined && environment !== "null") {
|
||||
if (environment) {
|
||||
const environmentObject = JSON.parse(environment);
|
||||
for (const entry of Object.entries(environmentObject).sort()) {
|
||||
if (typeof entry[1] === "string") {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
3
lib/actions-util.test.js
generated
3
lib/actions-util.test.js
generated
|
|
@ -76,6 +76,9 @@ ava_1.default("computeAutomationID()", async (t) => {
|
|||
// check non string environment values
|
||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"number": 1, "object": {"language": "javascript"}}');
|
||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/number:/object:/");
|
||||
// check undefined environment
|
||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", undefined);
|
||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
||||
});
|
||||
ava_1.default("prepareEnvironment() when a local run", (t) => {
|
||||
process.env.CODEQL_LOCAL_RUN = "false";
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -112,6 +112,16 @@ test("computeAutomationID()", async (t) => {
|
|||
actualAutomationID,
|
||||
".github/workflows/codeql-analysis.yml:analyze/number:/object:/"
|
||||
);
|
||||
|
||||
// check undefined environment
|
||||
actualAutomationID = actionsutil.computeAutomationID(
|
||||
".github/workflows/codeql-analysis.yml:analyze",
|
||||
undefined
|
||||
);
|
||||
t.deepEqual(
|
||||
actualAutomationID,
|
||||
".github/workflows/codeql-analysis.yml:analyze/"
|
||||
);
|
||||
});
|
||||
|
||||
test("prepareEnvironment() when a local run", (t) => {
|
||||
|
|
|
|||
|
|
@ -433,13 +433,13 @@ export async function getAutomationID(): Promise<string> {
|
|||
}
|
||||
|
||||
export function computeAutomationID(
|
||||
analysis_key: string | undefined,
|
||||
analysis_key: string,
|
||||
environment: string | undefined
|
||||
): string {
|
||||
let automationID = `${analysis_key}/`;
|
||||
|
||||
// the id has to be deterministic so we sort the fields
|
||||
if (environment !== undefined && environment !== "null") {
|
||||
if (environment) {
|
||||
const environmentObject = JSON.parse(environment);
|
||||
for (const entry of Object.entries(environmentObject).sort()) {
|
||||
if (typeof entry[1] === "string") {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export function populateRunAutomationDetails(
|
|||
|
||||
function getAutomationID(
|
||||
category: string | undefined,
|
||||
analysis_key: string | undefined,
|
||||
analysis_key: string,
|
||||
environment: string | undefined
|
||||
): string {
|
||||
if (category !== undefined) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue