|
|
@ -1,4 +1,4 @@ |
|
|
|
# This workflow will build a Java project with Maven |
|
|
|
# This workflow will build a Java project with Maven, check coverage with JaCoCo and analyze with sonarcloud |
|
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven |
|
|
|
|
|
|
|
name: Java CI with Maven |
|
|
@ -16,12 +16,32 @@ jobs: |
|
|
|
|
|
|
|
steps: |
|
|
|
- uses: actions/checkout@v2 |
|
|
|
- name: Set up JDK 8 |
|
|
|
with: |
|
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
|
|
|
- name: Set up JDK 11 |
|
|
|
uses: actions/setup-java@v2 |
|
|
|
with: |
|
|
|
java-version: '8' |
|
|
|
java-version: '11' |
|
|
|
distribution: 'adopt' |
|
|
|
- name: Run tests |
|
|
|
run: mvn --batch-mode test |
|
|
|
- name: Build with Maven |
|
|
|
run: mvn --batch-mode package --file pom.xml |
|
|
|
- name: Cache SonarCloud packages |
|
|
|
uses: actions/cache@v1 |
|
|
|
with: |
|
|
|
path: ~/.sonar/cache |
|
|
|
key: ${{ runner.os }}-sonar |
|
|
|
restore-keys: ${{ runner.os }}-sonar |
|
|
|
- name: Cache Maven packages |
|
|
|
uses: actions/cache@v1 |
|
|
|
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 }} # Needed to get PR information, if any |
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
|
|
|
run: mvn -B org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar |
|
|
|
- name: Upload jar artifact |
|
|
|
uses: actions/upload-artifact@v2 |
|
|
|
with: |
|
|
|
name: artifacts |
|
|
|
path: target/*.jar |