Skip to content

Commit 1d3f876

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 fe1ae47 commit 1d3f876

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
@@ -125,8 +125,11 @@ jobs:
125125
#
126126
echo ""
127127
echo "------ Checking project [org.eclipse.wildwebdeveloper] ------"
128-
java -jar $dashLicenseToolJar $dashArgs org.eclipse.wildwebdeveloper/package-lock.json
129-
currentStatus=$?
128+
# Tee the output to a log so the reporting step can extract the URLs of
129+
# the review requests that dash-licenses creates (they are logged to the
130+
# console but are not part of the -summary CSV file).
131+
java -jar $dashLicenseToolJar $dashArgs org.eclipse.wildwebdeveloper/package-lock.json 2>&1 | tee "$savePWD/target/dash/npm-review-log"
132+
currentStatus=${PIPESTATUS[0]}
130133
if [[ $currentStatus != 0 ]]; then
131134
exitStatus=$(($exitStatus + $currentStatus)) # Save for future
132135
fi
@@ -177,17 +180,47 @@ jobs:
177180
core.setFailed('The NPM license check failed but no restricted dependencies were found in the review summary.');
178181
return;
179182
}
183+
// dash-licenses creates a review request (an IP Lab GitLab issue) for
184+
// each unvetted dependency and logs its URL to the console. Parse the
185+
// captured log to associate each dependency id with its review URL.
186+
const reviewUrls = {};
187+
try {
188+
const log = fs.readFileSync('target/dash/npm-review-log', 'utf8');
189+
let currentId = null;
190+
for (const line of log.split('\n')) {
191+
const required = line.match(/A review is required for (.+?)\.\s*$/);
192+
if (required) {
193+
currentId = required[1].trim();
194+
continue;
195+
}
196+
const url = line.match(/A review request (?:was created|already exists)\s+(\S+)/);
197+
if (url && currentId) {
198+
reviewUrls[currentId] = url[1];
199+
currentId = null;
200+
}
201+
}
202+
} catch (err) {
203+
core.info(`No review log found to extract review request URLs: ${err}`);
204+
}
180205
const list = needsReview
181-
.map(fields => `- \`${fields[0]}\` (license: ${fields[1] || 'unknown'}, source: ${fields[3] || 'none'})`)
206+
.map(fields => {
207+
const url = reviewUrls[fields[0]];
208+
const link = url ? ` — [review request](${url})` : '';
209+
return `- \`${fields[0]}\` (license: ${fields[1] || 'unknown'}, source: ${fields[3] || 'none'})${link}`;
210+
})
182211
.join('\n');
212+
const anyReviewCreated = Object.keys(reviewUrls).length > 0;
213+
const footer = anyReviewCreated
214+
? '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.'
215+
: '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.';
183216
const body = [
184217
'## :warning: NPM dependency license review required',
185218
'',
186219
'The following NPM dependencies have licenses that are not yet vetted and require a review before they can be used:',
187220
'',
188221
list,
189222
'',
190-
'A review request has been submitted automatically to the Eclipse IP team. These dependencies must be approved before this change can be merged.',
223+
footer,
191224
].join('\n');
192225
core.summary.addRaw(body).write();
193226
const prNumber = context.issue && context.issue.number;
@@ -217,4 +250,5 @@ jobs:
217250
name: tools.wildwebdeveloper-npm-license-vetting-summary
218251
path: |
219252
target/dash/npm-review-summary
253+
target/dash/npm-review-log
220254
target/dash/summary

0 commit comments

Comments
 (0)