Skip to content

ci: optimize verify for increased parallelization and early results #2569

ci: optimize verify for increased parallelization and early results

ci: optimize verify for increased parallelization and early results #2569

Workflow file for this run

name: verify
on: [push, pull_request]
env:
JAVA_VERSION: '21'
MAVEN_VERSION: 3.9.11
PMD_VERSION: '7.15.0'
jobs:
compile:
runs-on: ubuntu-24.04
steps:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- uses: actions/checkout@v5
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- 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 with Maven
run: mvn clean compile -f ./ddk-parent/pom.xml --batch-mode -T3C
- name: Upload compiled artifacts
uses: actions/upload-artifact@v4
with:
name: compiled-classes
path: |
**/target/classes
**/target/generated-sources
retention-days: 1
# test:
# needs: compile
# runs-on: ubuntu-24.04
# steps:
# - name: Set up Maven
# uses: stCarolas/setup-maven@v5
# with:
# maven-version: ${{ env.MAVEN_VERSION }}
# - uses: actions/checkout@v5
# - name: Set up JDK 21
# uses: actions/setup-java@v5
# with:
# distribution: 'temurin'
# java-version: ${{ env.JAVA_VERSION }}
# - 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: Download compiled artifacts
# uses: actions/download-artifact@v4
# with:
# name: compiled-classes
# - name: Run tests with Maven within a virtual X Server Environment
# run: xvfb-run mvn test -f ./ddk-parent/pom.xml --batch-mode -T1C
# - name: Archive Tycho Surefire Plugin
# if: ${{ failure() }}
# uses: actions/upload-artifact@v4
# with:
# name: tycho-surefire-plugin-test
# path: ${{ env.GITHUB_WORKSPACE }}/com.avaloq.tools.ddk.xtext.test/target/work/data/.metadata/.log
pmd-github:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- name: PMD
uses: pmd/pmd-github-action@v2.0.0
id: pmd
with:
version: ${{ env.PMD_VERSION }}
rulesets: 'ddk-configuration/pmd/ruleset.xml'
analyzeModifiedFilesOnly: false
- name: Fail build if there are violations
if: steps.pmd.outputs.violations != 0
run: exit 1
early-static-analysis:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
tool: [checkstyle, pmd]
steps:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- uses: actions/checkout@v5
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- 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 ${{ matrix.tool }}
run: |
case "${{ matrix.tool }}" in
checkstyle)
mvn checkstyle:check -f ./ddk-parent/pom.xml --batch-mode -T2C
;;
pmd)
mvn pmd:pmd pmd:check pmd:cpd-check -f ./ddk-parent/pom.xml --batch-mode -T2C
;;
esac
spotbugs:
needs: compile
runs-on: ubuntu-24.04
steps:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- uses: actions/checkout@v5
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- 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: Download compiled artifacts
uses: actions/download-artifact@v4
with:
name: compiled-classes
path: .
- name: Run SpotBugs
run: |
set -eo pipefail
mkdir -p target/spotbugs
# Collect all compiled class directories
mapfile -t CLASS_DIRS < <(find . -type d -path '*/target/classes' -print | sort)
if [ "${#CLASS_DIRS[@]}" -eq 0 ]; then
echo "No class directories found. Did the compile artifacts download?"
exit 1
fi
# Build aux classpath from all class directories
AUX_CP=$(IFS=:; echo "${CLASS_DIRS[*]}")
# Fetch SpotBugs distribution ZIP (includes all dependencies)
mvn -q dependency:copy \
-Dartifact=com.github.spotbugs:spotbugs:4.9.6:zip \
-DoutputDirectory=target/spotbugs
unzip -q -o target/spotbugs/spotbugs-4.9.6.zip -d target/spotbugs/dist
SPOTBUGS_HOME=$(find target/spotbugs/dist -maxdepth 1 -type d -name 'spotbugs-*' | head -n1)
echo "Using SpotBugs home: $SPOTBUGS_HOME"
# Run SpotBugs CLI via main class with full lib classpath
java -Xmx2g -cp "$SPOTBUGS_HOME/lib/*" edu.umd.cs.findbugs.LaunchAppropriateUI \
-textui -effort:max -low -maxRank 15 -exitcode \
-exclude ddk-configuration/findbugs/exclusion-filter.xml \
-auxclasspath "$AUX_CP" \
-xml:withMessages \
-output target/spotbugs/spotbugs.xml \
"${CLASS_DIRS[@]}" 2>&1 | tee target/spotbugs/spotbugs.log
# Optional: fail if any missing classes remain
if grep -q "needed for analysis were missing" target/spotbugs/spotbugs.log; then
echo "ERROR: SpotBugs reported missing classes. Aux classpath is incomplete."
exit 2
fi
- name: Upload SpotBugs report
if: always()
uses: actions/upload-artifact@v4
with:
name: spotbugs-report
path: |
target/spotbugs/spotbugs.xml
target/spotbugs/spotbugs.log
retention-days: 7
integration-tests:
needs: compile
runs-on: ubuntu-24.04
steps:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- uses: actions/checkout@v5
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- 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: Download compiled artifacts
uses: actions/download-artifact@v4
with:
name: compiled-classes
path: .
- name: Run integration tests with Maven within a virtual X Server Environment
run: xvfb-run mvn verify -f ./ddk-parent/pom.xml --batch-mode --fail-at-end -T1C
- name: Archive Tycho Surefire Plugin
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: tycho-surefire-plugin-integration
path: ${{ env.GITHUB_WORKSPACE }}/com.avaloq.tools.ddk.xtext.test/target/work/data/.metadata/.log