Address comments

This commit is contained in:
David Verdeguer 2021-05-05 12:30:20 +02:00
parent aa53f64b85
commit cd7eedd4a5
8 changed files with 20 additions and 7 deletions

2
lib/actions-util.js generated
View file

@ -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

View file

@ -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

View file

@ -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) => {

View file

@ -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") {

View file

@ -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) {