Skip to content

Commit 9696d99

Browse files
committed
ci: configure dynamic build matrix for PRs, tags, and main
Update the GitHub Actions workflow to optimize CI runner usage by dynamically scaling the build matrix based on the event trigger: - Main branch pushes: Full matrix (Ubuntu, Windows, macOS) with Java 21 and 25. - Tags (v*): Reduced matrix to only Ubuntu with Java 21. - Pull Requests: Ubuntu and Windows with Java 21.
1 parent 00c3dc6 commit 9696d99

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

‎.github/workflows/full-build.yml‎

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,68 @@ name: Full Build
33
on:
44
push:
55
branches:
6-
- main # Only run push on main (merges/direct pushes)
6+
- main
77
tags:
8-
- 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0, v2.1.3)
8+
- 'v*'
99
pull_request:
1010
branches:
11-
- main # Run on any PR targeting main
11+
- main
1212

1313
jobs:
1414
build:
15-
runs-on: ${{ matrix.os }}
1615
strategy:
1716
matrix:
18-
os: [ubuntu-latest, windows-latest, macos-latest]
19-
java-version: [21]
20-
include:
21-
- os: ubuntu-latest
17+
# 1. If PR -> [ubuntu, windows]
18+
# 2. Else If Tag -> [ubuntu]
19+
# 3. Else (Main Push) -> [ubuntu, windows, macos]
20+
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"]')) }}
21+
22+
# 1. If Main Push -> [21, 25]
23+
# 2. Else (PR or Tag) -> [21]
24+
java-version: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && fromJSON('[21, 25]') || fromJSON('[21]') }}
25+
26+
# Exclude Java 25 from running on Windows and macOS.
27+
# (This leaves Java 25 running exclusively on Ubuntu for main pushes).
28+
exclude:
29+
- os: windows-latest
30+
java-version: 25
31+
- os: macos-latest
2232
java-version: 25
33+
34+
runs-on: ${{ matrix.os }}
2335
steps:
2436
- name: Checkout
2537
uses: actions/checkout@v6
38+
2639
- name: Set up JDK ${{ matrix.java-version }}
2740
uses: actions/setup-java@v5
2841
with:
2942
java-version: ${{ matrix.java-version }}
3043
distribution: 'temurin'
3144
cache: maven
3245

33-
# 1. Set up Go (cross-platform)
3446
- name: Set up Go
3547
uses: actions/setup-go@v6
3648
with:
3749
go-version: 'stable'
3850

39-
# 2. Install grpcurl (this places it in the $PATH automatically)
4051
- name: Install grpcurl
4152
run: go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
4253

4354
- name: Build
4455
run: mvn -B install -P gradlePlugin --no-transfer-progress
4556
env:
4657
BUILD_LOG_LEVEL: 'ERROR'
58+
4759
- name: 📊 Test Report
4860
if: always()
4961
run: |
50-
echo "## 🧪 Test Summary (${{ matrix.os }} - Java ${{ matrix.java-version }})" >> $GITHUB_STEP_SUMMARY
62+
echo "## 🧪 Test Summary (${{ matrix.os }} Java ${{ matrix.java-version }})" >> $GITHUB_STEP_SUMMARY
5163
52-
# Use Python to safely parse the JUnit XML files and write to the summary
5364
python3 -c '
5465
import xml.etree.ElementTree as ET
5566
import glob, os
5667
57-
# Find all JUnit XML reports
5868
files = glob.glob("**/target/**/TEST-*.xml", recursive=True)
5969
6070
tests, failures, errors, skipped = 0, 0, 0, 0
@@ -66,7 +76,6 @@ jobs:
6676
tree = ET.parse(f)
6777
root = tree.getroot()
6878
69-
# Handle both <testsuite> and <testsuites> root elements
7079
suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite")
7180
7281
for suite in suites:
@@ -75,10 +84,8 @@ jobs:
7584
errors += int(suite.attrib.get("errors", 0))
7685
skipped += int(suite.attrib.get("skipped", 0))
7786
78-
# Collect names of failing and skipped tests
7987
for case in suite.findall("testcase"):
8088
if case.find("failure") is not None or case.find("error") is not None:
81-
# Strip the package path from the classname for a cleaner display
8289
cls = case.attrib.get("classname", "UnknownClass").split(".")[-1]
8390
name = case.attrib.get("name", "UnknownMethod")
8491
failed_tests.add(f"- `{cls}.{name}`")
@@ -96,15 +103,13 @@ jobs:
96103
if not files:
97104
f.write("⚠️ **Could not find any `TEST-*.xml` files.**\n")
98105
else:
99-
# Draw the Markdown Table
100106
f.write("| Result | Count |\n")
101107
f.write("|--------|-------|\n")
102108
f.write(f"| ✅ **Passed** | **{passed}** |\n")
103109
f.write(f"| ❌ **Failed/Errors** | **{failures + errors}** |\n")
104110
f.write(f"| ⚠️ **Skipped** | **{skipped}** |\n")
105111
f.write(f"| 📊 **Total Tests** | **{tests}** |\n\n")
106112
107-
# Provide specific feedback for failures
108113
if failures > 0 or errors > 0:
109114
f.write("### 🚨 Test Failures Detected!\n")
110115
f.write("The following tests did not pass:\n")
@@ -114,7 +119,6 @@ jobs:
114119
f.write("### 🎉 100% Pass Rate!\n")
115120
f.write(f"The build is green across all {tests} tests.\n")
116121
117-
# Provide specific feedback for skips
118122
if skipped > 0:
119123
f.write("\n### ⚠️ Skipped Tests\n")
120124
for test in sorted(skipped_tests):
@@ -127,7 +131,6 @@ jobs:
127131
python3 -c '
128132
import csv, os
129133
130-
# Hardcoded path to the aggregated CSV
131134
csv_file = "tests/target/site/jacoco-aggregate/jacoco.csv"
132135
summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
133136
@@ -165,21 +168,21 @@ jobs:
165168
f.write(f"| **Line** | **{line_pct:.2f}%** |\n")
166169
f.write(f"| **Branch** | **{branch_pct:.2f}%** |\n\n")
167170
'
171+
168172
- name: Upload coverage to Codecov
169173
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
170174
uses: codecov/codecov-action@v6
171175
with:
172176
token: ${{ secrets.CODECOV_TOKEN }}
173177
files: tests/target/site/jacoco-aggregate/jacoco.xml
174178
fail_ci_if_error: false
179+
175180
- name: 🔗 Codecov Report Link
176181
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
177182
run: |
178-
# Use the PR head SHA if available, otherwise fallback to the push commit SHA
179183
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
180184
REPO="${{ github.repository }}"
181185
182-
# Construct both URLs
183186
COMMIT_URL="https://app.codecov.io/github/$REPO/commit/$COMMIT_SHA"
184187
PROJECT_URL="https://app.codecov.io/github/$REPO"
185188

0 commit comments

Comments
 (0)