build(deps): Bump pmd.version from 7.24.0 to 7.25.0 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Bundle CI | |
| on: | |
| pull_request: | |
| paths: | |
| - 'extensions/**' | |
| - 'pom.xml' | |
| - 'checkstyle.xml' | |
| - 'pmd-ruleset.xml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| MAVEN_OPTS: >- | |
| -Xmx4g | |
| -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN | |
| jobs: | |
| detect-bundles: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| bundles: ${{ steps.find-bundles.outputs.bundles }} | |
| has_bundles: ${{ steps.find-bundles.outputs.has_bundles }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect Changed Bundles | |
| id: find-bundles | |
| run: | | |
| CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD) | |
| BUNDLES=() | |
| for file in $CHANGED_FILES; do | |
| if [[ "$file" == extensions/* ]]; then | |
| dir="$file" | |
| while [[ "$dir" != "extensions" && "$dir" != "." ]]; do | |
| if [[ -f "$dir/pom.xml" ]] && grep -q '<packaging>pom</packaging>' "$dir/pom.xml" 2>/dev/null; then | |
| if grep -q '<modules>' "$dir/pom.xml" 2>/dev/null; then | |
| BUNDLES+=("$dir") | |
| break | |
| fi | |
| fi | |
| dir=$(dirname "$dir") | |
| done | |
| fi | |
| done | |
| UNIQUE_BUNDLES=($(printf '%s\n' "${BUNDLES[@]}" | sort -u)) | |
| if [ ${#UNIQUE_BUNDLES[@]} -eq 0 ]; then | |
| echo "bundles=[]" >> $GITHUB_OUTPUT | |
| echo "has_bundles=false" >> $GITHUB_OUTPUT | |
| else | |
| JSON=$(printf '%s\n' "${UNIQUE_BUNDLES[@]}" | jq -R . | jq -sc .) | |
| echo "bundles=$JSON" >> $GITHUB_OUTPUT | |
| echo "has_bundles=true" >> $GITHUB_OUTPUT | |
| fi | |
| build: | |
| needs: detect-bundles | |
| if: needs.detect-bundles.outputs.has_bundles == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| bundle: ${{ fromJson(needs.detect-bundles.outputs.bundles) }} | |
| name: Build ${{ matrix.bundle }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| - name: Set up Java 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'corretto' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Build, Verify, and Generate Coverage | |
| run: > | |
| ./mvnw clean verify | |
| -Pcontrib-check,report-code-coverage | |
| -f ${{ matrix.bundle }}/pom.xml | |
| --show-version | |
| --no-snapshot-updates | |
| --no-transfer-progress | |
| --fail-fast | |
| - name: Post Coverage Summary on PR | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const bundlePath = '${{ matrix.bundle }}'; | |
| const bundleName = path.basename(bundlePath); | |
| const globber = await glob.create(`${bundlePath}/**/target/site/jacoco/jacoco.xml`); | |
| const files = await globber.glob(); | |
| if (files.length === 0) { | |
| core.info('No JaCoCo XML reports found'); | |
| return; | |
| } | |
| let totalInstructions = 0; | |
| let coveredInstructions = 0; | |
| let totalBranches = 0; | |
| let coveredBranches = 0; | |
| let totalLines = 0; | |
| let coveredLines = 0; | |
| const moduleReports = []; | |
| for (const file of files) { | |
| const content = fs.readFileSync(file, 'utf8'); | |
| const modulePath = path.relative(bundlePath, path.dirname(path.dirname(path.dirname(file)))); | |
| const counterRegex = /<counter type="(\w+)" missed="(\d+)" covered="(\d+)"\/>/g; | |
| let match; | |
| let moduleInstr = { missed: 0, covered: 0 }; | |
| let moduleBranch = { missed: 0, covered: 0 }; | |
| let moduleLine = { missed: 0, covered: 0 }; | |
| while ((match = counterRegex.exec(content)) !== null) { | |
| const [, type, missed, covered] = match; | |
| if (type === 'INSTRUCTION') { | |
| moduleInstr.missed += parseInt(missed); | |
| moduleInstr.covered += parseInt(covered); | |
| } else if (type === 'BRANCH') { | |
| moduleBranch.missed += parseInt(missed); | |
| moduleBranch.covered += parseInt(covered); | |
| } else if (type === 'LINE') { | |
| moduleLine.missed += parseInt(missed); | |
| moduleLine.covered += parseInt(covered); | |
| } | |
| } | |
| totalInstructions += moduleInstr.missed + moduleInstr.covered; | |
| coveredInstructions += moduleInstr.covered; | |
| totalBranches += moduleBranch.missed + moduleBranch.covered; | |
| coveredBranches += moduleBranch.covered; | |
| totalLines += moduleLine.missed + moduleLine.covered; | |
| coveredLines += moduleLine.covered; | |
| const lineTotal = moduleLine.missed + moduleLine.covered; | |
| const linePct = lineTotal > 0 ? ((moduleLine.covered / lineTotal) * 100).toFixed(1) : 'N/A'; | |
| moduleReports.push({ module: modulePath, linePct, lineTotal, lineCovered: moduleLine.covered }); | |
| } | |
| const overallLinePct = totalLines > 0 ? ((coveredLines / totalLines) * 100).toFixed(1) : 'N/A'; | |
| const overallBranchPct = totalBranches > 0 ? ((coveredBranches / totalBranches) * 100).toFixed(1) : 'N/A'; | |
| const overallInstrPct = totalInstructions > 0 ? ((coveredInstructions / totalInstructions) * 100).toFixed(1) : 'N/A'; | |
| const passFail = parseFloat(overallLinePct) >= 80.0 ? ':white_check_mark:' : ':x:'; | |
| let body = `## Code Coverage: \`${bundleName}\` ${passFail}\n\n`; | |
| body += `| Metric | Coverage |\n`; | |
| body += `|--------|----------|\n`; | |
| body += `| **Line** | **${overallLinePct}%** (${coveredLines}/${totalLines}) |\n`; | |
| body += `| Branch | ${overallBranchPct}% (${coveredBranches}/${totalBranches}) |\n`; | |
| body += `| Instruction | ${overallInstrPct}% (${coveredInstructions}/${totalInstructions}) |\n\n`; | |
| if (moduleReports.length > 1) { | |
| body += `<details><summary>Module Breakdown</summary>\n\n`; | |
| body += `| Module | Line Coverage |\n`; | |
| body += `|--------|---------------|\n`; | |
| for (const m of moduleReports) { | |
| body += `| ${m.module} | ${m.linePct}% (${m.lineCovered}/${m.lineTotal}) |\n`; | |
| } | |
| body += `\n</details>\n\n`; | |
| } | |
| body += `> Threshold: 80% line coverage required`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const marker = `Code Coverage: \`${bundleName}\``; | |
| const existing = comments.find(c => c.body && c.body.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } | |
| - name: Upload Coverage to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@v6 | |
| with: | |
| flags: ${{ hashFiles(format('{0}/pom.xml', matrix.bundle)) }} | |
| directory: ${{ matrix.bundle }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| continue-on-error: true | |
| - name: Upload Test Reports | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: surefire-reports-${{ hashFiles(format('{0}/pom.xml', matrix.bundle)) }} | |
| path: | | |
| ${{ matrix.bundle }}/**/target/surefire-reports/*.txt | |
| ${{ matrix.bundle }}/**/target/surefire-reports/*.xml | |
| retention-days: 7 | |
| if: failure() |