Skip to content

Commit d6402b7

Browse files
akurtakovCopilot
andcommitted
Include review request issue URLs in the license review comment
dash-licenses logs the URL of each review request (IP Lab GitLab issue) it creates, but these URLs are not part of the -summary CSV. Capture the tool output to a log file and parse the 'A review request was created / already exists <url>' lines, associating each URL with its dependency. The PR comment now links each unvetted dependency to its review request issue, and falls back to guidance when no request could be created. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent aa96eed commit d6402b7

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

.github/workflows/licensecheck.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ jobs:
123123
#
124124
echo ""
125125
echo "------ Checking project [org.eclipse.wildwebdeveloper] ------"
126-
java -jar $dashLicenseToolJar $dashArgs org.eclipse.wildwebdeveloper/package-lock.json
127-
currentStatus=$?
126+
# Tee the output to a log so the reporting step can extract the URLs of
127+
# the review requests that dash-licenses creates (they are logged to the
128+
# console but are not part of the -summary CSV file).
129+
java -jar $dashLicenseToolJar $dashArgs org.eclipse.wildwebdeveloper/package-lock.json 2>&1 | tee "$savePWD/target/dash/npm-review-log"
130+
currentStatus=${PIPESTATUS[0]}
128131
if [[ $currentStatus != 0 ]]; then
129132
exitStatus=$(($exitStatus + $currentStatus)) # Save for future
130133
fi
@@ -175,17 +178,47 @@ jobs:
175178
core.setFailed('The NPM license check failed but no restricted dependencies were found in the review summary.');
176179
return;
177180
}
181+
// dash-licenses creates a review request (an IP Lab GitLab issue) for
182+
// each unvetted dependency and logs its URL to the console. Parse the
183+
// captured log to associate each dependency id with its review URL.
184+
const reviewUrls = {};
185+
try {
186+
const log = fs.readFileSync('target/dash/npm-review-log', 'utf8');
187+
let currentId = null;
188+
for (const line of log.split('\n')) {
189+
const required = line.match(/A review is required for (.+?)\.\s*$/);
190+
if (required) {
191+
currentId = required[1].trim();
192+
continue;
193+
}
194+
const url = line.match(/A review request (?:was created|already exists)\s+(\S+)/);
195+
if (url && currentId) {
196+
reviewUrls[currentId] = url[1];
197+
currentId = null;
198+
}
199+
}
200+
} catch (err) {
201+
core.info(`No review log found to extract review request URLs: ${err}`);
202+
}
178203
const list = needsReview
179-
.map(fields => `- \`${fields[0]}\` (license: ${fields[1] || 'unknown'}, source: ${fields[3] || 'none'})`)
204+
.map(fields => {
205+
const url = reviewUrls[fields[0]];
206+
const link = url ? ` — [review request](${url})` : '';
207+
return `- \`${fields[0]}\` (license: ${fields[1] || 'unknown'}, source: ${fields[3] || 'none'})${link}`;
208+
})
180209
.join('\n');
210+
const anyReviewCreated = Object.keys(reviewUrls).length > 0;
211+
const footer = anyReviewCreated
212+
? 'A review request has been submitted to the Eclipse IP team for each dependency listed above (see the linked issues). These dependencies must be approved before this change can be merged.'
213+
: 'No review request could be created automatically (this happens for fork pull requests, where the GitLab token is unavailable). A committer can submit the review requests by commenting `/request-license-review` on this pull request. These dependencies must be approved before this change can be merged.';
181214
const body = [
182215
'## :warning: NPM dependency license review required',
183216
'',
184217
'The following NPM dependencies have licenses that are not yet vetted and require a review before they can be used:',
185218
'',
186219
list,
187220
'',
188-
'A review request has been submitted automatically to the Eclipse IP team. These dependencies must be approved before this change can be merged.',
221+
footer,
189222
].join('\n');
190223
core.summary.addRaw(body).write();
191224
const prNumber = context.issue && context.issue.number;
@@ -215,4 +248,5 @@ jobs:
215248
name: tools.wildwebdeveloper-npm-license-vetting-summary
216249
path: |
217250
target/dash/npm-review-summary
251+
target/dash/npm-review-log
218252
target/dash/summary

0 commit comments

Comments
 (0)