Repository navigation
193 lines (161 loc) Β· 7.85 KB
/
Copy pathfull-build.yml
File metadata and controls
193 lines (161 loc) Β· 7.85 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Full Build
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
build:
strategy:
matrix:
# 1. If PR -> [ubuntu, windows]
# 2. Else If Tag -> [ubuntu]
# 3. Else (Main Push) -> [ubuntu, windows, macos]
os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest", "windows-latest"]') || (startsWith(github.ref, 'refs/tags/') && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "windows-latest", "macos-latest"]')) }}
# 1. If Main Push -> [21, 25]
# 2. Else (PR or Tag) -> [21]
java-version: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && fromJSON('[21, 25]') || fromJSON('[21]') }}
# Exclude Java 25 from running on Windows and macOS.
# (This leaves Java 25 running exclusively on Ubuntu for main pushes).
exclude:
- os: windows-latest
java-version: 25
- os: macos-latest
java-version: 25
runs-on: ${{ matrix.os }}
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
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 'stable'
- 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
python3 -c '
import xml.etree.ElementTree as ET
import glob, os
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()
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))
for case in suite.findall("testcase"):
if case.find("failure") is not None or case.find("error") is not None:
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:
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")
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")
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
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")
'
- name: Upload coverage to Codecov
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: tests/target/site/jacoco-aggregate/jacoco.xml
fail_ci_if_error: false
- name: π Codecov Report Link
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
run: |
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
REPO="${{ github.repository }}"
COMMIT_URL="https://app.codecov.io/github/$REPO/commit/$COMMIT_SHA"
PROJECT_URL="https://app.codecov.io/github/$REPO"
echo "" >> $GITHUB_STEP_SUMMARY
echo "### βοΈ Codecov Report" >> $GITHUB_STEP_SUMMARY
echo "Your upload is queued for processing. When finished, results will be available at:" >> $GITHUB_STEP_SUMMARY
echo "- π **[View Report for this Commit]($COMMIT_URL)**" >> $GITHUB_STEP_SUMMARY
echo "- π **[View Overall Project Dashboard]($PROJECT_URL)**" >> $GITHUB_STEP_SUMMARY