Skip to content

Commit 871ab17

Browse files
authored
sync: update 13 files from source repository (#67)
1 parent 4bd35d9 commit 871ab17

13 files changed

+387
-77
lines changed

.github/.env.base

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,22 @@ GOVULNCHECK_GO_VERSION=1.25.x
4747

4848
# Go sum file location for dependency verification and caching
4949
# Default: go.sum (standard location in repository root)
50-
# Custom examples: lib/go.sum, backend/go.sum, services/api/go.sum
50+
# NOTE: For multi-module monorepos (go.work), set ENABLE_MULTI_MODULE_TESTING=true
51+
# GO_SUM_FILE is still required but will be ignored for caching (uses **/go.sum pattern instead)
5152
GO_SUM_FILE=go.sum
5253

54+
# Multi-module monorepo support
55+
# When true: runs tests from repo root, magex discovers all Go modules and merges coverage
56+
# Cache keys use **/go.sum pattern (no root go.sum required), skips root go.sum validation
57+
# When false: runs tests from GO_MODULE_DIR (derived from GO_SUM_FILE path)
58+
ENABLE_MULTI_MODULE_TESTING=false
59+
5360
# ================================================================================================
5461
# 🖥️ RUNNER CONFIGURATION
5562
# ================================================================================================
5663

64+
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners
65+
5766
# Primary runner OS for most CI jobs
5867
# Options: ubuntu-24.04, ubuntu-22.04, macos-15
5968
# Note: macOS runners are 10x more expensive than Linux
@@ -147,7 +156,7 @@ GO_COVERAGE_PROVIDER=internal
147156
CODECOV_TOKEN_REQUIRED=false
148157

149158
# Go Coverage Tool Version
150-
GO_COVERAGE_VERSION=v1.1.13 # https://github.com/mrz1836/go-coverage/releases
159+
GO_COVERAGE_VERSION=v1.1.15 # https://github.com/mrz1836/go-coverage/releases
151160
GO_COVERAGE_USE_LOCAL=false # Use local version for development
152161

153162
# Core Coverage Settings
@@ -232,7 +241,7 @@ REDIS_CACHE_FORCE_PULL=false # Force pull Redis images even when cache
232241
# 🪄 MAGE-X CONFIGURATION
233242
# ================================================================================================
234243

235-
MAGE_X_VERSION=v1.8.0 # https://github.com/mrz1836/mage-x/releases
244+
MAGE_X_VERSION=v1.8.7 # https://github.com/mrz1836/mage-x/releases
236245
MAGE_X_USE_LOCAL=false # Use local version for development
237246
MAGE_X_AUTO_DISCOVER_BUILD_TAGS=true # Enable auto-discovery of build tags
238247
MAGE_X_AUTO_DISCOVER_BUILD_TAGS_EXCLUDE=race,custom # Comma-separated list of tags to exclude
@@ -250,6 +259,9 @@ MAGE_X_STATICCHECK_VERSION=2025.1.1 # https://github.c
250259
MAGE_X_SWAG_VERSION=v1.16.6 # https://github.com/swaggo/swag/releases
251260
MAGE_X_YAMLFMT_VERSION=v0.20.0 # https://github.com/google/yamlfmt/releases
252261

262+
# Exclude magefiles from prebuild - they require 'mage' build tag and fail without it
263+
# MAGE_X_BUILD_EXCLUDE_PATTERN=magefiles
264+
253265
# Runtime variables (set by setup-goreleaser action):
254266
# MAGE_X_GORELEASER_PATH - Path to installed goreleaser binary
255267
# MAGE_X_GORELEASER_INSTALLED - Set to 'true' when goreleaser is available
@@ -269,6 +281,7 @@ MAGE_X_YAMLFMT_VERSION=v0.20.0 # https://github.c
269281
# MAGE_X_DOWNLOAD_TIMEOUT=5000
270282
# MAGE_X_DOWNLOAD_USER_AGENT=MAGE-X-Agent
271283
# MAGE_X_PARALLEL=3
284+
# MAGE_X_TEST_EXCLUDE_MODULES=magefiles # Comma-separated module names to exclude from tests/coverage (default: magefiles)
272285
# MAGE_X_TEST_RACE=false
273286
# MAGE_X_VERBOSE=true
274287

@@ -293,7 +306,7 @@ NANCY_EXCLUDES=CVE-2024-38513,CVE-2023-45142
293306
# Security Tools
294307
GITLEAKS_VERSION=8.29.1 # https://github.com/gitleaks/gitleaks/releases
295308
GOVULNCHECK_VERSION=v1.1.4 # https://pkg.go.dev/golang.org/x/vuln
296-
NANCY_VERSION=v1.0.51 # https://github.com/sonatype-nexus-community/nancy/releases
309+
NANCY_VERSION=v1.0.52 # https://github.com/sonatype-nexus-community/nancy/releases
297310

298311
# ================================================================================================
299312
# 🪝 PRE-COMMIT SYSTEM CONFIGURATION (go-pre-commit)

.github/actions/setup-go-with-cache/action.yml

Lines changed: 118 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ inputs:
4141
description: "Secondary Go version for toolchain comparison"
4242
required: true
4343
go-sum-file:
44-
description: "Path to go.sum file for cache key generation"
44+
description: "Path to go.sum file for cache key generation (single module mode only; ignored when enable-multi-module is true)"
4545
required: true
46+
enable-multi-module:
47+
description: "Enable multi-module mode - uses pattern **/go.sum to hash all go.sum files for cache keys, skips root go.sum validation"
48+
required: false
49+
default: "false"
4650

4751
outputs:
4852
go-version-actual:
@@ -102,6 +106,7 @@ runs:
102106
# Validate go.sum exists for cache key generation
103107
# --------------------------------------------------------------------
104108
- name: 🔍 Validate go.sum exists
109+
if: ${{ inputs.enable-multi-module != 'true' }}
105110
shell: bash
106111
run: |
107112
GO_SUM_FILE="${{ inputs.go-sum-file }}"
@@ -131,35 +136,75 @@ runs:
131136
echo "📋 Input Values:"
132137
echo " matrix-os: '${{ inputs.matrix-os }}'"
133138
echo " go-sum-file: '${{ inputs.go-sum-file }}'"
139+
echo " enable-multi-module: '${{ inputs.enable-multi-module }}'"
134140
135-
# Verify go.sum file details
136-
GO_SUM_FILE="${{ inputs.go-sum-file }}"
137-
if [ -f "$GO_SUM_FILE" ]; then
138-
echo ""
139-
echo "📄 Go.sum File Analysis:"
140-
echo " Path: $GO_SUM_FILE"
141-
echo " Size: $(wc -c < "$GO_SUM_FILE") bytes"
142-
echo " Lines: $(wc -l < "$GO_SUM_FILE") lines"
143-
echo " SHA256: $(sha256sum "$GO_SUM_FILE" | cut -d' ' -f1)"
141+
if [ "${{ inputs.enable-multi-module }}" == "true" ]; then
142+
# Multi-module mode - show all go.sum files
144143
echo ""
145-
echo "🔍 First 5 lines of go.sum:"
146-
head -5 "$GO_SUM_FILE" | sed 's/^/ /'
144+
echo "📦 Multi-module mode enabled"
145+
echo "🔍 Found go.sum files:"
146+
find . -name "go.sum" -type f | while read file; do
147+
echo " - $file ($(wc -l < "$file") lines, $(wc -c < "$file") bytes)"
148+
done
149+
147150
echo ""
148-
echo "🔍 Last 3 lines of go.sum:"
149-
tail -3 "$GO_SUM_FILE" | sed 's/^/ /'
151+
echo "🔑 Expected Module Cache Key Pattern:"
152+
echo " Pattern: ${{ inputs.matrix-os }}-gomod-multi-[hash-of-all-go.sum]"
153+
echo " Actual hash: ${{ hashFiles('**/go.sum') }}"
154+
echo " Complete key: ${{ inputs.matrix-os }}-gomod-multi-${{ hashFiles('**/go.sum') }}"
150155
else
151-
echo "❌ ERROR: go.sum file not found at: $GO_SUM_FILE"
156+
# Single module mode - verify go.sum file
157+
GO_SUM_FILE="${{ inputs.go-sum-file }}"
158+
if [ -f "$GO_SUM_FILE" ]; then
159+
echo ""
160+
echo "📄 Go.sum File Analysis:"
161+
echo " Path: $GO_SUM_FILE"
162+
echo " Size: $(wc -c < "$GO_SUM_FILE") bytes"
163+
echo " Lines: $(wc -l < "$GO_SUM_FILE") lines"
164+
echo " SHA256: $(sha256sum "$GO_SUM_FILE" | cut -d' ' -f1)"
165+
echo ""
166+
echo "🔍 First 5 lines of go.sum:"
167+
head -5 "$GO_SUM_FILE" | sed 's/^/ /'
168+
echo ""
169+
echo "🔍 Last 3 lines of go.sum:"
170+
tail -3 "$GO_SUM_FILE" | sed 's/^/ /'
171+
else
172+
echo "❌ ERROR: go.sum file not found at: $GO_SUM_FILE"
173+
fi
174+
175+
# Show expected cache key pattern
176+
echo ""
177+
echo "🔑 Expected Module Cache Key Pattern:"
178+
echo " Pattern: ${{ inputs.matrix-os }}-gomod-[hash-of-go.sum]"
179+
echo " Actual hash: ${{ hashFiles(inputs.go-sum-file) }}"
180+
echo " Complete key: ${{ inputs.matrix-os }}-gomod-${{ hashFiles(inputs.go-sum-file) }}"
152181
fi
153182
154-
# Show expected cache key pattern
155-
echo ""
156-
echo "🔑 Expected Module Cache Key Pattern:"
157-
echo " Pattern: ${{ inputs.matrix-os }}-gomod-[hash-of-go.sum]"
158-
echo " Actual hash: ${{ hashFiles(inputs.go-sum-file) }}"
159-
echo " Complete key: ${{ inputs.matrix-os }}-gomod-${{ hashFiles(inputs.go-sum-file) }}"
160183
echo ""
161184
echo "============================================================"
162185
186+
# --------------------------------------------------------------------
187+
# Compute cache keys based on multi-module mode
188+
# --------------------------------------------------------------------
189+
- name: 🔑 Compute cache keys
190+
id: cache-keys
191+
shell: bash
192+
run: |
193+
if [ "${{ inputs.enable-multi-module }}" == "true" ]; then
194+
echo "📦 Multi-module mode enabled - using hash of all go.sum files"
195+
HASH="${{ hashFiles('**/go.sum') }}"
196+
echo "module-key=${{ inputs.matrix-os }}-gomod-multi-${HASH}" >> $GITHUB_OUTPUT
197+
echo "build-key=${{ inputs.matrix-os }}-gobuild-multi-${{ inputs.go-version }}-${HASH}" >> $GITHUB_OUTPUT
198+
echo "mode=multi" >> $GITHUB_OUTPUT
199+
else
200+
echo "📁 Single module mode - using hash of ${{ inputs.go-sum-file }}"
201+
HASH="${{ hashFiles(inputs.go-sum-file) }}"
202+
echo "module-key=${{ inputs.matrix-os }}-gomod-${HASH}" >> $GITHUB_OUTPUT
203+
echo "build-key=${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-${HASH}" >> $GITHUB_OUTPUT
204+
echo "mode=single" >> $GITHUB_OUTPUT
205+
fi
206+
echo "🔑 Cache keys computed successfully"
207+
163208
# --------------------------------------------------------------------
164209
# Restore Go module cache (shared across versions)
165210
# --------------------------------------------------------------------
@@ -168,7 +213,7 @@ runs:
168213
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
169214
with:
170215
path: ~/go/pkg/mod
171-
key: ${{ inputs.matrix-os }}-gomod-${{ hashFiles(inputs.go-sum-file) }}
216+
key: ${{ steps.cache-keys.outputs.module-key }}
172217

173218
# --------------------------------------------------------------------
174219
# DEBUG: Build cache key components
@@ -185,18 +230,27 @@ runs:
185230
echo " matrix-os: '${{ inputs.matrix-os }}'"
186231
echo " go-version: '${{ inputs.go-version }}'"
187232
echo " go-sum-file: '${{ inputs.go-sum-file }}'"
233+
echo " enable-multi-module: '${{ inputs.enable-multi-module }}'"
188234
189-
# Verify go.sum file details (for build cache key)
190-
GO_SUM_FILE="${{ inputs.go-sum-file }}"
191-
if [ -f "$GO_SUM_FILE" ]; then
235+
if [ "${{ inputs.enable-multi-module }}" == "true" ]; then
236+
# Multi-module mode - show summary of all go.sum files
192237
echo ""
193-
echo "📄 Go.sum File Analysis (for build cache):"
194-
echo " Path: $GO_SUM_FILE"
195-
echo " Size: $(wc -c < "$GO_SUM_FILE") bytes"
196-
echo " SHA256: $(sha256sum "$GO_SUM_FILE" | cut -d' ' -f1)"
197-
echo " Last Modified: $(stat -c %y "$GO_SUM_FILE" 2>/dev/null || stat -f %Sm "$GO_SUM_FILE" 2>/dev/null || echo 'Unknown')"
238+
echo "📦 Multi-module mode enabled"
239+
echo "🔍 Go.sum files count: $(find . -name "go.sum" -type f | wc -l)"
240+
echo "🔑 Cache hash: ${{ hashFiles('**/go.sum') }}"
198241
else
199-
echo "❌ ERROR: go.sum file not found at: $GO_SUM_FILE"
242+
# Single module mode - verify go.sum file details
243+
GO_SUM_FILE="${{ inputs.go-sum-file }}"
244+
if [ -f "$GO_SUM_FILE" ]; then
245+
echo ""
246+
echo "📄 Go.sum File Analysis (for build cache):"
247+
echo " Path: $GO_SUM_FILE"
248+
echo " Size: $(wc -c < "$GO_SUM_FILE") bytes"
249+
echo " SHA256: $(sha256sum "$GO_SUM_FILE" | cut -d' ' -f1)"
250+
echo " Last Modified: $(stat -c %y "$GO_SUM_FILE" 2>/dev/null || stat -f %Sm "$GO_SUM_FILE" 2>/dev/null || echo 'Unknown')"
251+
else
252+
echo "❌ ERROR: go.sum file not found at: $GO_SUM_FILE"
253+
fi
200254
fi
201255
202256
# Show cache paths that will be used
@@ -210,10 +264,17 @@ runs:
210264
211265
# Show expected cache key pattern
212266
echo ""
213-
echo "🔑 Expected Build Cache Key Pattern:"
214-
echo " Pattern: ${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-[hash-of-go.sum]"
215-
echo " Actual hash: ${{ hashFiles(inputs.go-sum-file) }}"
216-
echo " Complete key: ${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-${{ hashFiles(inputs.go-sum-file) }}"
267+
if [ "${{ inputs.enable-multi-module }}" == "true" ]; then
268+
echo "🔑 Expected Build Cache Key Pattern:"
269+
echo " Pattern: ${{ inputs.matrix-os }}-gobuild-multi-${{ inputs.go-version }}-[hash-of-all-go.sum]"
270+
echo " Actual hash: ${{ hashFiles('**/go.sum') }}"
271+
echo " Complete key: ${{ inputs.matrix-os }}-gobuild-multi-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }}"
272+
else
273+
echo "🔑 Expected Build Cache Key Pattern:"
274+
echo " Pattern: ${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-[hash-of-go.sum]"
275+
echo " Actual hash: ${{ hashFiles(inputs.go-sum-file) }}"
276+
echo " Complete key: ${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-${{ hashFiles(inputs.go-sum-file) }}"
277+
fi
217278
echo ""
218279
echo "============================================================"
219280
@@ -227,7 +288,7 @@ runs:
227288
path: |
228289
~/.cache/go-build
229290
~/.cache/go-build/test
230-
key: ${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-${{ hashFiles(inputs.go-sum-file) }}
291+
key: ${{ steps.cache-keys.outputs.build-key }}
231292

232293
# --------------------------------------------------------------------
233294
# DEBUG: Cache restoration summary
@@ -247,17 +308,27 @@ runs:
247308
# Show the actual keys that were used
248309
echo ""
249310
echo "🔑 Actual Cache Keys Used:"
250-
MODULE_KEY="${{ inputs.matrix-os }}-gomod-${{ hashFiles(inputs.go-sum-file) }}"
251-
BUILD_KEY="${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-${{ hashFiles(inputs.go-sum-file) }}"
252-
echo " Module: $MODULE_KEY"
253-
echo " Build: $BUILD_KEY"
254-
255-
# Break down the keys for analysis
256-
echo ""
257-
echo "🔍 Key Component Analysis:"
258-
echo " OS component: '${{ inputs.matrix-os }}'"
259-
echo " Go version component: '${{ inputs.go-version }}'"
260-
echo " Go.sum hash component: '${{ hashFiles(inputs.go-sum-file) }}'"
311+
if [ "${{ inputs.enable-multi-module }}" == "true" ]; then
312+
MODULE_KEY="${{ inputs.matrix-os }}-gomod-multi-${{ hashFiles('**/go.sum') }}"
313+
BUILD_KEY="${{ inputs.matrix-os }}-gobuild-multi-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }}"
314+
echo " Module: $MODULE_KEY"
315+
echo " Build: $BUILD_KEY"
316+
echo ""
317+
echo "🔍 Key Component Analysis (Multi-module mode):"
318+
echo " OS component: '${{ inputs.matrix-os }}'"
319+
echo " Go version component: '${{ inputs.go-version }}'"
320+
echo " Go.sum hash component (all files): '${{ hashFiles('**/go.sum') }}'"
321+
else
322+
MODULE_KEY="${{ inputs.matrix-os }}-gomod-${{ hashFiles(inputs.go-sum-file) }}"
323+
BUILD_KEY="${{ inputs.matrix-os }}-gobuild-${{ inputs.go-version }}-${{ hashFiles(inputs.go-sum-file) }}"
324+
echo " Module: $MODULE_KEY"
325+
echo " Build: $BUILD_KEY"
326+
echo ""
327+
echo "🔍 Key Component Analysis (Single module mode):"
328+
echo " OS component: '${{ inputs.matrix-os }}'"
329+
echo " Go version component: '${{ inputs.go-version }}'"
330+
echo " Go.sum hash component: '${{ hashFiles(inputs.go-sum-file) }}'"
331+
fi
261332
262333
# Cache effectiveness summary
263334
echo ""

0 commit comments

Comments
 (0)