Skip to content

Commit

Permalink
Merge pull request #876 from github/aeisenberg/multi-init
Browse files Browse the repository at this point in the history
Include better error message
  • Loading branch information
aeisenberg authored Jan 21, 2022
2 parents fdb92bb + 5e69ce8 commit 0dabead
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## [UNRELEASED]

No user facing changes.
- Display a better error message when encountering a workflow that runs the `codeql-action/init` action multiple times. [#876](https://github.com/github/codeql-action/pull/876)

## 1.0.29 - 21 Jan 2022

Expand All @@ -15,7 +15,7 @@ No user facing changes.

## 1.0.27 - 11 Jan 2022

- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`.
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`. [#855](https://github.com/github/codeql-action/pull/855)

## 1.0.26 - 10 Dec 2021

Expand Down
29 changes: 22 additions & 7 deletions lib/init.js

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

2 changes: 1 addition & 1 deletion lib/init.js.map

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

49 changes: 32 additions & 17 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,41 @@ export async function runInit(
): Promise<TracerConfig | undefined> {
fs.mkdirSync(config.dbLocation, { recursive: true });

if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
// Init a database cluster
await codeql.databaseInitCluster(
config.dbLocation,
config.languages,
sourceRoot,
processName,
processLevel
);
} else {
for (const language of config.languages) {
// Init language database
await codeql.databaseInit(
util.getCodeQLDatabasePath(config, language),
language,
sourceRoot
try {
if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
// Init a database cluster
await codeql.databaseInitCluster(
config.dbLocation,
config.languages,
sourceRoot,
processName,
processLevel
);
} else {
for (const language of config.languages) {
// Init language database
await codeql.databaseInit(
util.getCodeQLDatabasePath(config, language),
language,
sourceRoot
);
}
}
} catch (e) {
// Handle the situation where init is called twice
// for the same database in the same job.
if (
e instanceof Error &&
e.message?.includes("Refusing to create databases") &&
e.message.includes("exists and is not an empty directory.")
) {
throw new Error(
`Is the "init" action called twice in the same job? ${e.message}`
);
} else {
throw e;
}
}

return await getCombinedTracerConfig(config, codeql);
}

Expand Down

0 comments on commit 0dabead

Please sign in to comment.