From d3121ccf7e7c507acc089f6ca77a47c73caee749 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Fri, 23 May 2025 23:35:58 -0400 Subject: [PATCH 1/3] [CONFIG] [Github Actions] lint and test actions splitted --- .github/workflows/java-gradle-checkstyle.yml | 59 ++++++++++++++++++++ .github/workflows/java-gradle.yml | 3 - 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/java-gradle-checkstyle.yml diff --git a/.github/workflows/java-gradle-checkstyle.yml b/.github/workflows/java-gradle-checkstyle.yml new file mode 100644 index 0000000..bda5043 --- /dev/null +++ b/.github/workflows/java-gradle-checkstyle.yml @@ -0,0 +1,59 @@ +# yamllint disable rule:line-length +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle +# yamllint enable rule:line-length +--- + +name: Java CI Tests with Gradle + +on: # yamllint disable-line rule:truthy + push: + branches: ["main"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["main"] + workflow_dispatch: + +permissions: + contents: read + +jobs: + gradle: + name: Java Gradle CI Test + + strategy: + matrix: + os: ["windows-2022", "ubuntu-24.04", "macos-14"] + java: ['22', '23', '24'] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: temurin + + - name: Tool test + run: | + echo "Java version: ${{ matrix.java }}" + java -version + echo "OS: ${{ matrix.os }}" + echo "Gradle version:" + ./gradlew --version + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v4 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Clean + run: ./gradlew --console=verbose clean + + - name: Lint + run: ./gradlew --console=verbose checkstyleMain checkstyleTest diff --git a/.github/workflows/java-gradle.yml b/.github/workflows/java-gradle.yml index 26f83de..54e0676 100644 --- a/.github/workflows/java-gradle.yml +++ b/.github/workflows/java-gradle.yml @@ -55,8 +55,5 @@ jobs: - name: Clean run: ./gradlew --console=verbose clean - - name: Lint - run: ./gradlew --console=verbose checkstyleMain checkstyleTest - - name: Run tests run: ./gradlew --console=verbose test -x checkstyleMain checkstyleTest From 4084df9be402a6e29792c7de460710b13df92f18 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Fri, 23 May 2025 23:51:10 -0400 Subject: [PATCH 2/3] [CONFIG] [Github Actions] coverage action: Java version updated to 24 --- .github/workflows/java-gradle-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/java-gradle-coverage.yml b/.github/workflows/java-gradle-coverage.yml index d91d903..126f091 100644 --- a/.github/workflows/java-gradle-coverage.yml +++ b/.github/workflows/java-gradle-coverage.yml @@ -31,7 +31,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: 22 + java-version: 24 # Alternative distribution options are available distribution: temurin - name: Validate Gradle wrapper From 17d44b6bd07e2edd456c8c437cda6559d66b5edb Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Fri, 23 May 2025 23:50:47 -0400 Subject: [PATCH 3/3] [CONFIG] auto fix format sources capacity added. Makefile action "format" added. --- Makefile | 6 ++++++ algorithm-exercises-java/build.gradle | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 5b25724..25a897b 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,12 @@ lint: lint/markdown lint/yaml test/styling test/static test/styling: dependencies $(GRADLE) --console=verbose clean checkstyleMain checkstyleTest + +format/sources: + $(GRADLE) --console=verbose rewriteRun + +format: format/sources + test/static: dependencies test: env diff --git a/algorithm-exercises-java/build.gradle b/algorithm-exercises-java/build.gradle index 9c2149d..8934e3a 100644 --- a/algorithm-exercises-java/build.gradle +++ b/algorithm-exercises-java/build.gradle @@ -10,6 +10,7 @@ plugins { // Apply the application plugin to add support for building a CLI application in Java. id 'application' id 'checkstyle' + id 'org.openrewrite.rewrite' version '7.6.2' id 'jacoco' id 'org.barfuin.gradle.jacocolog' version '3.1.0' id 'com.adarshr.test-logger' version '4.0.0' @@ -35,6 +36,7 @@ dependencies { implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.19.0' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.19.0' + rewrite 'org.openrewrite.recipe:rewrite-static-analysis:latest.release' } application { @@ -55,6 +57,12 @@ checkstyle { showViolations = true } +// Reference: https://docs.openrewrite.org/running-recipes/popular-recipe-guides/automatically-fix-checkstyle-violations +rewrite { + activeRecipe 'org.openrewrite.staticanalysis.CodeCleanup' + checkstyleConfigFile = file("checkstyle.xml") +} + configurations.checkstyle { resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") { select("com.google.guava:guava:33.4.8-jre")