-
Notifications
You must be signed in to change notification settings - Fork 7
77 lines (66 loc) · 2.61 KB
/
maven.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# This workflow builds a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: build and analyse
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up with Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Build with Maven (including running of all tests)
run: mvn -B package --file pom.xml
- name: Publish Test Report
if: ${{ always() }}
uses: scacap/action-surefire-report@v1
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
generate-coverage-badge: true
generate-branches-badge: true
generate-summary: true
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit and push the svg badges and the json coverage summary (if it changed)
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'commit coverage badge and summary'
add: '*.svg *.json'
- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: target/site/jacoco/
- name: Comment on PR with coverage percentages
if: ${{ github.event_name == 'pull_request' }}
run: |
REPORT=$(<.github/badges/coverage-summary.json)
COVERAGE=$(jq -r '.coverage' <<< "$REPORT")%
BRANCHES=$(jq -r '.branches' <<< "$REPORT")%
NEWLINE=$'\n'
BODY="## Test Coverage Summary ${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}"
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}"
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Build and analyze with Sonar Cloud
# run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=tommens_calculator-cucumber
# env:
# # Needed to get some information about the pull request, if any
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # SonarCloud access token should be generated from https://sonarcloud.io/account/security/
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}