-
-
Notifications
You must be signed in to change notification settings - Fork 200
167 lines (144 loc) Β· 6.84 KB
/
full-build.yml
File metadata and controls
167 lines (144 loc) Β· 6.84 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Full Build
on:
push:
branches:
- main # Only run push on main (merges/direct pushes)
tags:
- 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0, v2.1.3)
pull_request:
branches:
- main # Run on any PR targeting main
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
java-version: [21]
include:
- os: ubuntu-latest
java-version: 25
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven
# 1. Set up Go (cross-platform)
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 'stable'
# 2. Install grpcurl (this places it in the $PATH automatically)
- name: Install grpcurl
run: go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
- name: Build
run: mvn -B install -P gradlePlugin --no-transfer-progress
env:
BUILD_LOG_LEVEL: 'ERROR'
- name: π Test Report
if: always()
run: |
echo "## π§ͺ Test Summary (${{ matrix.os }} - Java ${{ matrix.java-version }})" >> $GITHUB_STEP_SUMMARY
# Use Python to safely parse the JUnit XML files and write to the summary
python3 -c '
import xml.etree.ElementTree as ET
import glob, os
# Find all JUnit XML reports
files = glob.glob("**/target/**/TEST-*.xml", recursive=True)
tests, failures, errors, skipped = 0, 0, 0, 0
failed_tests = set()
skipped_tests = set()
for f in files:
try:
tree = ET.parse(f)
root = tree.getroot()
# Handle both <testsuite> and <testsuites> root elements
suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite")
for suite in suites:
tests += int(suite.attrib.get("tests", 0))
failures += int(suite.attrib.get("failures", 0))
errors += int(suite.attrib.get("errors", 0))
skipped += int(suite.attrib.get("skipped", 0))
# Collect names of failing and skipped tests
for case in suite.findall("testcase"):
if case.find("failure") is not None or case.find("error") is not None:
# Strip the package path from the classname for a cleaner display
cls = case.attrib.get("classname", "UnknownClass").split(".")[-1]
name = case.attrib.get("name", "UnknownMethod")
failed_tests.add(f"- `{cls}.{name}`")
elif case.find("skipped") is not None:
cls = case.attrib.get("classname", "UnknownClass").split(".")[-1]
name = case.attrib.get("name", "UnknownMethod")
skipped_tests.add(f"- `{cls}.{name}`")
except Exception as e:
print(f"Error parsing {f}: {e}")
passed = tests - failures - errors - skipped
summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
with open(summary_file, "a", encoding="utf-8") as f:
if not files:
f.write("β οΈ **Could not find any `TEST-*.xml` files.**\n")
else:
# Draw the Markdown Table
f.write("| Result | Count |\n")
f.write("|--------|-------|\n")
f.write(f"| β
**Passed** | **{passed}** |\n")
f.write(f"| β **Failed/Errors** | **{failures + errors}** |\n")
f.write(f"| β οΈ **Skipped** | **{skipped}** |\n")
f.write(f"| π **Total Tests** | **{tests}** |\n\n")
# Provide specific feedback for failures
if failures > 0 or errors > 0:
f.write("### π¨ Test Failures Detected!\n")
f.write("The following tests did not pass:\n")
for test in sorted(failed_tests):
f.write(f"{test}\n")
else:
f.write("### π 100% Pass Rate!\n")
f.write(f"The build is green across all {tests} tests.\n")
# Provide specific feedback for skips
if skipped > 0:
f.write("\n### β οΈ Skipped Tests\n")
for test in sorted(skipped_tests):
f.write(f"{test}\n")
'
- name: π Coverage Report
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
run: |
python3 -c '
import csv, os
# Hardcoded path to the aggregated CSV
csv_file = "tests/target/site/jacoco-aggregate/jacoco.csv"
summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
if not os.path.exists(csv_file):
with open(summary_file, "a", encoding="utf-8") as f:
f.write(f"\nβ οΈ **Coverage report not found at {csv_file}.**\n")
else:
instr_missed, instr_covered = 0, 0
branch_missed, branch_covered = 0, 0
line_missed, line_covered = 0, 0
with open(csv_file, mode="r", encoding="utf-8") as file:
reader = csv.DictReader(file)
for row in reader:
instr_missed += int(row["INSTRUCTION_MISSED"])
instr_covered += int(row["INSTRUCTION_COVERED"])
branch_missed += int(row["BRANCH_MISSED"])
branch_covered += int(row["BRANCH_COVERED"])
line_missed += int(row["LINE_MISSED"])
line_covered += int(row["LINE_COVERED"])
def calc(covered, missed):
total = covered + missed
return (covered / total * 100) if total > 0 else 0
instr_pct = calc(instr_covered, instr_missed)
line_pct = calc(line_covered, line_missed)
branch_pct = calc(branch_covered, branch_missed)
with open(summary_file, "a", encoding="utf-8") as f:
f.write("## π Code Coverage\n")
f.write("| Metric | Coverage |\n")
f.write("|--------|----------|\n")
f.write(f"| **Instruction (Overall)** | **{instr_pct:.2f}%** |\n")
f.write(f"| **Line** | **{line_pct:.2f}%** |\n")
f.write(f"| **Branch** | **{branch_pct:.2f}%** |\n\n")
'