Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci][3PP License Check] Detect when dash-licenses exits with an internal error #12545

Merged
merged 1 commit into from
May 18, 2023
Merged
Changes from all commits
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
21 changes: 17 additions & 4 deletions scripts/check_3pp_licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const dashLicensesJar = path.resolve(__dirname, 'download/dash-licenses.jar');
const dashLicensesSummary = path.resolve(__dirname, '../dependency-check-summary.txt');
const dashLicensesBaseline = path.resolve(__dirname, '../dependency-check-baseline.json');
const dashLicensesUrl = 'https://repo.eclipse.org/service/local/artifact/maven/redirect?r=dash-licenses&g=org.eclipse.dash&a=org.eclipse.dash.licenses&v=LATEST';
const dashLicensesInternalError = 127;

// A Eclipse Foundation Gitlab Personal Access Token, generated by an Eclipse committer,
// is required to use dash-licenses in "review" mode. For more information see:
Expand Down Expand Up @@ -71,12 +72,21 @@ async function main() {
info(`Using "review" mode for project: ${project}`);
args.push('-review', '-token', personalAccessToken);
}
const dashError = getErrorFromStatus(spawn('java', args, {
stdio: ['ignore', 'ignore', 'inherit']
}));
const dashStatus = spawn('java', args, {
stdio: ['ignore', 'inherit', 'inherit']
});

const dashError = getErrorFromStatus(dashStatus);

if (dashError) {
warn(dashError);
if (dashStatus.status == dashLicensesInternalError) {
error(dashError);
error('Detected an internal error in dash-licenses - run inconclusive');
process.exit(dashLicensesInternalError);
}
warn(dashError);
}

const restricted = await getRestrictedDependenciesFromSummary(dashLicensesSummary);
if (restricted.length > 0) {
if (fs.existsSync(dashLicensesBaseline)) {
Expand Down Expand Up @@ -235,6 +245,9 @@ function getErrorFromStatus(status) {
if (typeof status.signal === 'string') {
return `Command ${prettyCommand(status)} exited with signal: ${status.signal}`;
} else if (status.status !== 0) {
if (status.status == dashLicensesInternalError) {
return `Command ${prettyCommand(status)} exit code (${status.status}) means dash-licenses has encountered an internal error`;
}
return `Command ${prettyCommand(status)} exited with code: ${status.status}`;
}
}
Expand Down