From 8d8975a53f536285c771d82f8f3e6ed23f7ab8bc Mon Sep 17 00:00:00 2001 From: Tonji Zimmerman Date: Thu, 8 Oct 2026 14:03:52 -0500 Subject: [PATCH 1/5] testing failures --- src/main/java/com/example/app/App.java | 3 ++- src/main/java/com/example/app/Violations.java | 22 +++++++++++++++++++ src/test/java/com/example/app/AppTest.java | 5 +++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/example/app/Violations.java diff --git a/src/main/java/com/example/app/App.java b/src/main/java/com/example/app/App.java index 2901455..b30a217 100644 --- a/src/main/java/com/example/app/App.java +++ b/src/main/java/com/example/app/App.java @@ -9,6 +9,7 @@ public static void main(String[] args) { } static String greeting() { - return "Hello, world!"; + var phrase = "Hello, world!"; + return phrase; } } diff --git a/src/main/java/com/example/app/Violations.java b/src/main/java/com/example/app/Violations.java new file mode 100644 index 0000000..96c89ed --- /dev/null +++ b/src/main/java/com/example/app/Violations.java @@ -0,0 +1,22 @@ +package com.example.app; + +import java.util.List; // Checkstyle: UnusedImports + +/** Deliberately broken class: each tool in `./gradlew check` should complain. */ +public class Violations { + + static final int max_size = 10; // Checkstyle: ConstantName + + public boolean sameName(String a, String b) { // Spotless: bad indentation + return a == b; // SpotBugs: comparing Strings with == + } + + public void swallow() { + try { + Integer.parseInt("x"); + } catch (NumberFormatException e) { + } // PMD: EmptyCatchBlock + } + + // JaCoCo: no test covers this class, so coverage falls below 80% +} diff --git a/src/test/java/com/example/app/AppTest.java b/src/test/java/com/example/app/AppTest.java index 61aa92b..d1213a1 100644 --- a/src/test/java/com/example/app/AppTest.java +++ b/src/test/java/com/example/app/AppTest.java @@ -10,4 +10,9 @@ class AppTest { void greetingReturnsHelloWorld() { assertEquals("Hello, world!", App.greeting(), "greeting() should return the expected message"); } + + @Test + void greetingReturnsHelloWorldFailure() { + assertEquals("Helloooo, world!", App.greeting(), "greeting() should return the expected message"); + } } From 353177807102046aee6f8b435856d5932302605c Mon Sep 17 00:00:00 2001 From: Tonji Zimmerman Date: Thu, 8 Oct 2026 14:11:17 -0500 Subject: [PATCH 2/5] break out check --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2c7fe3..449a6a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,8 +26,33 @@ jobs: - name: Set up Gradle (with caching) uses: gradle/actions/setup-gradle@v4 - - name: Run checks - run: ./gradlew check --no-daemon + # Each check is its own step so it shows its own pass/fail. + # `!cancelled()` lets later steps run even if an earlier one failed. + + - name: Formatting (Spotless) + run: ./gradlew spotlessCheck + + - name: Compile and test + id: test + if: ${{ !cancelled() }} + run: ./gradlew test + + - name: Checkstyle + if: ${{ !cancelled() }} + run: ./gradlew checkstyleMain checkstyleTest + + - name: PMD + if: ${{ !cancelled() }} + run: ./gradlew pmdMain pmdTest + + - name: SpotBugs + if: ${{ !cancelled() }} + run: ./gradlew spotbugsMain spotbugsTest + + # Coverage is only meaningful if the tests passed. + - name: Coverage (JaCoCo) + if: ${{ !cancelled() && steps.test.outcome == 'success' }} + run: ./gradlew jacocoTestCoverageVerification - name: Upload test reports if: failure() From 009cca017702a7504cdc2102727dc6ac8b67cabc Mon Sep 17 00:00:00 2001 From: Tonji Zimmerman Date: Thu, 8 Oct 2026 14:14:45 -0500 Subject: [PATCH 3/5] show on main PR view --- .github/workflows/ci.yml | 63 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 449a6a3..70d1b8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,4 @@ + name: CI on: @@ -10,9 +11,32 @@ permissions: contents: read jobs: - test: + check: + # Each matrix entry becomes its own job, and its own line + # in the PR's checks list (e.g. "CI / Checkstyle"). + name: ${{ matrix.name }} runs-on: ubuntu-latest + strategy: + fail-fast: false # let every check finish even if one fails + matrix: + include: + - id: spotless + name: Formatting (Spotless) + tasks: spotlessCheck + - id: tests + name: Tests and coverage + tasks: test jacocoTestCoverageVerification + - id: checkstyle + name: Checkstyle + tasks: checkstyleMain checkstyleTest + - id: pmd + name: PMD + tasks: pmdMain pmdTest + - id: spotbugs + name: SpotBugs + tasks: spotbugsMain spotbugsTest + steps: - name: Check out code uses: actions/checkout@v4 @@ -26,38 +50,13 @@ jobs: - name: Set up Gradle (with caching) uses: gradle/actions/setup-gradle@v4 - # Each check is its own step so it shows its own pass/fail. - # `!cancelled()` lets later steps run even if an earlier one failed. - - - name: Formatting (Spotless) - run: ./gradlew spotlessCheck - - - name: Compile and test - id: test - if: ${{ !cancelled() }} - run: ./gradlew test - - - name: Checkstyle - if: ${{ !cancelled() }} - run: ./gradlew checkstyleMain checkstyleTest - - - name: PMD - if: ${{ !cancelled() }} - run: ./gradlew pmdMain pmdTest - - - name: SpotBugs - if: ${{ !cancelled() }} - run: ./gradlew spotbugsMain spotbugsTest - - # Coverage is only meaningful if the tests passed. - - name: Coverage (JaCoCo) - if: ${{ !cancelled() && steps.test.outcome == 'success' }} - run: ./gradlew jacocoTestCoverageVerification + - name: Run ${{ matrix.name }} + run: ./gradlew ${{ matrix.tasks }} - - name: Upload test reports + - name: Upload reports if: failure() uses: actions/upload-artifact@v4 with: - name: test-reports - path: '**/build/reports/tests/' - retention-days: 7 + name: reports-${{ matrix.id }} + path: '**/build/reports/' + retention-days: 7 \ No newline at end of file From b3038018ce737a94943e097ebaa95b66e14f5b3e Mon Sep 17 00:00:00 2001 From: Tonji Zimmerman Date: Thu, 8 Oct 2026 16:41:53 -0500 Subject: [PATCH 4/5] remove failure code --- src/main/java/com/example/app/App.java | 3 +-- src/main/java/com/example/app/Violations.java | 22 ------------------- src/test/java/com/example/app/AppTest.java | 5 ----- 3 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 src/main/java/com/example/app/Violations.java diff --git a/src/main/java/com/example/app/App.java b/src/main/java/com/example/app/App.java index b30a217..2901455 100644 --- a/src/main/java/com/example/app/App.java +++ b/src/main/java/com/example/app/App.java @@ -9,7 +9,6 @@ public static void main(String[] args) { } static String greeting() { - var phrase = "Hello, world!"; - return phrase; + return "Hello, world!"; } } diff --git a/src/main/java/com/example/app/Violations.java b/src/main/java/com/example/app/Violations.java deleted file mode 100644 index 96c89ed..0000000 --- a/src/main/java/com/example/app/Violations.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.app; - -import java.util.List; // Checkstyle: UnusedImports - -/** Deliberately broken class: each tool in `./gradlew check` should complain. */ -public class Violations { - - static final int max_size = 10; // Checkstyle: ConstantName - - public boolean sameName(String a, String b) { // Spotless: bad indentation - return a == b; // SpotBugs: comparing Strings with == - } - - public void swallow() { - try { - Integer.parseInt("x"); - } catch (NumberFormatException e) { - } // PMD: EmptyCatchBlock - } - - // JaCoCo: no test covers this class, so coverage falls below 80% -} diff --git a/src/test/java/com/example/app/AppTest.java b/src/test/java/com/example/app/AppTest.java index d1213a1..61aa92b 100644 --- a/src/test/java/com/example/app/AppTest.java +++ b/src/test/java/com/example/app/AppTest.java @@ -10,9 +10,4 @@ class AppTest { void greetingReturnsHelloWorld() { assertEquals("Hello, world!", App.greeting(), "greeting() should return the expected message"); } - - @Test - void greetingReturnsHelloWorldFailure() { - assertEquals("Helloooo, world!", App.greeting(), "greeting() should return the expected message"); - } } From 98a51c24392b2f4169942e0778dbaa733910dbf4 Mon Sep 17 00:00:00 2001 From: Tonji Zimmerman Date: Fri, 9 Oct 2026 11:43:52 -0500 Subject: [PATCH 5/5] Remove spotbug --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70d1b8f..7f87f06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,9 +33,6 @@ jobs: - id: pmd name: PMD tasks: pmdMain pmdTest - - id: spotbugs - name: SpotBugs - tasks: spotbugsMain spotbugsTest steps: - name: Check out code