Skip to content

Commit e5a786f

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 e5a786f

1 file changed

Lines changed: 18 additions & 23 deletions

File tree

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,60 @@ 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
22-
java-version: 25
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+
runs-on: ${{ matrix.os }}
2327
steps:
2428
- name: Checkout
2529
uses: actions/checkout@v6
30+
2631
- name: Set up JDK ${{ matrix.java-version }}
2732
uses: actions/setup-java@v5
2833
with:
2934
java-version: ${{ matrix.java-version }}
3035
distribution: 'temurin'
3136
cache: maven
3237

33-
# 1. Set up Go (cross-platform)
3438
- name: Set up Go
3539
uses: actions/setup-go@v6
3640
with:
3741
go-version: 'stable'
3842

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

4346
- name: Build
4447
run: mvn -B install -P gradlePlugin --no-transfer-progress
4548
env:
4649
BUILD_LOG_LEVEL: 'ERROR'
50+
4751
- name: 📊 Test Report
4852
if: always()
4953
run: |
50-
echo "## 🧪 Test Summary (${{ matrix.os }} - Java ${{ matrix.java-version }})" >> $GITHUB_STEP_SUMMARY
54+
echo "## 🧪 Test Summary (${{ matrix.os }} Java ${{ matrix.java-version }})" >> $GITHUB_STEP_SUMMARY
5155
52-
# Use Python to safely parse the JUnit XML files and write to the summary
5356
python3 -c '
5457
import xml.etree.ElementTree as ET
5558
import glob, os
5659
57-
# Find all JUnit XML reports
5860
files = glob.glob("**/target/**/TEST-*.xml", recursive=True)
5961
6062
tests, failures, errors, skipped = 0, 0, 0, 0
@@ -66,7 +68,6 @@ jobs:
6668
tree = ET.parse(f)
6769
root = tree.getroot()
6870
69-
# Handle both <testsuite> and <testsuites> root elements
7071
suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite")
7172
7273
for suite in suites:
@@ -75,10 +76,8 @@ jobs:
7576
errors += int(suite.attrib.get("errors", 0))
7677
skipped += int(suite.attrib.get("skipped", 0))
7778
78-
# Collect names of failing and skipped tests
7979
for case in suite.findall("testcase"):
8080
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
8281
cls = case.attrib.get("classname", "UnknownClass").split(".")[-1]
8382
name = case.attrib.get("name", "UnknownMethod")
8483
failed_tests.add(f"- `{cls}.{name}`")
@@ -96,15 +95,13 @@ jobs:
9695
if not files:
9796
f.write("⚠️ **Could not find any `TEST-*.xml` files.**\n")
9897
else:
99-
# Draw the Markdown Table
10098
f.write("| Result | Count |\n")
10199
f.write("|--------|-------|\n")
102100
f.write(f"| ✅ **Passed** | **{passed}** |\n")
103101
f.write(f"| ❌ **Failed/Errors** | **{failures + errors}** |\n")
104102
f.write(f"| ⚠️ **Skipped** | **{skipped}** |\n")
105103
f.write(f"| 📊 **Total Tests** | **{tests}** |\n\n")
106104
107-
# Provide specific feedback for failures
108105
if failures > 0 or errors > 0:
109106
f.write("### 🚨 Test Failures Detected!\n")
110107
f.write("The following tests did not pass:\n")
@@ -114,7 +111,6 @@ jobs:
114111
f.write("### 🎉 100% Pass Rate!\n")
115112
f.write(f"The build is green across all {tests} tests.\n")
116113
117-
# Provide specific feedback for skips
118114
if skipped > 0:
119115
f.write("\n### ⚠️ Skipped Tests\n")
120116
for test in sorted(skipped_tests):
@@ -127,7 +123,6 @@ jobs:
127123
python3 -c '
128124
import csv, os
129125
130-
# Hardcoded path to the aggregated CSV
131126
csv_file = "tests/target/site/jacoco-aggregate/jacoco.csv"
132127
summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
133128
@@ -165,21 +160,21 @@ jobs:
165160
f.write(f"| **Line** | **{line_pct:.2f}%** |\n")
166161
f.write(f"| **Branch** | **{branch_pct:.2f}%** |\n\n")
167162
'
163+
168164
- name: Upload coverage to Codecov
169165
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
170166
uses: codecov/codecov-action@v6
171167
with:
172168
token: ${{ secrets.CODECOV_TOKEN }}
173169
files: tests/target/site/jacoco-aggregate/jacoco.xml
174170
fail_ci_if_error: false
171+
175172
- name: 🔗 Codecov Report Link
176173
if: always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
177174
run: |
178-
# Use the PR head SHA if available, otherwise fallback to the push commit SHA
179175
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
180176
REPO="${{ github.repository }}"
181177
182-
# Construct both URLs
183178
COMMIT_URL="https://app.codecov.io/github/$REPO/commit/$COMMIT_SHA"
184179
PROJECT_URL="https://app.codecov.io/github/$REPO"
185180

0 commit comments

Comments
 (0)