Skip to content

Commit f0c1869

Browse files
committed
Enhanced License Check
- As we are getting blacklisted from data websites, we have to limit the usage - Now the check can be executed manually using /check-license comment - It will be still manually executed daily on main branch - It can be executed also from the Actions menu - Removed staging profile - Switched to Temurin JDK Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
1 parent ad3d833 commit f0c1869

1 file changed

Lines changed: 60 additions & 16 deletions

File tree

.github/workflows/maven.yml

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
2+
# Copyright (c) 2022, 2026 Contributors to the Eclipse Foundation
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Eclipse Public License v. 2.0 which is available at
@@ -9,42 +9,86 @@
99
#
1010
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
1111
#
12-
13-
name: Eclipse Required License Check
14-
15-
on: [push, pull_request]
16-
12+
name: License Check
13+
on:
14+
workflow_dispatch:
15+
schedule:
16+
- cron: "0 5 * * *"
17+
issue_comment:
18+
types: [created]
19+
permissions:
20+
contents: read
21+
pull-requests: write
1722
jobs:
1823
build:
24+
if: >
25+
github.event_name != 'issue_comment' ||
26+
(github.event.issue.pull_request &&
27+
contains(github.event.comment.body, '/check-license') ||
28+
contains(github.event.comment.body, '/license-check')
29+
)
1930
name: Build on JDK ${{ matrix.java_version }} with ${{matrix.test_profiles}} profile
2031
runs-on: ubuntu-latest
2132
env:
2233
script-directory: $GITHUB_WORKSPACE/etc/jenkins
23-
2434
strategy:
2535
matrix:
2636
java_version: [ 21 ]
27-
verify_profiles: [ '-Plicense_check,staging' ]
28-
continue-on-error: false
29-
37+
verify_profiles: [ '-Plicense_check' ]
3038
steps:
39+
- name: Get PR ref
40+
if: github.event_name == 'issue_comment'
41+
id: pr
42+
uses: actions/github-script@v7
43+
with:
44+
script: |
45+
const pr = await github.rest.pulls.get({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
pull_number: context.issue.number
49+
});
50+
core.setOutput('ref', pr.data.head.sha);
3151
- name: Checkout for build
3252
uses: actions/checkout@v4
3353
with:
3454
fetch-depth: 0
55+
ref: ${{ steps.pr.outputs.ref || github.ref }}
3556
- name: Set up JDK
3657
uses: actions/setup-java@v4.1.0
3758
with:
38-
distribution: 'zulu'
59+
distribution: 'temurin'
3960
java-version: ${{ matrix.java_version }}
40-
- name: configure JDK
41-
run: |
42-
secLoc=`find $JAVA_HOME -name java.security`
43-
sed -i 's/jdk.tls.disabledAlgorithms/# jdk.tls.disabledAlgorithms/g' -i $secLoc
4461
- name: Build
45-
run: mvn -V -U -B ${{matrix.verify_profiles}} org.eclipse.dash:license-tool-plugin:license-check -DexcludeArtifactIds=bsh,jmh-core,jmh-generator-annprocess,swing-layout -pl '!:version-agnostic'
62+
id: license-check
63+
run: mvn -ntp -V -U -B ${{matrix.verify_profiles}} org.eclipse.dash:license-tool-plugin:license-check -DexcludeArtifactIds=bsh,jmh-core,jmh-generator-annprocess,swing-layout -pl '!:version-agnostic'
64+
continue-on-error: true
4665
- name: Upload license-check info
4766
uses: actions/upload-artifact@v4
4867
with:
4968
name: license-summary.txt
5069
path: target/dash/summary
70+
- name: Post license summary to PR
71+
if: github.event_name == 'issue_comment'
72+
uses: actions/github-script@v7
73+
with:
74+
script: |
75+
const fs = require('fs');
76+
const path = 'target/dash/summary';
77+
let body = '### 📋 Eclipse License Check\n\n';
78+
if (fs.existsSync(path)) {
79+
const content = fs.readFileSync(path, 'utf8').slice(0, 60000);
80+
const status = '${{ steps.license-check.outcome }}' === 'success' ? '✅ Passed' : '⚠️ Issues found (non-blocking) — see the run log for details';
81+
body += `**Status:** ${status}\n\n<details><summary>Full summary</summary>\n\n\`\`\`\n${content}\n\`\`\`\n</details>`;
82+
} else {
83+
const status = '${{ steps.license-check.outcome }}' === 'success' ? '✅ Passed' : '⚠️ Failed (non-blocking) — no summary file produced, check the run log';
84+
body += `**Status:** ${status}`;
85+
}
86+
const { data: comments } = await github.rest.issues.listComments({
87+
owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number
88+
});
89+
const existing = comments.find(c => c.body.startsWith('### 📋 Eclipse License Check'));
90+
if (existing) {
91+
await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body });
92+
} else {
93+
await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body });
94+
}

0 commit comments

Comments
 (0)