diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..329950a --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/pom.xml b/pom.xml index 8878ce4..7a214eb 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,16 @@ UTF-8 6.55.0 + + + SvenWoltmann_hexagonal-architecture-java + svenwoltmann + https://sonarcloud.io + + target/spotbugsXml.xml + target/pmd.xml + target/checkstyle-result.xml + target/site/jacoco/jacoco.xml