From 5b36f14c35532cd682ebac7e794ffcf16a0c2df2 Mon Sep 17 00:00:00 2001 From: "Mr. Z" Date: Wed, 14 Jan 2026 12:45:55 -0500 Subject: [PATCH] sync(ci): update mage-x to v1.17.4 and tool versions --- .github/.env.base | 9 +- .github/actions/setup-mage/action.yml | 120 +++++++++++++++++++++ .github/workflows/fortress-test-matrix.yml | 9 ++ 3 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 .github/actions/setup-mage/action.yml diff --git a/.github/.env.base b/.github/.env.base index a04e78b..a0dc290 100644 --- a/.github/.env.base +++ b/.github/.env.base @@ -235,7 +235,7 @@ REDIS_CACHE_FORCE_PULL=false # Force pull Redis images even when cache # 🪄 MAGE-X CONFIGURATION # ================================================================================================ -MAGE_X_VERSION=v1.15.5 # https://github.com/mrz1836/mage-x/releases +MAGE_X_VERSION=v1.17.4 # https://github.com/mrz1836/mage-x/releases MAGE_X_USE_LOCAL=false # Use local version for development MAGE_X_CI_SKIP_STEP_SUMMARY=true # Skip duplicate test results in step summary (already in test validation summary) MAGE_X_AUTO_DISCOVER_BUILD_TAGS=true # Enable auto-discovery of build tags @@ -244,7 +244,7 @@ MAGE_X_FORMAT_EXCLUDE_PATHS=vendor,node_modules,.git,.idea # Format exclusion MAGE_X_GITLEAKS_VERSION=8.30.0 # https://github.com/gitleaks/gitleaks/releases MAGE_X_GOFUMPT_VERSION=v0.9.2 # https://github.com/mvdan/gofumpt/releases MAGE_X_GOLANGCI_LINT_VERSION=v2.8.0 # https://github.com/golangci/golangci-lint/releases -MAGE_X_GORELEASER_VERSION=v2.13.2 # https://github.com/goreleaser/goreleaser/releases +MAGE_X_GORELEASER_VERSION=v2.13.3 # https://github.com/goreleaser/goreleaser/releases MAGE_X_GOVULNCHECK_VERSION=v1.1.4 # https://go.googlesource.com/vuln/+refs MAGE_X_GO_SECONDARY_VERSION=1.24.x # Secondary Go version for MAGE-X (also our secondary) MAGE_X_GO_VERSION=1.24.x # Primary Go version for MAGE-X (also our primary) @@ -253,7 +253,8 @@ MAGE_X_NANCY_VERSION=v1.0.52 # https://github.c MAGE_X_STATICCHECK_VERSION=2025.1.1 # https://github.com/dominikh/go-tools/releases MAGE_X_SWAG_VERSION=v1.16.6 # https://github.com/swaggo/swag/releases MAGE_X_YAMLFMT_VERSION=v0.21.0 # https://github.com/google/yamlfmt/releases -MAGE_X_BENCHSTAT_VERSION=v0.0.0-20251208221838-04cf7a2dca90 # https://pkg.go.dev/golang.org/x/perf/cmd/benchstat +MAGE_X_BENCHSTAT_VERSION=v0.0.0-20260112171951-5abaabe9f1bd # https://pkg.go.dev/golang.org/x/perf/cmd/benchstat +MAGE_X_MAGE_VERSION=v1.15.0 # https://github.com/magefile/mage/releases # Exclude magefiles from prebuild - they require 'mage' build tag and fail without it # MAGE_X_BUILD_EXCLUDE_PATTERN=magefiles @@ -315,7 +316,7 @@ NANCY_VERSION=v1.0.52 # https://github.com/sonatype-nexus-commu # ================================================================================================ # Pre-Commit System -GO_PRE_COMMIT_VERSION=v1.4.6 # https://github.com/mrz1836/go-pre-commit/releases +GO_PRE_COMMIT_VERSION=v1.5.1 # https://github.com/mrz1836/go-pre-commit/releases GO_PRE_COMMIT_USE_LOCAL=false # Use local version for development # System Settings diff --git a/.github/actions/setup-mage/action.yml b/.github/actions/setup-mage/action.yml new file mode 100644 index 0000000..966feb8 --- /dev/null +++ b/.github/actions/setup-mage/action.yml @@ -0,0 +1,120 @@ +# ------------------------------------------------------------------------------------ +# Setup Mage Composite Action (GoFortress) +# +# Purpose: Install and cache the mage binary for use in GitHub Actions workflows. +# Provides efficient caching by OS and version, with automatic binary installation +# on cache miss and PATH management for seamless integration. +# +# Features: +# - Smart binary caching by OS and version +# - Automatic go install only on cache miss +# - PATH management for immediate availability +# +# Usage: +# - uses: ./.github/actions/setup-mage +# with: +# mage-version: ${{ env.MAGE_X_MAGE_VERSION }} +# runner-os: ${{ runner.os }} +# +# Maintainer: @mrz1836 +# +# ------------------------------------------------------------------------------------ + +name: "Setup Mage" +description: "Install and cache mage binary for magefile execution" + +inputs: + mage-version: + description: "Mage version to install (e.g., v1.15.0)" + required: true + runner-os: + description: "Runner OS for cache key (e.g., ubuntu-latest)" + required: true + +outputs: + cache-hit: + description: "Whether mage was restored from cache (true/false)" + value: ${{ steps.mage-cache.outputs.cache-hit }} + installation-method: + description: "How mage was obtained: cached or fresh" + value: ${{ steps.installation-summary.outputs.method }} + +runs: + using: "composite" + steps: + # -------------------------------------------------------------------- + # Restore mage binary cache + # -------------------------------------------------------------------- + - name: 💾 Restore mage binary cache + id: mage-cache + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 + with: + path: ~/.cache/mage-bin + key: ${{ inputs.runner-os }}-mage-${{ inputs.mage-version }} + + # -------------------------------------------------------------------- + # Install cached binary to PATH when cache hits + # -------------------------------------------------------------------- + - name: 📦 Install cached mage to PATH + if: steps.mage-cache.outputs.cache-hit == 'true' + shell: bash + run: | + echo "📦 Installing cached mage binary to PATH..." + + # Copy cached binary to GOPATH and add to PATH + mkdir -p "$(go env GOPATH)/bin" + cp ~/.cache/mage-bin/mage "$(go env GOPATH)/bin/mage" + chmod +x "$(go env GOPATH)/bin/mage" + echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" + + echo "✅ Cached mage binary installed to PATH" + + # -------------------------------------------------------------------- + # Install mage via go install when cache misses + # -------------------------------------------------------------------- + - name: ⬇️ Install mage (cache miss) + if: steps.mage-cache.outputs.cache-hit != 'true' + shell: bash + run: | + echo "⬇️ Cache miss – installing mage via go install..." + echo "📋 Installing mage version: ${{ inputs.mage-version }}" + + # Install mage + go install "github.com/magefile/mage@${{ inputs.mage-version }}" + + # Cache the binary for future runs + mkdir -p ~/.cache/mage-bin + cp "$(go env GOPATH)/bin/mage" ~/.cache/mage-bin/mage + + # Ensure GOPATH/bin is in PATH + echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" + + echo "✅ Mage installed and cached" + + # -------------------------------------------------------------------- + # Verify mage installation and set outputs + # -------------------------------------------------------------------- + - name: 🔍 Verify mage installation + id: installation-summary + shell: bash + run: | + echo "🔍 Verifying mage installation..." + + # Test that mage is available and working + if ! command -v mage >/dev/null 2>&1; then + echo "❌ ERROR: mage is not available in PATH" >&2 + exit 1 + fi + + # Show version + MAGE_VERSION=$(mage -version 2>&1 | head -1 || echo "unknown") + echo "✅ mage $MAGE_VERSION is available" + + # Determine installation method + if [[ "${{ steps.mage-cache.outputs.cache-hit }}" == "true" ]]; then + echo "method=cached" >> $GITHUB_OUTPUT + echo "📋 Installation method: Cached" + else + echo "method=fresh" >> $GITHUB_OUTPUT + echo "📋 Installation method: Fresh install" + fi diff --git a/.github/workflows/fortress-test-matrix.yml b/.github/workflows/fortress-test-matrix.yml index 5cbc5eb..7552acc 100644 --- a/.github/workflows/fortress-test-matrix.yml +++ b/.github/workflows/fortress-test-matrix.yml @@ -181,6 +181,15 @@ jobs: runner-os: ${{ matrix.os }} go-version: ${{ matrix.go-version }} + # -------------------------------------------------------------------- + # Setup mage (required for delegation tests that use mage binary) + # -------------------------------------------------------------------- + - name: 🧙 Setup mage + uses: ./.github/actions/setup-mage + with: + mage-version: ${{ env.MAGE_X_MAGE_VERSION }} + runner-os: ${{ matrix.os }} + # -------------------------------------------------------------------- # Setup Redis service using composite action with caching # --------------------------------------------------------------------