Skip to content

Commit

Permalink
Set up GitHub actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenWoltmann committed Jun 1, 2023
1 parent 25c48b0 commit a6e3803
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-jvm:
name: Build

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 19
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 19

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Verify code format
run: mvn -B spotless:check

- name: Compile, test and verify
run: mvn -B verify -Ptest-coverage,code-analysis

- name: Analyze code with Sonar
if: ${{ env.SONAR_TOKEN }} # the token is not available in Dependabot-triggered builds
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<pmd.version>6.55.0</pmd.version>

<!-- SonarCloud configuration -->
<sonar.projectKey>SvenWoltmann_hexagonal-architecture-java</sonar.projectKey>
<sonar.organization>svenwoltmann</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<sonar.java.spotbugs.reportPaths>target/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
<sonar.java.pmd.reportPaths>target/pmd.xml</sonar.java.pmd.reportPaths>
<sonar.java.checkstyle.reportPaths>target/checkstyle-result.xml</sonar.java.checkstyle.reportPaths>
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<dependencies>
Expand Down

0 comments on commit a6e3803

Please sign in to comment.