-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (88 loc) · 3.18 KB
/
java-dev-ci.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Java DEV CI
on:
pull_request:
branches:
- dev
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
- name: Build with Maven
run: mvn clean compile
- name: Run tests
run: mvn test
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
colors: '#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44'
fail-if-coverage-less-than: 80
generate-workflow-summary: true
workflow-summary-heading: JaCoCo Test Coverage Summary
generate-coverage-endpoint: true
generate-coverage-badge: true
coverage-badge-filename: jacoco.svg
- name: Log coverage percentage
run: |
coverage=$(echo "${{ steps.jacoco.outputs.coverage }} * 100" | bc)
branches=$(echo "${{ steps.jacoco.outputs.branches }} * 100" | bc)
echo "Coverage = ${coverage}%"
echo "Branch Coverage = ${branches}%"
- name: Upload JaCoCo badge
uses: actions/upload-artifact@v4
with:
name: jacoco-badge
path: .github/badges/jacoco.svg
- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: target/site/jacoco/
- name: commit coverage badge to gh-pages
run: |
mkdir -p public
cp .github/badges/jacoco.svg public/coverage-badge.svg
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git fetch origin
git checkout -b gh-pages origin/gh-pages || git checkout -b gh-pages
mv public/* .
git add -f coverage-badge.svg
git commit -m "Update coverage badge [skip ci]" || echo "No changes to commit"
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install and Run gitinspector
run: |
pip install git+https://github.com/jpwhite3/gitinspector.git
git fetch origin dev
git checkout dev
echo "git log ..."
git log --oneline -n 5
mkdir -p .github/reports
gitinspector --format=html --since=2024-01-12 --weeks --list-file-types --timeline > .github/reports/gi-report.html
- name: Push coverage badge and gi-report to gh-pages
run: |
mkdir -p public
cp .github/reports/gi-report.html public/gitinspector-report.html
git fetch origin
git checkout -b gh-pages origin/gh-pages || git checkout -b gh-pages
mv public/* .
git add -f gitinspector-report.html
git commit -m "Update gitInspector-report [skip ci]" || echo "No changes to commit"
git push -f origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}