|
1 | 1 | # |
2 | | -# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation |
| 2 | +# Copyright (c) 2022, 2026 Contributors to the Eclipse Foundation |
3 | 3 | # |
4 | 4 | # This program and the accompanying materials are made available under the |
5 | 5 | # terms of the Eclipse Public License v. 2.0 which is available at |
|
9 | 9 | # |
10 | 10 | # SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
11 | 11 | # |
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 |
17 | 22 | jobs: |
18 | 23 | 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 | + ) |
19 | 30 | name: Build on JDK ${{ matrix.java_version }} with ${{matrix.test_profiles}} profile |
20 | 31 | runs-on: ubuntu-latest |
21 | 32 | env: |
22 | 33 | script-directory: $GITHUB_WORKSPACE/etc/jenkins |
23 | | - |
24 | 34 | strategy: |
25 | 35 | matrix: |
26 | 36 | java_version: [ 21 ] |
27 | | - verify_profiles: [ '-Plicense_check,staging' ] |
28 | | - continue-on-error: false |
29 | | - |
| 37 | + verify_profiles: [ '-Plicense_check' ] |
30 | 38 | 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); |
31 | 51 | - name: Checkout for build |
32 | 52 | uses: actions/checkout@v4 |
33 | 53 | with: |
34 | 54 | fetch-depth: 0 |
| 55 | + ref: ${{ steps.pr.outputs.ref || github.ref }} |
35 | 56 | - name: Set up JDK |
36 | 57 | uses: actions/setup-java@v4.1.0 |
37 | 58 | with: |
38 | | - distribution: 'zulu' |
| 59 | + distribution: 'temurin' |
39 | 60 | 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 |
44 | 61 | - 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 |
46 | 65 | - name: Upload license-check info |
47 | 66 | uses: actions/upload-artifact@v4 |
48 | 67 | with: |
49 | 68 | name: license-summary.txt |
50 | 69 | 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