Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c05a5b7
Add `ActionsEnvVars` enum
mbg Jun 16, 2026
652296e
Allow abstracting over `process.env`
mbg Jun 16, 2026
9c4ee01
Add `RemoteFileAddress` type
mbg Jun 23, 2026
07b6b1e
Move `getRemoteConfig` to `config/file.ts`
mbg Jun 23, 2026
9ef8be7
Refactor `parseRemoteFileAddress` out of `getRemoteConfig`
mbg Jun 23, 2026
82e5ca6
Return `RemoteFileAddress` from `parseRemoteFileAddress`
mbg Jun 23, 2026
c7a94c9
Add `getRemoteConfig` JSDoc
mbg Jun 23, 2026
85c8a8c
Add tests for `parseRemoteFileAddress`
mbg Jun 23, 2026
598d008
Make `ref` optional in `parseRemoteFileAddress`
mbg Jun 23, 2026
e537ff2
Make `path` optional in `parseRemoteFileAddress`
mbg Jun 23, 2026
12821cf
Make `owner` optional in `parseRemoteFileAddress`
mbg Jun 23, 2026
81ad479
Fix test names
mbg Jun 23, 2026
8102fa6
Anchor regex and trim input
mbg Jun 23, 2026
00e5a58
Update format in error message
mbg Jun 23, 2026
8d69da9
Improve whitespace handling
mbg Jun 23, 2026
3fe7ef9
Fix `getEnv` not using `getOptionalEnvVarFrom`
mbg Jun 23, 2026
812b882
Merge remote-tracking branch 'origin/main' into mbg/repo-props/config…
mbg Jun 23, 2026
f77cf55
Support old and new formats
mbg Jun 26, 2026
d8d1d6d
Add FF for shorthands
mbg Jun 24, 2026
e446d55
Add initial `ActionState` type
mbg Jun 30, 2026
f86aa52
Use `ActionState` for `getRemoteConfig`
mbg Jun 30, 2026
7b2af89
Add `TestEnv` class to simplify testing of `ActionState`-dependent fu…
mbg Jun 30, 2026
b6be81d
Gate new remote file format behind FF
mbg Jun 30, 2026
708e106
Index `ActionState` over the types of state used
mbg Jun 30, 2026
5094019
Refactor `Config` type out of `config-utils`
mbg Jul 6, 2026
73f4741
Refactor pack registry code out of `config-utils`
mbg Jul 6, 2026
69c9e8c
Mark some `status-report` imports as `type`-only to avoid circular de…
mbg Jul 6, 2026
8e22350
Thread `ActionState` to `initConfig`
mbg Jul 6, 2026
7dc37cb
Merge remote-tracking branch 'origin/main' into mbg/repo-props/config…
mbg Jul 6, 2026
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
6,230 changes: 3,150 additions & 3,080 deletions lib/entry-points.js

Large diffs are not rendered by default.

71 changes: 29 additions & 42 deletions src/config-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
mockCodeQLVersion,
createTestConfig,
makeMacro,
initAllState,
} from "./testing-utils";
import {
GitHubVariant,
Expand Down Expand Up @@ -160,8 +161,9 @@ test.serial("load empty config", async (t) => {
},
});

const state = initAllState({ logger });
const config = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput: languages,
repository: { owner: "github", repo: "example" },
Expand Down Expand Up @@ -202,8 +204,9 @@ test.serial("load code quality config", async (t) => {
},
});

const state = initAllState({ logger });
const config = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
analysisKinds: [AnalysisKind.CodeQuality],
languagesInput: languages,
Expand Down Expand Up @@ -280,9 +283,10 @@ test.serial(
repositoryProperties,
});

const state = initAllState({ logger });
await t.notThrowsAsync(async () => {
const config = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
analysisKinds: [AnalysisKind.CodeQuality],
languagesInput: languages,
Expand Down Expand Up @@ -321,8 +325,9 @@ test.serial("loading a saved config produces the same config", async (t) => {
// Sanity check that getConfig returns undefined before we have called initConfig
t.deepEqual(await configUtils.getConfig(tempDir, logger), undefined);

const state = initAllState({ logger });
const config1 = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput: "javascript,python",
tempDir,
Expand Down Expand Up @@ -373,8 +378,9 @@ test.serial("loading config with version mismatch throws", async (t) => {
.stub(actionsUtil, "getActionVersion")
.returns("does-not-exist");

const state = initAllState({ logger });
const config = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput: "javascript,python",
tempDir,
Expand Down Expand Up @@ -402,8 +408,9 @@ test.serial("loading config with version mismatch throws", async (t) => {
test.serial("load input outside of workspace", async (t) => {
return await withTmpDir(async (tempDir) => {
try {
const state = initAllState();
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
configFile: "../input",
tempDir,
Expand All @@ -424,43 +431,16 @@ test.serial("load input outside of workspace", async (t) => {
});
});

test.serial("load non-local input with invalid repo syntax", async (t) => {
return await withTmpDir(async (tempDir) => {
// no filename given, just a repo
const configFile = "octo-org/codeql-config@main";

try {
await configUtils.initConfig(
createFeatures([]),
createTestInitConfigInputs({
configFile,
tempDir,
workspacePath: tempDir,
}),
);
throw new Error("initConfig did not throw error");
} catch (err) {
t.deepEqual(
err,
new ConfigurationError(
errorMessages.getConfigFileRepoFormatInvalidMessage(
"octo-org/codeql-config@main",
),
),
);
}
});
});

test.serial("load non-existent input", async (t) => {
return await withTmpDir(async (tempDir) => {
const languagesInput = "javascript";
const configFile = "input";
t.false(fs.existsSync(path.join(tempDir, configFile)));

try {
const state = initAllState();
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput,
configFile,
Expand Down Expand Up @@ -536,8 +516,9 @@ test.serial("load non-empty input", async (t) => {
const languagesInput = "javascript";
const configFilePath = createConfigFile(inputFileContents, tempDir);

const state = initAllState();
const actualConfig = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput,
buildModeInput: "none",
Expand Down Expand Up @@ -595,8 +576,9 @@ test.serial(
// Only JS, python packs will be ignored
const languagesInput = "javascript";

const state = initAllState();
const config = await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput,
configFile: configFilePath,
Expand Down Expand Up @@ -647,8 +629,9 @@ test.serial("API client used when reading remote config", async (t) => {
const configFile = "octo-org/codeql-config/config.yaml@main";
const languagesInput = "javascript";

const state = initAllState();
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput,
configFile,
Expand All @@ -669,9 +652,10 @@ test.serial(
mockGetContents(dummyResponse);

const repoReference = "octo-org/codeql-config/config.yaml@main";
const state = initAllState();
try {
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
configFile: repoReference,
tempDir,
Expand Down Expand Up @@ -699,9 +683,10 @@ test.serial("Invalid format of remote config handled correctly", async (t) => {
mockGetContents(dummyResponse);

const repoReference = "octo-org/codeql-config/config.yaml@main";
const state = initAllState();
try {
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
configFile: repoReference,
tempDir,
Expand Down Expand Up @@ -729,9 +714,10 @@ test.serial("No detected languages", async (t) => {
},
});

const state = initAllState();
try {
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
tempDir,
codeql,
Expand All @@ -752,9 +738,10 @@ test.serial("Unknown languages", async (t) => {
return await withTmpDir(async (tempDir) => {
const languagesInput = "rubbish,english";

const state = initAllState();
try {
await configUtils.initConfig(
createFeatures([]),
state,
createTestInitConfigInputs({
languagesInput,
tempDir,
Expand Down
Loading
Loading