Skip to content

Commit 4fb59c8

Browse files
authored
sync(ci): update mage-x to v1.15.0 and tools (#90)
1 parent c26856d commit 4fb59c8

File tree

10 files changed

+249
-24
lines changed

10 files changed

+249
-24
lines changed

.github/.env.base

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ REDIS_CACHE_FORCE_PULL=false # Force pull Redis images even when cache
235235
# 🪄 MAGE-X CONFIGURATION
236236
# ================================================================================================
237237

238-
MAGE_X_VERSION=v1.13.0 # https://github.com/mrz1836/mage-x/releases
238+
MAGE_X_VERSION=v1.15.0 # https://github.com/mrz1836/mage-x/releases
239239
MAGE_X_USE_LOCAL=false # Use local version for development
240240
MAGE_X_CI_SKIP_STEP_SUMMARY=true # Skip duplicate test results in step summary (already in test validation summary)
241241
MAGE_X_AUTO_DISCOVER_BUILD_TAGS=true # Enable auto-discovery of build tags
@@ -244,15 +244,16 @@ MAGE_X_FORMAT_EXCLUDE_PATHS=vendor,node_modules,.git,.idea # Format exclusion
244244
MAGE_X_GITLEAKS_VERSION=8.30.0 # https://github.com/gitleaks/gitleaks/releases
245245
MAGE_X_GOFUMPT_VERSION=v0.9.2 # https://github.com/mvdan/gofumpt/releases
246246
MAGE_X_GOLANGCI_LINT_VERSION=v2.7.2 # https://github.com/golangci/golangci-lint/releases
247-
MAGE_X_GORELEASER_VERSION=v2.13.1 # https://github.com/goreleaser/goreleaser/releases
247+
MAGE_X_GORELEASER_VERSION=v2.13.2 # https://github.com/goreleaser/goreleaser/releases
248248
MAGE_X_GOVULNCHECK_VERSION=v1.1.4 # https://go.googlesource.com/vuln/+refs
249249
MAGE_X_GO_SECONDARY_VERSION=1.24.x # Secondary Go version for MAGE-X (also our secondary)
250250
MAGE_X_GO_VERSION=1.24.x # Primary Go version for MAGE-X (also our primary)
251251
MAGE_X_MOCKGEN_VERSION=v0.6.0 # https://github.com/uber-go/mock/releases
252252
MAGE_X_NANCY_VERSION=v1.0.52 # https://github.com/sonatype-nexus-community/nancy/releases
253253
MAGE_X_STATICCHECK_VERSION=2025.1.1 # https://github.com/dominikh/go-tools/releases
254254
MAGE_X_SWAG_VERSION=v1.16.6 # https://github.com/swaggo/swag/releases
255-
MAGE_X_YAMLFMT_VERSION=v0.20.0 # https://github.com/google/yamlfmt/releases
255+
MAGE_X_YAMLFMT_VERSION=v0.21.0 # https://github.com/google/yamlfmt/releases
256+
MAGE_X_BENCHSTAT_VERSION=v0.0.0-20251208221838-04cf7a2dca90 # https://pkg.go.dev/golang.org/x/perf/cmd/benchstat
256257

257258
# Exclude magefiles from prebuild - they require 'mage' build tag and fail without it
258259
# MAGE_X_BUILD_EXCLUDE_PATTERN=magefiles
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# ------------------------------------------------------------------------------------
2+
# Setup Benchstat Composite Action (GoFortress)
3+
#
4+
# Purpose: Install and cache the benchstat binary for use in GitHub Actions workflows.
5+
# Provides efficient caching by OS and version, with automatic binary installation
6+
# on cache miss and PATH management for seamless integration.
7+
#
8+
# Features:
9+
# - Smart binary caching by OS and version
10+
# - Automatic go install only on cache miss
11+
# - PATH management for immediate availability
12+
# - Performance tracking outputs
13+
#
14+
# Usage:
15+
# - uses: ./.github/actions/setup-benchstat
16+
# with:
17+
# benchstat-version: ${{ env.MAGE_X_BENCHSTAT_VERSION }}
18+
# runner-os: ${{ runner.os }}
19+
# go-version: ${{ matrix.go-version }}
20+
#
21+
# Maintainer: @mrz1836
22+
#
23+
# ------------------------------------------------------------------------------------
24+
25+
name: "Setup Benchstat"
26+
description: "Install and cache benchstat binary for benchmark comparison"
27+
28+
inputs:
29+
benchstat-version:
30+
description: "Benchstat version to install (e.g., v0.6.0)"
31+
required: true
32+
runner-os:
33+
description: "Runner OS for cache key (e.g., ubuntu-latest, mac-latest)"
34+
required: true
35+
go-version:
36+
description: "Go version being used (e.g., 1.24.x, 1.22). Benchstat requires Go 1.23+"
37+
required: true
38+
39+
outputs:
40+
cache-hit:
41+
description: "Whether benchstat was restored from cache (true/false). Empty if skipped due to Go version."
42+
value: ${{ steps.benchstat-cache.outputs.cache-hit }}
43+
installation-method:
44+
description: "How benchstat was obtained: cached, fresh, or skipped"
45+
value: ${{ steps.installation-summary.outputs.method }}
46+
skipped:
47+
description: "Whether benchstat installation was skipped due to Go version < 1.23"
48+
value: ${{ steps.version-check.outputs.skip }}
49+
50+
runs:
51+
using: "composite"
52+
steps:
53+
# --------------------------------------------------------------------
54+
# Check Go version compatibility (benchstat requires Go 1.23+)
55+
# --------------------------------------------------------------------
56+
- name: 🔍 Check Go version compatibility
57+
id: version-check
58+
shell: bash
59+
run: |
60+
GO_VERSION="${{ inputs.go-version }}"
61+
# Extract major and minor version:
62+
# "1.24.x" -> MAJOR=1, MINOR=24
63+
# "1.22" -> MAJOR=1, MINOR=22
64+
# "1.23.5" -> MAJOR=1, MINOR=23
65+
# "2.0.0" -> MAJOR=2, MINOR=0
66+
MAJOR=$(echo "$GO_VERSION" | sed -E 's/^([0-9]+)\..*/\1/')
67+
MINOR=$(echo "$GO_VERSION" | sed -E 's/^[0-9]+\.([0-9]+).*/\1/')
68+
69+
if [ -z "$MAJOR" ] || [ -z "$MINOR" ] || ! [[ "$MAJOR" =~ ^[0-9]+$ ]] || ! [[ "$MINOR" =~ ^[0-9]+$ ]]; then
70+
echo "❌ Could not parse Go version '$GO_VERSION'. Please provide a valid Go version (e.g., '1.23', '1.24.x')." >&2
71+
exit 1
72+
elif [ "$MAJOR" -gt 1 ]; then
73+
# Any Go major version > 1 is considered compatible with the 1.23+ requirement
74+
echo "✅ Go $GO_VERSION >= 1.23: proceeding with benchstat installation"
75+
echo "skip=false" >> $GITHUB_OUTPUT
76+
elif [ "$MAJOR" -eq 1 ] && [ "$MINOR" -lt 23 ]; then
77+
echo "⚠️ Go $GO_VERSION < 1.23: skipping benchstat installation (requires Go 1.23+)"
78+
echo "skip=true" >> $GITHUB_OUTPUT
79+
else
80+
echo "✅ Go $GO_VERSION >= 1.23: proceeding with benchstat installation"
81+
echo "skip=false" >> $GITHUB_OUTPUT
82+
fi
83+
84+
# --------------------------------------------------------------------
85+
# Restore benchstat binary cache
86+
# --------------------------------------------------------------------
87+
- name: 💾 Restore benchstat binary cache
88+
if: steps.version-check.outputs.skip != 'true'
89+
id: benchstat-cache
90+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
91+
with:
92+
path: ~/.cache/benchstat-bin
93+
key: ${{ inputs.runner-os }}-benchstat-${{ inputs.benchstat-version }}
94+
95+
# --------------------------------------------------------------------
96+
# Install cached binary to PATH when cache hits
97+
# --------------------------------------------------------------------
98+
- name: 📦 Install cached benchstat to PATH
99+
if: steps.version-check.outputs.skip != 'true' && steps.benchstat-cache.outputs.cache-hit == 'true'
100+
shell: bash
101+
run: |
102+
echo "📦 Installing cached benchstat binary to PATH..."
103+
104+
# Copy cached binary to GOPATH and add to PATH
105+
mkdir -p "$(go env GOPATH)/bin"
106+
cp ~/.cache/benchstat-bin/benchstat "$(go env GOPATH)/bin/benchstat"
107+
chmod +x "$(go env GOPATH)/bin/benchstat"
108+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
109+
110+
echo "✅ Cached benchstat binary installed to PATH"
111+
112+
# --------------------------------------------------------------------
113+
# Install benchstat via go install when cache misses
114+
# --------------------------------------------------------------------
115+
- name: ⬇️ Install benchstat (cache miss)
116+
if: steps.version-check.outputs.skip != 'true' && steps.benchstat-cache.outputs.cache-hit != 'true'
117+
shell: bash
118+
run: |
119+
echo "⬇️ Cache miss – installing benchstat via go install..."
120+
echo "📋 Installing benchstat version: ${{ inputs.benchstat-version }}"
121+
122+
# Install benchstat
123+
go install "golang.org/x/perf/cmd/benchstat@${{ inputs.benchstat-version }}"
124+
125+
# Cache the binary for future runs
126+
mkdir -p ~/.cache/benchstat-bin
127+
cp "$(go env GOPATH)/bin/benchstat" ~/.cache/benchstat-bin/benchstat
128+
129+
# Ensure GOPATH/bin is in PATH
130+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
131+
132+
echo "✅ Benchstat installed and cached"
133+
134+
# --------------------------------------------------------------------
135+
# Verify benchstat installation and set outputs
136+
# --------------------------------------------------------------------
137+
- name: 🔍 Verify benchstat installation
138+
id: installation-summary
139+
shell: bash
140+
run: |
141+
# Check if installation was skipped due to Go version
142+
if [[ "${{ steps.version-check.outputs.skip }}" == "true" ]]; then
143+
echo "⏭️ Benchstat installation skipped (Go version < 1.23)"
144+
echo "method=skipped" >> $GITHUB_OUTPUT
145+
echo "📋 Installation method: Skipped"
146+
exit 0
147+
fi
148+
149+
echo "🔍 Verifying benchstat installation..."
150+
151+
# Test that benchstat is available and working
152+
if ! command -v benchstat >/dev/null 2>&1; then
153+
echo "❌ ERROR: benchstat is not available in PATH" >&2
154+
exit 1
155+
fi
156+
157+
# Show version
158+
echo "✅ benchstat is available"
159+
benchstat -h 2>&1 | head -3 || true
160+
161+
# Determine installation method
162+
if [[ "${{ steps.benchstat-cache.outputs.cache-hit }}" == "true" ]]; then
163+
echo "method=cached" >> $GITHUB_OUTPUT
164+
echo "📋 Installation method: Cached"
165+
else
166+
echo "method=fresh" >> $GITHUB_OUTPUT
167+
echo "📋 Installation method: Fresh install"
168+
fi

.github/actions/upload-statistics/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ inputs:
4545
description: "Compression level for the artifact (0-9, 6 is default)"
4646
required: false
4747
default: "6"
48+
continue-on-error:
49+
description: "Continue workflow if upload fails (for non-critical artifacts)"
50+
required: false
51+
default: "false"
4852

4953
runs:
5054
using: "composite"
@@ -54,6 +58,7 @@ runs:
5458
# --------------------------------------------------------------------
5559
- name: 📤 Upload ${{ inputs.artifact-name }}
5660
if: always() # Always run to capture data even on job failure
61+
continue-on-error: ${{ inputs.continue-on-error == 'true' }}
5762
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
5863
with:
5964
name: ${{ inputs.artifact-name }}

.github/tech-conventions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ Creating and maintaining GitHub Actions workflows with security, reliability, an
5959

6060
### 🏗️ Build & Project Setup
6161

62-
**[MAGE-X Build Automation](mage-x.md)**
63-
Zero-boilerplate build automation system with 150+ built-in commands that replaces Makefiles. Includes installation, configuration, command reference, and migration guide.
62+
**[MAGE-X Build Tooling](mage-x.md)**
63+
Zero-boilerplate build toolchain with 150+ built-in commands that replaces Makefiles. Includes installation, configuration, command reference, and migration guide.

.github/tech-conventions/mage-x.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# MAGE-X Build Automation
1+
# MAGE-X Build Tooling
22

3-
> Zero-boilerplate build automation for Go projects that replaces Makefiles with 150+ built-in commands and intelligent configuration.
3+
> Zero-boilerplate build tooling for Go projects that replaces Makefiles with 150+ built-in commands and intelligent configuration.
44
55
<br><br>
66

77
## 🚀 What is MAGE-X?
88

9-
**MAGE-X** is a revolutionary zero-configuration build automation system for Go that provides **truly zero-boilerplate** development workflows. Unlike traditional build systems that require extensive configuration or wrapper functions, MAGE-X delivers all commands instantly through a single `magex` binary.
9+
**MAGE-X** is a revolutionary zero-configuration build toolchain for Go that provides **truly zero-boilerplate** development workflows. Unlike traditional build systems that require extensive configuration or wrapper functions, MAGE-X delivers all commands instantly through a single `magex` binary.
1010

1111
### Core Philosophy
1212

13-
**"Write Once, Mage Everywhere: Production Build Automation for Go"**
13+
**"Write Once, Mage Everywhere: Production Build Tooling for Go"**
1414

1515
- **Zero Setup Required**: No magefile.go needed for basic operations
1616
- **150+ Built-in Commands**: Complete build, test, lint, release, and deployment workflows
@@ -654,6 +654,6 @@ magex --help # Global help and options and list all comma
654654
5. **Performance**: Significantly faster than traditional build tools
655655
6. **Production Ready**: Security, compliance, and governance features built-in
656656

657-
MAGE-X transforms Go build automation from a chore into a productivity multiplier, enabling teams to focus on code rather than tooling configuration.
657+
MAGE-X transforms Go build tasks from a chore into a productivity multiplier, enabling teams to focus on code rather than tooling configuration.
658658

659-
**Next Steps**: Install MAGE-X, run `magex build` in your project, and experience zero-configuration build automation.
659+
**Next Steps**: Install MAGE-X, run `magex build` in your project, and experience zero-configuration build tooling.

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
# --------------------------------------------------------------------
165165
- name: 📊 Fetch Dependabot metadata
166166
id: metadata
167-
uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b # v2.4.0
167+
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
168168
with:
169169
github-token: ${{ secrets.GITHUB_TOKEN }}
170170

.github/workflows/fortress-completion-statistics.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ jobs:
632632
artifact-path: "statistics-section.md"
633633
retention-days: "1"
634634
if-no-files-found: "warn"
635+
continue-on-error: "true"
635636

636637
- name: 📋 Set Output Content
637638
id: set-output

.github/workflows/fortress-coverage.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ jobs:
737737
738738
# Count processed files from coverage output
739739
if [ -f "$COVERAGE_FILE" ]; then
740-
FILES_PROCESSED=$(wc -l < "$COVERAGE_FILE" || echo "0")
740+
FILES_PROCESSED=$(grep -v '^mode:' "$COVERAGE_FILE" | grep '^[^:]*:' | grep -o '^[^:]*' | sort -u | wc -l | tr -d ' ' || echo "0")
741741
echo "📁 Files processed: $FILES_PROCESSED"
742742
fi
743743
@@ -2425,12 +2425,51 @@ jobs:
24252425
24262426
# Calculate coverage from coverage.txt file using go tool cover
24272427
if [ -f "coverage-artifacts/coverage-data/coverage.txt" ]; then
2428-
COVERAGE_PERCENTAGE=$(go tool cover -func="coverage-artifacts/coverage-data/coverage.txt" | tail -1 | awk '{print $3}' | sed 's/%//' || echo "0")
2429-
FILES_PROCESSED=$(wc -l < "coverage-artifacts/coverage-data/coverage.txt" || echo "0")
2428+
# First, try direct calculation (suppress stderr to avoid module warnings)
2429+
COVERAGE_PERCENTAGE=$(go tool cover -func="coverage-artifacts/coverage-data/coverage.txt" 2>/dev/null | tail -1 | awk '{print $3}' | sed 's/%//' || true)
2430+
2431+
# Validate result - must be a number (handles empty output or errors)
2432+
if [[ -z "$COVERAGE_PERCENTAGE" ]] || ! [[ "$COVERAGE_PERCENTAGE" =~ ^[0-9]+\.?[0-9]*$ ]]; then
2433+
echo "⚠️ Could not calculate coverage percentage directly, trying manual calculation..."
2434+
COVERAGE_PERCENTAGE=""
2435+
2436+
# Fallback: Calculate from coverage file lines manually
2437+
# Coverage file format: path/file.go:startLine.startCol,endLine.endCol stmtCount hitCount
2438+
TOTAL_STATEMENTS=0
2439+
COVERED_STATEMENTS=0
2440+
while IFS= read -r line; do
2441+
# Skip header line (mode: ...)
2442+
[[ "$line" == mode:* ]] && continue
2443+
# Skip empty lines
2444+
[[ -z "$line" ]] && continue
2445+
# Extract statement count (first number) and hit count (second number)
2446+
# Format: path/file.go:startLine.startCol,endLine.endCol stmtCount hitCount
2447+
if [[ "$line" =~ [[:space:]]([0-9]+)[[:space:]]([0-9]+)$ ]]; then
2448+
STMT_COUNT="${BASH_REMATCH[1]}"
2449+
HIT_COUNT="${BASH_REMATCH[2]}"
2450+
TOTAL_STATEMENTS=$((TOTAL_STATEMENTS + STMT_COUNT))
2451+
if [[ $HIT_COUNT -gt 0 ]]; then
2452+
COVERED_STATEMENTS=$((COVERED_STATEMENTS + STMT_COUNT))
2453+
fi
2454+
fi
2455+
done < "coverage-artifacts/coverage-data/coverage.txt"
2456+
2457+
if [[ $TOTAL_STATEMENTS -gt 0 ]]; then
2458+
COVERAGE_PERCENTAGE=$(awk "BEGIN {printf \"%.1f\", ($COVERED_STATEMENTS / $TOTAL_STATEMENTS) * 100}")
2459+
echo "📈 Calculated coverage manually: ${COVERAGE_PERCENTAGE}% ($COVERED_STATEMENTS/$TOTAL_STATEMENTS statements)"
2460+
else
2461+
COVERAGE_PERCENTAGE="0"
2462+
echo "⚠️ No coverage data found, defaulting to 0%"
2463+
fi
2464+
fi
2465+
2466+
FILES_PROCESSED=$(grep -v '^mode:' "coverage-artifacts/coverage-data/coverage.txt" | grep '^[^:]*:' | grep -o '^[^:]*' | sort -u | wc -l | tr -d ' ' || echo "0")
24302467
echo "📈 Calculated coverage percentage: ${COVERAGE_PERCENTAGE}%"
24312468
echo "📁 Files processed: $FILES_PROCESSED"
24322469
else
24332470
echo "⚠️ Coverage file not found for statistics"
2471+
COVERAGE_PERCENTAGE="0"
2472+
FILES_PROCESSED="0"
24342473
fi
24352474
24362475
# Codecov job doesn't generate badges or deploy pages directly

.github/workflows/fortress-test-matrix.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ jobs:
170170
runner-os: ${{ matrix.os }}
171171
use-local: ${{ env.MAGE_X_USE_LOCAL }}
172172

173+
# --------------------------------------------------------------------
174+
# Setup benchstat (required for benchmark comparison tests)
175+
# Note: benchstat requires Go 1.23+, action will skip for older versions
176+
# --------------------------------------------------------------------
177+
- name: 📊 Setup benchstat
178+
uses: ./.github/actions/setup-benchstat
179+
with:
180+
benchstat-version: ${{ env.MAGE_X_BENCHSTAT_VERSION }}
181+
runner-os: ${{ matrix.os }}
182+
go-version: ${{ matrix.go-version }}
183+
173184
# --------------------------------------------------------------------
174185
# Setup Redis service using composite action with caching
175186
# --------------------------------------------------------------------

0 commit comments

Comments
 (0)