ci: only run spotbugs for changed modules #2651
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
| name: verify | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| jobs: | |
| # Job 1: PMD (runs independently and in parallel) | |
| pmd: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: PMD | |
| uses: pmd/pmd-github-action@v2.0.0 | |
| id: pmd | |
| with: | |
| version: '7.17.0' | |
| rulesets: 'ddk-configuration/pmd/ruleset.xml' | |
| analyzeModifiedFilesOnly: false | |
| - name: Fail build if there are violations | |
| if: steps.pmd.outputs.violations != 0 | |
| run: exit 1 | |
| # Job 2: Code Quality Checks (runs in parallel with PMD) | |
| code-quality: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Set up Maven | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: 3.9.11 | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Set up Workspace Environment Variable | |
| run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: /home/runner/.m2/repository | |
| key: ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }} | |
| - name: Run checkstyle, pmd, and cpd | |
| run: mvn -T 1.5C checkstyle:check pmd:check pmd:cpd-check -f ./ddk-parent/pom.xml --batch-mode --fail-at-end | |
| # Job 3: Compile and install (produces artifacts for verify and spotbugs) | |
| compile: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Set up Maven | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: 3.9.11 | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Set up Workspace Environment Variable | |
| run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: /home/runner/.m2/repository | |
| key: ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }} | |
| - name: Compile and install all modules | |
| run: mvn -T 1.5C clean install -f ./ddk-parent/pom.xml --batch-mode -DskipTests | |
| # Job 4: Maven verify (runs tests) | |
| maven-verify: | |
| runs-on: ubuntu-24.04 | |
| needs: compile | |
| steps: | |
| - name: Set up Maven | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: 3.9.11 | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Set up Workspace Environment Variable | |
| run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: /home/runner/.m2/repository | |
| key: ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }} | |
| - name: Run tests with Maven within a virtual X Server Environment | |
| run: xvfb-run mvn -T 1.5C verify -f ./ddk-parent/pom.xml --batch-mode --fail-at-end | |
| # Job 5: SpotBugs | |
| spotbugs: | |
| runs-on: ubuntu-24.04 | |
| needs: compile | |
| steps: | |
| - name: Set up Maven | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: 3.9.11 | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Set up Workspace Environment Variable | |
| run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: /home/runner/.m2/repository | |
| key: ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }} | |
| - name: Enable SpotBugs for changed modules (PR only) | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| chmod +x .github/scripts/enable-spotbugs-for-changed-modules.sh | |
| .github/scripts/enable-spotbugs-for-changed-modules.sh "${{ github.event.pull_request.base.sha }}" | |
| - name: Enable SpotBugs for all modules (push to master) | |
| if: github.event_name == 'push' | |
| run: | | |
| echo "Running SpotBugs on all modules (push to master)" | |
| # Set spotbugs.skip=false in parent POM | |
| sed -i 's/<spotbugs.skip>true<\/spotbugs.skip>/<spotbugs.skip>false<\/spotbugs.skip>/' ddk-parent/pom.xml | |
| - name: Run SpotBugs | |
| run: mvn -T 1.5C spotbugs:check -f ./ddk-parent/pom.xml --batch-mode --fail-at-end |