Skip to content

Commit 4dc47b7

Browse files
authored
sync: update 16 files from source repository (#191)
1 parent 91856b2 commit 4dc47b7

16 files changed

+349
-134
lines changed

.github/.env.base

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ GO_PRIMARY_VERSION=1.24.x
3636
# Set to same as primary to test with single version only
3737
GO_SECONDARY_VERSION=1.24.x
3838

39+
# Govulncheck-specific Go version for vulnerability scanning
40+
# Uses newer Go version for accurate standard library vulnerability detection
41+
# Override this in .env.custom if needed for compatibility
42+
GOVULNCHECK_GO_VERSION=1.25.x
43+
3944
# ================================================================================================
4045
# 📦 GO MODULE CONFIGURATION
4146
# ================================================================================================
@@ -73,6 +78,7 @@ PREFERRED_GITHUB_TOKEN=GH_PAT_TOKEN
7378

7479
# Core Features
7580
ENABLE_BENCHMARKS=true # Run benchmark tests
81+
ENABLE_CACHE_WARMING=true # Warm Go module and build caches
7682
ENABLE_CODE_COVERAGE=true # Generate coverage reports via go-coverage
7783
ENABLE_FUZZ_TESTING=true # Run fuzz tests (Go 1.18+)
7884
ENABLE_RACE_DETECTION=true # Enable Go race detector
@@ -225,14 +231,15 @@ REDIS_CACHE_FORCE_PULL=false # Force pull Redis images even when cache
225231
# 🪄 MAGE-X CONFIGURATION
226232
# ================================================================================================
227233

228-
MAGE_X_VERSION=v1.7.6 # https://github.com/mrz1836/mage-x/releases
234+
MAGE_X_VERSION=v1.7.9 # https://github.com/mrz1836/mage-x/releases
235+
MAGE_X_USE_LOCAL=false # Use local version for development
229236
MAGE_X_AUTO_DISCOVER_BUILD_TAGS=true # Enable auto-discovery of build tags
230237
MAGE_X_AUTO_DISCOVER_BUILD_TAGS_EXCLUDE=race,custom # Comma-separated list of tags to exclude
231238
MAGE_X_FORMAT_EXCLUDE_PATHS=vendor,node_modules,.git,.idea # Format exclusion paths (comma-separated directories to exclude from formatting)
232239
MAGE_X_GITLEAKS_VERSION=8.28.0 # https://github.com/gitleaks/gitleaks/releases
233240
MAGE_X_GOFUMPT_VERSION=v0.9.1 # https://github.com/mvdan/gofumpt/releases
234241
MAGE_X_GOLANGCI_LINT_VERSION=v2.5.0 # https://github.com/golangci/golangci-lint/releases
235-
MAGE_X_GORELEASER_VERSION=v2.12.2 # https://github.com/goreleaser/goreleaser/releases
242+
MAGE_X_GORELEASER_VERSION=v2.12.7 # https://github.com/goreleaser/goreleaser/releases
236243
MAGE_X_GOVULNCHECK_VERSION=v1.1.4 # https://pkg.go.dev/golang.org/x/vuln
237244
MAGE_X_GO_SECONDARY_VERSION=1.24.x # Secondary Go version for MAGE-X (also our secondary)
238245
MAGE_X_GO_VERSION=1.24.x # Primary Go version for MAGE-X (also our primary)

.github/actions/setup-magex/action.yml

Lines changed: 112 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ inputs:
3131
runner-os:
3232
description: "Runner OS for cache key (e.g., ubuntu-latest, windows-latest)"
3333
required: true
34+
use-local:
35+
description: "Build from local source instead of downloading release"
36+
required: false
37+
default: 'false'
3438

3539
outputs:
3640
cache-hit:
@@ -48,37 +52,65 @@ runs:
4852
# --------------------------------------------------------------------
4953
- name: 💾 Restore magex binary cache
5054
id: magex-cache
55+
if: inputs.use-local != 'true'
5156
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
5257
with:
5358
path: |
5459
~/.cache/magex-bin
5560
key: ${{ inputs.runner-os }}-magex-${{ inputs.magex-version }}
5661

5762
# --------------------------------------------------------------------
58-
# Make cached magex usable by copying to GOPATH/bin and adding to PATH
63+
# Install cached binary to PATH when remote cache hits
5964
# --------------------------------------------------------------------
60-
- name: 🛠️ Make cached magex usable
65+
- name: 📦 Install cached MAGE-X to PATH (remote mode)
66+
if: inputs.use-local != 'true' && steps.magex-cache.outputs.cache-hit == 'true'
6167
shell: bash
6268
run: |
63-
set -euo pipefail
64-
BIN_DIR="$HOME/.cache/magex-bin"
65-
MAGEX_BIN="$BIN_DIR/magex"
66-
67-
# If we restored a cache, copy/link it into GOPATH/bin.
68-
if [[ -f "$MAGEX_BIN" ]]; then
69-
echo "✅ Using cached magex binary"
70-
mkdir -p "$(go env GOPATH)/bin"
71-
cp "$MAGEX_BIN" "$(go env GOPATH)/bin/"
72-
fi
69+
echo "📦 Installing cached MAGE-X binary to PATH..."
7370
74-
# Make sure the binary location is on PATH for *all* subsequent steps.
71+
# Copy cached binary to GOPATH and add to PATH
72+
mkdir -p "$(go env GOPATH)/bin"
73+
cp ~/.cache/magex-bin/magex "$(go env GOPATH)/bin/magex"
74+
chmod +x "$(go env GOPATH)/bin/magex"
7575
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
7676
77+
echo "✅ Cached MAGE-X binary installed to PATH"
78+
7779
# --------------------------------------------------------------------
78-
# Detect platform and download MAGE-X binary *only* when the cache was empty.
80+
# Restore local build cache (commit-specific for local builds)
7981
# --------------------------------------------------------------------
80-
- name: ✅ Download MAGE-X binary (cache miss)
81-
if: steps.magex-cache.outputs.cache-hit != 'true'
82+
- name: 💾 Restore magex binary cache (local)
83+
id: magex-local-cache
84+
if: inputs.use-local == 'true'
85+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
86+
with:
87+
path: |
88+
~/.cache/magex-local
89+
key: ${{ inputs.runner-os }}-local-magex-${{ github.sha }}
90+
# No restore-keys: local builds are commit-specific only to prevent stale cache issues
91+
92+
# --------------------------------------------------------------------
93+
# Install cached binary to PATH when local cache hits
94+
# --------------------------------------------------------------------
95+
- name: 📦 Install cached MAGE-X to PATH (local mode)
96+
if: inputs.use-local == 'true' && steps.magex-local-cache.outputs.cache-hit == 'true'
97+
shell: bash
98+
run: |
99+
echo "📦 Installing cached MAGE-X binary to PATH..."
100+
101+
# Copy cached binary to GOPATH and add to PATH
102+
mkdir -p "$(go env GOPATH)/bin"
103+
cp ~/.cache/magex-local/magex "$(go env GOPATH)/bin/magex"
104+
chmod +x "$(go env GOPATH)/bin/magex"
105+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
106+
107+
echo "✅ Cached MAGE-X binary installed to PATH"
108+
109+
# --------------------------------------------------------------------
110+
# Download MAGE-X binary for remote mode when cache misses
111+
# --------------------------------------------------------------------
112+
- name: ✅ Download MAGE-X binary (remote mode only)
113+
if: inputs.use-local != 'true' && steps.magex-cache.outputs.cache-hit != 'true'
82114
shell: bash
83115
run: |
84116
echo "⬇️ Cache miss – downloading MAGE-X binary..."
@@ -142,21 +174,60 @@ runs:
142174
143175
echo "✅ Found magex binary at: $MAGEX_BINARY"
144176
145-
# Make it executable and copy to GOPATH/bin
177+
# Make it executable and copy to cache directory
146178
chmod +x "$MAGEX_BINARY"
147-
mkdir -p "$(go env GOPATH)/bin"
148-
cp "$MAGEX_BINARY" "$(go env GOPATH)/bin/magex"
149-
150-
# Copy to cache directory for future runs
151179
mkdir -p ~/.cache/magex-bin
152180
cp "$MAGEX_BINARY" ~/.cache/magex-bin/magex
153181
182+
# Copy to GOPATH and add to PATH for subsequent steps
183+
mkdir -p "$(go env GOPATH)/bin"
184+
cp ~/.cache/magex-bin/magex "$(go env GOPATH)/bin/magex"
185+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
186+
154187
# Cleanup
155188
cd /
156189
rm -rf "$TEMP_DIR"
157190
158191
echo "✅ MAGE-X binary downloaded and cached"
159192
193+
# --------------------------------------------------------------------
194+
# Build MAGE-X from local source (when use-local is true)
195+
# --------------------------------------------------------------------
196+
- name: 🔨 Build MAGE-X from local source
197+
id: build-local
198+
if: inputs.use-local == 'true' && steps.magex-local-cache.outputs.cache-hit != 'true'
199+
shell: bash
200+
run: |
201+
echo "📦 Building local development version of MAGE-X"
202+
cd "$GITHUB_WORKSPACE"
203+
204+
# Check if source directory exists (we're in mage-x repo with full checkout)
205+
if [ ! -d "./cmd/magex" ]; then
206+
echo "❌ ERROR: ./cmd/magex directory not found"
207+
echo "❌ use-local=true requires mage-x repository with full checkout"
208+
echo "❌ Either set use-local=false or ensure full repository checkout"
209+
exit 1
210+
fi
211+
212+
# Build from local source
213+
echo "🔨 Building magex from ./cmd/magex..."
214+
go build -v -o /tmp/magex ./cmd/magex
215+
chmod +x /tmp/magex
216+
217+
# Show version for debugging
218+
/tmp/magex --version || echo "⚠️ Version check skipped"
219+
220+
# Copy to local cache for future runs
221+
mkdir -p ~/.cache/magex-local
222+
cp /tmp/magex ~/.cache/magex-local/magex
223+
224+
# Add magex to PATH for subsequent steps
225+
mkdir -p "$(go env GOPATH)/bin"
226+
cp ~/.cache/magex-local/magex "$(go env GOPATH)/bin/magex"
227+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
228+
229+
echo "✅ MAGE-X built from local source and cached"
230+
160231
# --------------------------------------------------------------------
161232
# Verify MAGE-X installation and set outputs
162233
# --------------------------------------------------------------------
@@ -167,19 +238,29 @@ runs:
167238
echo "🔍 Verifying MAGE-X installation..."
168239
169240
# Test that magex is available and working
170-
if command -v magex >/dev/null 2>&1; then
171-
MAGEX_VERSION=$(magex --version 2>/dev/null | grep -E '^\s+Version:' | awk '{print $2}' || echo "unknown")
172-
echo "✅ MAGE-X is available: $MAGEX_VERSION"
241+
if ! command -v magex >/dev/null 2>&1; then
242+
echo "❌ ERROR: MAGE-X is not available in PATH" >&2
243+
exit 1
244+
fi
173245
174-
# Determine installation method
175-
if [[ "${{ steps.magex-cache.outputs.cache-hit }}" == "true" ]]; then
246+
MAGEX_VERSION=$(magex --version 2>/dev/null | grep -E '^\s+Version:' | awk '{print $2}' || echo "unknown")
247+
echo "✅ MAGE-X $MAGEX_VERSION is available"
248+
249+
# Determine installation method based on mode and cache status
250+
if [[ "${{ inputs.use-local }}" == "true" ]]; then
251+
if [[ "${{ steps.magex-local-cache.outputs.cache-hit }}" == "true" ]]; then
176252
echo "method=cached" >> $GITHUB_OUTPUT
177-
echo "📋 Installation method: Restored from cache"
253+
echo "📋 Installation method: Cached (local build)"
178254
else
179-
echo "method=fresh" >> $GITHUB_OUTPUT
180-
echo "📋 Installation method: Fresh binary download"
255+
echo "method=fresh-build" >> $GITHUB_OUTPUT
256+
echo "📋 Installation method: Fresh build from source"
181257
fi
182258
else
183-
echo "❌ ERROR: MAGE-X is not available in PATH" >&2
184-
exit 1
259+
if [[ "${{ steps.magex-cache.outputs.cache-hit }}" == "true" ]]; then
260+
echo "method=cached" >> $GITHUB_OUTPUT
261+
echo "📋 Installation method: Cached (remote download)"
262+
else
263+
echo "method=fresh-download" >> $GITHUB_OUTPUT
264+
echo "📋 Installation method: Fresh download from releases"
265+
fi
185266
fi

.github/actions/warm-cache/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ runs:
223223
if [ -n "$GO_MODULE_DIR" ]; then
224224
echo "🔧 Running build commands from directory: $GO_MODULE_DIR"
225225
# Use configured parallelism to avoid OOM on GitHub Actions runners
226-
(cd "$GO_MODULE_DIR" && magex build:prebuild p="$PARALLEL_JOBS" strategy=smart)
226+
(cd "$GO_MODULE_DIR" && magex build:prebuild p="$PARALLEL_JOBS" strategy="${MAGE_X_BUILD_STRATEGY:-smart}" batch_size="${MAGE_X_BUILD_BATCH_SIZE:-20}" batch_delay="${MAGE_X_BUILD_BATCH_DELAY_MS:-0}" exclude="${MAGE_X_BUILD_EXCLUDE_PATTERN:-}")
227227
228228
echo "🏗️ Building stdlib for host platform..."
229229
(cd "$GO_MODULE_DIR" && magex install:stdlib)
230230
else
231231
echo "🔧 Running build commands from repository root"
232232
# Use configured parallelism to avoid OOM on GitHub Actions runners
233-
magex build:prebuild p="$PARALLEL_JOBS" strategy=smart
233+
magex build:prebuild p="$PARALLEL_JOBS" strategy="${MAGE_X_BUILD_STRATEGY:-smart}" batch_size="${MAGE_X_BUILD_BATCH_SIZE:-20}" batch_delay="${MAGE_X_BUILD_BATCH_DELAY_MS:-0}" exclude="${MAGE_X_BUILD_EXCLUDE_PATTERN:-}"
234234
235235
echo "🏗️ Building stdlib for host platform..."
236236
magex install:stdlib

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
# Initializes the CodeQL tools for scanning.
4949
- name: Initialize CodeQL
50-
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
50+
uses: github/codeql-action/init@5fe9434cd24fe243e33e7f3305f8a5b519b70280 # v4.31.1
5151
with:
5252
languages: ${{ matrix.language }}
5353
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -58,7 +58,7 @@ jobs:
5858
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below)
6060
- name: Autobuild
61-
uses: github/codeql-action/autobuild@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
61+
uses: github/codeql-action/autobuild@5fe9434cd24fe243e33e7f3305f8a5b519b70280 # v4.31.1
6262

