diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 73124dc..41ba8ba 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -26,12 +26,10 @@ jobs: build: runs-on: ubuntu-latest timeout-minutes: 30 - strategy: matrix: - java: [11, 17, 21] + java: [17, 21] distribution: [temurin] - steps: - uses: actions/checkout@v5 @@ -40,11 +38,17 @@ jobs: with: distribution: ${{ matrix.distribution }} java-version: ${{ matrix.java }} - cache: 'maven' + + - name: Cache Maven + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-mvn-build- - name: Build with Maven - # Java 17 is required for tests - run: ./mvnw -B clean package ${{ matrix.java >=17 && '-P run-integration-tests' || '-Dmaven.test.skip=true' }} + run: ./mvnw -B clean package -P run-integration-tests - name: Check for uncommited changes run: | @@ -79,6 +83,31 @@ jobs: path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/screenshots if-no-files-found: ignore + # Ensure compatibility with Java 11 + # See https://github.com/xdev-software/chartjs-java-model/issues/14 + build-java-11: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v5 + + - name: Set up JDK + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 11 + + - name: Cache Maven + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-mvn-build-java-11-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-mvn-build-java-11- + + - name: Build with Maven + run: ./mvnw -B clean package -Dmaven.test.skip=true + checkstyle: runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} @@ -97,7 +126,22 @@ jobs: with: distribution: ${{ matrix.distribution }} java-version: ${{ matrix.java }} - cache: 'maven' + + - name: Cache Maven + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-mvn-checkstyle-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-mvn-checkstyle- + + - name: CheckStyle Cache + uses: actions/cache@v4 + with: + path: '**/target/checkstyle-cachefile' + key: ${{ runner.os }}-checkstyle-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-checkstyle- - name: Run Checkstyle run: ./mvnw -B checkstyle:check -P checkstyle -T2C @@ -120,7 +164,22 @@ jobs: with: distribution: ${{ matrix.distribution }} java-version: ${{ matrix.java }} - cache: 'maven' + + - name: Cache Maven + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-mvn-pmd-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-mvn-pmd- + + - name: PMD Cache + uses: actions/cache@v4 + with: + path: '**/target/pmd/pmd.cache' + key: ${{ runner.os }}-pmd-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pmd- - name: Run PMD run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea4ad2f..3d92007 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,8 @@ permissions: contents: write pull-requests: write +# DO NOT RESTORE CACHE for critical release steps to prevent a (extremely unlikely) scenario +# where a supply chain attack could be achieved due to poisoned cache jobs: check-code: runs-on: ubuntu-latest @@ -23,7 +25,15 @@ jobs: with: java-version: '17' distribution: 'temurin' - cache: 'maven' + + # Try to reuse existing cache from check-build + - name: Try restore Maven Cache + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-mvn-build- - name: Build with Maven run: ./mvnw -B clean package -T2C @@ -166,7 +176,15 @@ jobs: with: java-version: '17' distribution: 'temurin' - cache: 'maven' + + # Try to reuse existing cache from check-build + - name: Try restore Maven Cache + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-mvn-build- - name: Build site run: ../mvnw -B compile site -DskipTests -T2C diff --git a/chartjs-java-model/pom.xml b/chartjs-java-model/pom.xml index 9a454c3..0ce3f2e 100644 --- a/chartjs-java-model/pom.xml +++ b/chartjs-java-model/pom.xml @@ -355,6 +355,7 @@ maven-pmd-plugin 3.27.0 + true true true diff --git a/pom.xml b/pom.xml index bba5629..81ad245 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,7 @@ maven-pmd-plugin 3.27.0 + true true true