diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml new file mode 100644 index 00000000..cd2ef61e --- /dev/null +++ b/.github/workflows/analysis.yml @@ -0,0 +1,41 @@ +name: Checkstyle + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + checkstyle: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Apply Checkstyle + run: ./gradlew checkstyleMain checkstyleTest + + - name: Upload Checkstyle reports + uses: actions/upload-artifact@v3 + with: + name: checkstyle-reports + path: build/reports/checkstyle/ \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d5d735b5..b3705358 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,10 +1,3 @@ -# 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 - name: Java CI with Gradle on: @@ -28,25 +21,12 @@ jobs: java-version: '17' distribution: 'temurin' - # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. - # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md - name: Setup Gradle - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 - name: Build with Gradle Wrapper run: ./gradlew build - # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). - # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. - # - # - name: Setup Gradle - # uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 - # with: - # gradle-version: '8.5' - # - # - name: Build with Gradle 8.5 - # run: gradle build - dependency-submission: runs-on: ubuntu-latest @@ -61,7 +41,5 @@ jobs: java-version: '17' distribution: 'temurin' - # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. - # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md - name: Generate and submit dependency graph - uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 diff --git a/build.gradle b/build.gradle index 3b0aed05..0bf3a593 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java' + id 'checkstyle' } group = 'com.lmax' @@ -44,6 +45,11 @@ sourceSets { } } +checkstyle { + toolVersion = '8.45' + configFile = file('config/checkstyle/checkstyle.xml') +} + dependencies { // dependencies implementation 'org.bitcoinj:bitcoinj-core:0.15' @@ -105,4 +111,11 @@ tasks.processTestResources { duplicatesStrategy = DuplicatesStrategy.INCLUDE } +tasks.withType(Checkstyle) { + reports { + xml.enabled = true + html.enabled = true + } +} + check.dependsOn integrationTest \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 00000000..7ba89202 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file