6363
# ℹ️ Command-line programs to run using the OS shell.
6464
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# uses a compiled language
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
71+
uses: github/codeql-action/analyze@5fe9434cd24fe243e33e7f3305f8a5b519b70280 # v4.31.1

.github/workflows/fortress-benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ jobs:
159159
with:
160160
magex-version: ${{ env.MAGE_X_VERSION }}
161161
runner-os: ${{ matrix.os }}
162+
use-local: ${{ env.MAGE_X_USE_LOCAL }}
162163

163164
# --------------------------------------------------------------------
164165
# Setup Redis service using composite action with caching

.github/workflows/fortress-code-quality.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ jobs:
109109
with:
110110
magex-version: ${{ env.MAGE_X_VERSION }}
111111
runner-os: ${{ inputs.primary-runner }}
112+
use-local: ${{ env.MAGE_X_USE_LOCAL }}
112113

113114
# --------------------------------------------------------------------
114115
# Run go vet with sequential execution to avoid memory issues
@@ -231,16 +232,6 @@ jobs:
231232
echo "GOMODCACHE=$HOME/go/pkg/mod" >> $GITHUB_ENV
232233
echo "GOLANGCI_LINT_CACHE=$HOME/.cache/golangci-lint" >> $GITHUB_ENV
233234
234-
# --------------------------------------------------------------------
235-
# Extract golangci-lint version (MAGE-X managed)
236-
# --------------------------------------------------------------------
237-
- name: 🔍 Use MAGE-X managed golangci-lint version
238-
id: golangci-lint-version
239-
run: |
240-
# MAGE-X handles golangci-lint version automatically
241-
echo "✅ Using MAGE-X managed golangci-lint version"
242-
echo "version=${{ env.MAGE_X_GOLANGCI_LINT_VERSION }}" >> $GITHUB_OUTPUT
243-
244235
# --------------------------------------------------------------------
245236
# Setup Go with caching and version management
246237
# --------------------------------------------------------------------
@@ -270,6 +261,7 @@ jobs:
270261
with:
271262
magex-version: ${{ env.MAGE_X_VERSION }}
272263
runner-os: ${{ inputs.primary-runner }}
264+
use-local: ${{ env.MAGE_X_USE_LOCAL }}
273265

