-
Notifications
You must be signed in to change notification settings - Fork 10
62 lines (51 loc) · 1.96 KB
/
coverage.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
#This workflow will build a Java project with Maven - to generate coverage in the file jacaco.csv.
# This file is then parsed to generate a coverage percentage.
# readme.MD is then updated with this value to make a coverage badge.
name: coverage
on:
push:
branches: [ "master" ]
# runs tests and generate Jacoco report
#
jobs:
# This workflow contains a single job called "coverage"
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 1.17
uses: actions/setup-java@v1
with:
java-version: 1.17
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Run tests with Maven
run: |
mvn test --file pom.xml
- name: Run coverage parse script
run: |
chmod +x scripts/coverage_percentage_git.sh
percent=`scripts/coverage_percentage_git.sh`
echo $percent > .github/coverage/percentage.txt
echo coverage = $percent
cat /home/runner/work/AuScope-Portal-API/AuScope-Portal-API/target/site/jacoco/jacoco.csv > .github/coverage/jacoco.csv
shell: bash
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit changes
uses: EndBug/add-and-commit@v8
with:
author_name: ${{ github.actor }}
author_email: ${{ github.event.commits[0].author.email }}
message: Autogenerated JaCoCo coverage badge
add: .github/coverage/percentage.txt .github/coverage/jacoco.csv .github/badges/jacoco.svg