Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
5 changes: 5 additions & 0 deletions lib/init-action.js

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

37 changes: 36 additions & 1 deletion src/feature-flags/properties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as sinon from "sinon";
import * as api from "../api-client";
import { getRunnerLogger } from "../logging";
import { parseRepositoryNwo } from "../repository";
import { setupTests } from "../testing-utils";
import { RecordingLogger, setupTests } from "../testing-utils";

import * as properties from "./properties";

Expand Down Expand Up @@ -197,3 +197,38 @@ test.serial(
);
},
);

test.serial(
"loadPropertiesFromApi warns if a repository property name starts with the common prefix, but is not recognised by us",
async (t) => {
process.env["GITHUB_EVENT_NAME"] = "push";
const propertyName: string = `${properties.GITHUB_CODEQL_PROPERTY_PREFIX}unknown`;
sinon.stub(api, "getRepositoryProperties").resolves({
headers: {},
status: 200,
url: "",
data: [
{
property_name: propertyName,
value: "true",
},
] satisfies properties.GitHubPropertiesResponse,
});
const logger = new RecordingLogger();
const warningSpy = sinon.spy(logger, "warning");
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
const response = await properties.loadPropertiesFromApi(
logger,
mockRepositoryNwo,
);
t.deepEqual(response, {});
t.true(warningSpy.calledOnce);
t.assert(
warningSpy.firstCall.args[0]
.toString()
.startsWith(
`Found a repository property named '${propertyName}', which looks like a CodeQL Action repository property`,
),
);
},
);
14 changes: 14 additions & 0 deletions src/feature-flags/properties.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { isDynamicWorkflow } from "../actions-util";
import { getRepositoryProperties } from "../api-client";
import { Logger } from "../logging";
import { RepositoryNwo } from "../repository";

/** The common prefix that we expect all of our repository properties to have. */
export const GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";

/**
* Enumerates repository property names that have some meaning to us.
*/
Expand Down Expand Up @@ -123,6 +127,16 @@ export async function loadPropertiesFromApi(

if (isKnownPropertyName(property.property_name)) {
setProperty(properties, property.property_name, property.value, logger);
} else if (
property.property_name.startsWith(GITHUB_CODEQL_PROPERTY_PREFIX) &&
!isDynamicWorkflow()
) {
logger.warning(
`Found a repository property named '${property.property_name}', ` +
"which looks like a CodeQL Action repository property, " +
"but which is not understood by this version of the CodeQL Action. " +
"Do you need to update to a newer version?",
);
}
}

Expand Down
Loading