Skip to content

Commit

Permalink
Merge pull request #10 from github/autobuild_errors
Browse files Browse the repository at this point in the history
Improve errors & warnings in autobuild
  • Loading branch information
Max Veytsman authored and GitHub committed May 1, 2020
2 parents d46c1c7 + 984552a commit 5218f93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/autobuild.js

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

11 changes: 8 additions & 3 deletions src/autobuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ async function run() {
// We want pick the dominant language in the repo from the ones we're able to build
// The languages are sorted in order specified by user or by lines of code if we got
// them from the GitHub API, so try to build the first language on the list.
const language = process.env[sharedEnv.CODEQL_ACTION_TRACED_LANGUAGES]?.split(',')[0];
const autobuildLanguages = process.env[sharedEnv.CODEQL_ACTION_TRACED_LANGUAGES]?.split(',') || [];
const language = autobuildLanguages[0];

if (!language) {
core.info("None of the languages in this project require extra build steps");
Expand All @@ -24,6 +25,10 @@ async function run() {

core.debug(`Detected dominant traced language: ${language}`);

if (autobuildLanguages.length > 1) {
core.warning(`We will only automatically build ${language} code. If you wish to scan ${autobuildLanguages.slice(1).join(' and ')}, you must replace this block with custom build steps.`);
}

core.startGroup(`Attempting to automatically build ${language} code`);
// TODO: share config accross actions better via env variables
const codeqlCmd = util.getRequiredEnvParam(sharedEnv.CODEQL_ACTION_CMD);
Expand All @@ -44,7 +49,7 @@ async function run() {
core.endGroup();

} catch (error) {
core.setFailed(error.message);
core.setFailed("We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. " + error.message);
await util.reportActionFailed('autobuild', error.message, error.stack);
return;
}
Expand All @@ -53,6 +58,6 @@ async function run() {
}

run().catch(e => {
core.setFailed("autobuild action failed: " + e);
core.setFailed("autobuild action failed. " + e);
console.log(e);
});

0 comments on commit 5218f93

Please sign in to comment.