This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (60 loc) · 1.98 KB
/
main.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
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: write # Garantisce i permessi di scrittura
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '22'
distribution: 'temurin'
cache: maven
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Generate site
run: mvn jacoco:prepare-agent install jacoco:report
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/[email protected]
with:
generate-branches-badge: true
jacoco-csv-file: target/site/jacoco/jacoco.csv
badges-directory: .github/badges
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage}}"
echo "branches = ${{ steps.jacoco.outputs.branches}}"
- name: Add badges
run: git add .github/badges
- name: Commit files
run: |
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -m "Added coverage badges" -a || true
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: target/site/jacoco/jacoco.xml
token: ${{ secrets.CODECOV_TOKEN }}