274266
# --------------------------------------------------------------------
275267
# Restore Cache golangci-lint
@@ -279,7 +271,7 @@ jobs:
279271
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
280272
with:
281273
path: ${{ env.GOLANGCI_LINT_CACHE }}
282-
key: ${{ inputs.primary-runner }}-golangci-lint-analysis-${{ hashFiles('.golangci.json', env.GO_SUM_FILE) }}-${{ steps.golangci-lint-version.outputs.version }}
274+
key: ${{ inputs.primary-runner }}-golangci-lint-analysis-${{ hashFiles('.golangci.json', env.GO_SUM_FILE) }}
283275

284276
- name: 🔍 Debug cache usage
285277
run: |
@@ -409,6 +401,7 @@ jobs:
409401
with:
410402
magex-version: ${{ env.MAGE_X_VERSION }}
411403
runner-os: ${{ inputs.primary-runner }}
404+
use-local: ${{ env.MAGE_X_USE_LOCAL }}
412405

413406
# --------------------------------------------------------------------
414407
# Get yamlfmt version from MAGE-X

.github/workflows/fortress-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ jobs:
138138
with:
139139
magex-version: ${{ env.MAGE_X_VERSION }}
140140
runner-os: ${{ inputs.primary-runner }}
141+
use-local: ${{ env.MAGE_X_USE_LOCAL }}
141142

