-
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (104 loc) · 4.07 KB
/
snapshot.yml
File metadata and controls
116 lines (104 loc) · 4.07 KB
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
108
109
110
111
112
113
114
115
116
---
name: Snapshot
permissions:
contents: read
packages: write
statuses: write
checks: write
on:
push:
branches:
- main
pull_request:
jobs:
test-build:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
packages: write
statuses: write
checks: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
java-version: "25"
distribution: "temurin"
cache: "maven"
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Build with Maven
run: >-
mvn -B -ntp -Dstyle.color=always verify
${{ github.event_name != 'pull_request' && '-P sign' || '' }}
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Test Summary
id: test_summary
uses: test-summary/action@v2
with:
paths: |
**/target/surefire-reports/TEST-*.xml
if: always()
- uses: qltysh/qlty-action/coverage@main
if: github.event_name != 'pull_request'
with:
coverage-token: ${{secrets.QLTY_COVERAGE_TOKEN}}
files: "**/target/site/jacoco/jacoco.xml"
- name: Merge JaCoCo reports
run: |
python3 - <<'PYEOF'
import xml.etree.ElementTree as ET, sys
files = [
"mjml-java-core/target/site/jacoco/jacoco.xml",
"mjml-java-resolvers/target/site/jacoco/jacoco.xml",
"mjml-java-spring/target/site/jacoco/jacoco.xml",
]
merged = None
for f in files:
root = ET.parse(f).getroot()
if merged is None:
merged = root
continue
for pkg in root.findall("package"):
merged.append(pkg)
for counter in root.findall("counter"):
ctype = counter.get("type")
existing = merged.find(f"counter[@type='{ctype}']")
if existing is not None:
existing.set("missed", str(int(existing.get("missed")) + int(counter.get("missed"))))
existing.set("covered", str(int(existing.get("covered")) + int(counter.get("covered"))))
else:
merged.append(counter)
import os; os.makedirs("target", exist_ok=True)
ET.ElementTree(merged).write("target/jacoco-merged.xml", xml_declaration=True, encoding="UTF-8")
PYEOF
# generates coverage-report.md and publishes as checkrun
- name: JaCoCo Code Coverage Report
id: jacoco_reporter
uses: PavanMudigonda/jacoco-reporter@v5.1
with:
coverage_results_path: target/jacoco-merged.xml
coverage_report_name: Coverage
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_check_run: false
minimum_coverage: 80
fail_below_threshold: true
publish_only_summary: false
# Publish Coverage Job Summary
- name: Add Jacoco report to workflow run summary
run: |
echo "| Outcome | Value |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| Code Coverage % | ${{ steps.jacoco_reporter.outputs.coverage_percentage }} |" >> $GITHUB_STEP_SUMMARY
echo "| :heavy_check_mark: Number of Lines Covered | ${{ steps.jacoco_reporter.outputs.covered_lines }} |" >> $GITHUB_STEP_SUMMARY
echo "| :x: Number of Lines Missed | ${{ steps.jacoco_reporter.outputs.missed_lines }} |" >> $GITHUB_STEP_SUMMARY
echo "| Total Number of Lines | ${{ steps.jacoco_reporter.outputs.total_lines }} |" >> $GITHUB_STEP_SUMMARY
- name: Publish package to GitHub Packages
if: github.event_name != 'pull_request'
run: mvn -B -ntp -Dstyle.color=always deploy -P github,sign -DskipTests=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}