Skip to content

Commit c0e8887

Browse files
committed
Throw a ConfigurationError if setup-codeql has run before init
1 parent 0002951 commit c0e8887

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

lib/init-action.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql-action.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/environment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export enum EnvVar {
4747
/** Whether the CodeQL Action has already warned the user about low disk space. */
4848
HAS_WARNED_ABOUT_DISK_SPACE = "CODEQL_ACTION_HAS_WARNED_ABOUT_DISK_SPACE",
4949

50+
/** Whether the `setup-codeql` action has been run. */
51+
SETUP_CODEQL_ACTION_HAS_RUN = "CODEQL_ACTION_SETUP_CODEQL_HAS_RUN",
52+
5053
/** Whether the init action has been run. */
5154
INIT_ACTION_HAS_RUN = "CODEQL_ACTION_INIT_HAS_RUN",
5255

src/init-action.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ async function run() {
201201
? await loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo)
202202
: {};
203203

204+
// Create a unique identifier for this run.
204205
const jobRunUuid = uuidV4();
205206
logger.info(`Job run UUID is ${jobRunUuid}.`);
206207
core.exportVariable(EnvVar.JOB_RUN_UUID, jobRunUuid);
@@ -229,6 +230,14 @@ async function run() {
229230
if (statusReportBase !== undefined) {
230231
await sendStatusReport(statusReportBase);
231232
}
233+
234+
// Throw a `ConfigurationError` if the `setup-codeql` action has been run.
235+
if (process.env[EnvVar.SETUP_CODEQL_ACTION_HAS_RUN] === "true") {
236+
throw new ConfigurationError(
237+
`The 'init' action should not be run in the same workflow as 'setup-codeql'.`,
238+
);
239+
}
240+
232241
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(
233242
gitHubVersion.type,
234243
);

src/setup-codeql-action.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ async function run(): Promise<void> {
152152

153153
core.setOutput("codeql-path", codeql.getPath());
154154
core.setOutput("codeql-version", (await codeql.getVersion()).version);
155+
156+
core.exportVariable(EnvVar.SETUP_CODEQL_ACTION_HAS_RUN, "true");
155157
} catch (unwrappedError) {
156158
const error = wrapError(unwrappedError);
157159
core.setFailed(error.message);

0 commit comments

Comments
 (0)