#119 add diagrams #236
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven, 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-maven | |
# 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. | |
name: Build and Test | |
on: | |
pull_request: | |
workflow_call: | |
inputs: | |
config-path: | |
required: true | |
type: string | |
secrets: | |
SONAR_TOKEN: | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Build | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
testCoverage: | |
runs-on: ubuntu-latest | |
name: Test coverage | |
permissions: | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Run Coverage | |
run: mvn jacoco:prepare-agent test jacoco:report | |
- name: Upload Report | |
uses: 'actions/upload-artifact@v2' | |
with: | |
name: report.xml | |
path: ${{ github.workspace }}/target/site/jacoco/jacoco.xml | |
- name: Jacoco Report to PR | |
id: jacoco | |
uses: madrapps/jacoco-report@v1.6.1 | |
with: | |
paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 80 | |
min-coverage-changed-files: 60 | |
debug-mode: false | |
title: Code Coverage | |
update-comment: true | |
pass-emoji: ':green_circle:' | |
fail-emoji: ':red_circle:' | |
- name: Get the Coverage info | |
run: | | |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}" | |
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}" | |
- name: Fail PR if overall coverage is less than 80% for changed files | |
if: ${{ steps.jacoco.outputs.coverage-changed-files < 80.0 }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.setFailed('Overall coverage is less than 80%!') | |
sonarqube_scan: | |
runs-on: ubuntu-latest | |
name: SonarQube Scan | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- 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: Build and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn -B verify sonar:sonar -Dgpg.skip=true |