142143
# --------------------------------------------------------------------
143144
# Extract GoReleaser version from environment

.github/workflows/fortress-security-scans.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,14 @@ jobs:
204204

205205
# --------------------------------------------------------------------
206206
# Setup Go with caching and version management
207+
# Uses GOVULNCHECK_GO_VERSION if set, otherwise falls back to primary version
208+
# This allows govulncheck to use a newer Go version for accurate stdlib vulnerability detection
207209
# --------------------------------------------------------------------
208210
- name: 🏗️ Setup Go with Cache
209211
id: setup-govulncheck
210212
uses: ./.github/actions/setup-go-with-cache
211213
with:
212-
go-version: ${{ inputs.go-primary-version }}
214+
go-version: ${{ env.GOVULNCHECK_GO_VERSION || inputs.go-primary-version }}
213215
matrix-os: ${{ inputs.primary-runner }}
214216
go-primary-version: ${{ inputs.go-primary-version }}
215217
go-secondary-version: ${{ inputs.go-primary-version }}
@@ -231,6 +233,7 @@ jobs:
231233
with:
232234
magex-version: ${{ env.MAGE_X_VERSION }}
233235
runner-os: ${{ inputs.primary-runner }}
236+
use-local: ${{ env.MAGE_X_USE_LOCAL }}
234237

235238
# --------------------------------------------------------------------
236239
# Restore (and later save) a compact cache for the govulncheck binary

0 commit comments

Comments
 (0)