Skip to content

Commit 0e9a432

Browse files
authored
sync: update 5 files from source repository (#51)
1 parent edf5197 commit 0e9a432

File tree

5 files changed

+184
-11
lines changed

5 files changed

+184
-11
lines changed

.github/.env.base

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ NANCY_EXCLUDES=CVE-2024-38513,CVE-2023-45142
291291
# Github Secret(s): OSSI_USERNAME and OSSI_TOKEN
292292

293293
# Security Tools
294-
GITLEAKS_VERSION=8.29.0 # https://github.com/gitleaks/gitleaks/releases
294+
GITLEAKS_VERSION=8.29.1 # https://github.com/gitleaks/gitleaks/releases
295295
GOVULNCHECK_VERSION=v1.1.4 # https://pkg.go.dev/golang.org/x/vuln
296296
NANCY_VERSION=v1.0.51 # https://github.com/sonatype-nexus-community/nancy/releases
297297

@@ -300,7 +300,7 @@ NANCY_VERSION=v1.0.51 # https://github.com/sonatype-nexus-commu
300300
# ================================================================================================
301301

302302
# Pre-Commit System
303-
GO_PRE_COMMIT_VERSION=v1.4.2 # https://github.com/mrz1836/go-pre-commit/releases
303+
GO_PRE_COMMIT_VERSION=v1.4.3 # https://github.com/mrz1836/go-pre-commit/releases
304304
GO_PRE_COMMIT_USE_LOCAL=false # Use local version for development
305305

306306
# System Settings
@@ -312,6 +312,7 @@ GO_PRE_COMMIT_PARALLEL_WORKERS=2
312312
GO_PRE_COMMIT_LOG_LEVEL=debug
313313
GO_PRE_COMMIT_MAX_FILE_SIZE_MB=10
314314
GO_PRE_COMMIT_MAX_FILES_OPEN=100
315+
GO_PRE_COMMIT_DEBUG=false # Enable verbose debug output for tool caching and locations
315316

316317
# File Detection Strategy for CI
317318
# true = Check all repository files (comprehensive but slower)
@@ -322,7 +323,7 @@ GO_PRE_COMMIT_ALL_FILES=true
322323
GO_PRE_COMMIT_GOLANGCI_LINT_VERSION=v2.6.2 # https://github.com/golangci/golangci-lint/releases
323324
GO_PRE_COMMIT_FUMPT_VERSION=v0.9.2 # https://github.com/mvdan/gofumpt/releases
324325
GO_PRE_COMMIT_GOIMPORTS_VERSION=latest # https://github.com/golang/tools
325-
GO_PRE_COMMIT_GITLEAKS_VERSION=v8.29.0 # https://github.com/gitleaks/gitleaks/releases
326+
GO_PRE_COMMIT_GITLEAKS_VERSION=v8.29.1 # https://github.com/gitleaks/gitleaks/releases
326327

327328
# Build tags for golangci-lint and other tools
328329
GO_PRE_COMMIT_BUILD_TAGS=

.github/workflows/auto-merge-on-approval.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
runs-on: ubuntu-latest
8989
permissions:
9090
pull-requests: write # Required: Update PR status and enable auto-merge
91+
issues: write # Required: Add labels and create comments
9192
outputs:
9293
action-taken: ${{ steps.process.outputs.action }}
9394
pr-number: ${{ github.event.pull_request.number }}

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

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,48 @@ jobs:
273273
echo "version=${{ env.MAGE_X_GOLANGCI_LINT_VERSION }}" >> $GITHUB_OUTPUT
274274
275275
# --------------------------------------------------------------------
276-
# Restore Cache golangci-lint
276+
# Cache golangci-lint binary (prevents re-downloading)
277+
# --------------------------------------------------------------------
278+
- name: 💾 Restore golangci-lint binary cache
279+
id: cache-golangci-lint-binary
280+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
281+
with:
282+
path: ~/.cache/golangci-lint-bin
283+
key: ${{ inputs.primary-runner }}-golangci-lint-binary-${{ env.MAGE_X_GOLANGCI_LINT_VERSION }}
284+
285+
# --------------------------------------------------------------------
286+
# Install cached golangci-lint binary to GOPATH/bin
287+
# --------------------------------------------------------------------
288+
- name: 📦 Install cached golangci-lint binary
289+
if: steps.cache-golangci-lint-binary.outputs.cache-hit == 'true'
290+
run: |
291+
echo "📦 Restoring cached golangci-lint binary..."
292+
GOPATH_BIN="$(go env GOPATH)/bin"
293+
mkdir -p "$GOPATH_BIN"
294+
295+
if [[ -f ~/.cache/golangci-lint-bin/golangci-lint ]]; then
296+
cp ~/.cache/golangci-lint-bin/golangci-lint "$GOPATH_BIN/"
297+
chmod +x "$GOPATH_BIN/golangci-lint"
298+
echo "✅ Cached golangci-lint binary installed to $GOPATH_BIN"
299+
echo "📍 Version: $(golangci-lint --version | head -n1 || echo 'version check failed')"
300+
else
301+
echo "⚠️ Cache hit but binary not found, will install via MAGE-X"
302+
fi
303+
304+
# --------------------------------------------------------------------
305+
# Cache golangci-lint build cache (prevents re-compiling)
306+
# --------------------------------------------------------------------
307+
- name: 💾 Cache golangci-lint build cache
308+
id: cache-golangci-lint-build
309+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
310+
with:
311+
path: ~/.cache/go-build
312+
key: ${{ inputs.primary-runner }}-go-build-golangci-${{ env.MAGE_X_GOLANGCI_LINT_VERSION }}-${{ hashFiles('**/*.go') }}
313+
restore-keys: |
314+
${{ inputs.primary-runner }}-go-build-golangci-${{ env.MAGE_X_GOLANGCI_LINT_VERSION }}-
315+
316+
# --------------------------------------------------------------------
317+
# Cache golangci-lint analysis results
277318
# --------------------------------------------------------------------
278319
- name: 💾 Cache golangci-lint analysis
279320
id: cache-golangci-lint
@@ -313,6 +354,24 @@ jobs:
313354
314355
echo "✅ Code linting completed successfully"
315356
357+
# --------------------------------------------------------------------
358+
# Save golangci-lint binary to cache (on cache miss)
359+
# --------------------------------------------------------------------
360+
- name: 💾 Save golangci-lint binary to cache
361+
if: steps.cache-golangci-lint-binary.outputs.cache-hit != 'true'
362+
run: |
363+
echo "💾 Caching golangci-lint binary for future runs..."
364+
GOPATH_BIN="$(go env GOPATH)/bin"
365+
mkdir -p ~/.cache/golangci-lint-bin
366+
367+
if [[ -f "$GOPATH_BIN/golangci-lint" ]]; then
368+
cp "$GOPATH_BIN/golangci-lint" ~/.cache/golangci-lint-bin/
369+
echo "✅ golangci-lint binary cached"
370+
echo "📊 Binary size: $(du -h "$GOPATH_BIN/golangci-lint" | cut -f1)"
371+
else
372+
echo "⚠️ golangci-lint binary not found at $GOPATH_BIN, cannot cache"
373+
fi
374+
316375
# --------------------------------------------------------------------
317376
# Summary of golangci-lint results
318377
# --------------------------------------------------------------------
@@ -324,7 +383,8 @@ jobs:
324383
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
325384
echo "| **Configuration** | Custom ruleset via .golangci.json |" >> $GITHUB_STEP_SUMMARY
326385
echo "| **Version** | ${{ steps.golangci-lint-version.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
327-
echo "| **Cache** | 💾 Analysis cache enabled |" >> $GITHUB_STEP_SUMMARY
386+
echo "| **Binary Cache** | ${{ steps.cache-golangci-lint-binary.outputs.cache-hit == 'true' && '💚 Cache Hit' || '📦 Downloaded & Cached' }} |" >> $GITHUB_STEP_SUMMARY
387+
echo "| **Analysis Cache** | 💾 Enabled |" >> $GITHUB_STEP_SUMMARY
328388
echo "| **Result** | ✅ All checks passed |" >> $GITHUB_STEP_SUMMARY
329389
echo "" >> $GITHUB_STEP_SUMMARY
330390
echo "🎯 **Code quality standards met - no linting issues found.**" >> $GITHUB_STEP_SUMMARY

.github/workflows/fortress-pre-commit.yml

Lines changed: 116 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ jobs:
131131

132132
# --------------------------------------------------------------------
133133
# Restore (and later save) a compact cache for go-pre-commit tools
134-
# (golangci-lint, gofumpt) to avoid reinstalling on every run
134+
# Primary: gitleaks (installed as binary by go-pre-commit)
135+
# Note: golangci-lint, gofumpt, goimports are managed by MAGE-X/other workflows
136+
# Cache key includes all versions to invalidate when any tool version changes
135137
# --------------------------------------------------------------------
136138
- name: 💾 Restore go-pre-commit tools cache
137139
id: go-pre-commit-tools-cache
@@ -157,12 +159,13 @@ jobs:
157159
if [[ -f "$GO_PRE_COMMIT_BIN" ]]; then
158160
echo "✅ Using cached go-pre-commit binary"
159161
cp "$GO_PRE_COMMIT_BIN" "$GOPATH_BIN/"
162+
chmod +x "$GOPATH_BIN/go-pre-commit"
160163
fi
161164
162165
# If we restored tools cache, copy them to GOPATH/bin
163166
if [[ -d "$TOOLS_DIR" ]]; then
164167
echo "✅ Using cached go-pre-commit tools"
165-
for tool in golangci-lint gofumpt; do
168+
for tool in golangci-lint gofumpt gitleaks goimports; do
166169
if [[ -f "$TOOLS_DIR/$tool" ]]; then
167170
echo " • Restoring cached $tool"
168171
cp "$TOOLS_DIR/$tool" "$GOPATH_BIN/"
@@ -535,6 +538,53 @@ jobs:
535538
echo "files_found=false" >> $GITHUB_OUTPUT
536539
fi
537540
541+
# --------------------------------------------------------------------
542+
# Debug: Show tool locations before go-pre-commit runs
543+
# Only runs when GO_PRE_COMMIT_DEBUG=true
544+
# --------------------------------------------------------------------
545+
- name: 🔍 Debug tool locations (before execution)
546+
if: steps.install-pre-commit.outputs.install_success == 'true' || steps.install-pre-commit-cached.outputs.install_success == 'true'
547+
run: |
548+
# Skip debug output unless explicitly enabled
549+
if [[ "${{ env.GO_PRE_COMMIT_DEBUG }}" != "true" ]]; then
550+
echo "🔍 Debug mode disabled (set GO_PRE_COMMIT_DEBUG=true to enable)"
551+
exit 0
552+
fi
553+
554+
echo "🔍 Checking tool locations BEFORE go-pre-commit execution..."
555+
echo "============================================================"
556+
GOPATH_BIN="$(go env GOPATH)/bin"
557+
echo ""
558+
echo "📂 GOPATH/bin contents ($GOPATH_BIN):"
559+
if [[ -d "$GOPATH_BIN" ]]; then
560+
for tool in golangci-lint gofumpt gitleaks goimports go-pre-commit; do
561+
if [[ -f "$GOPATH_BIN/$tool" ]]; then
562+
SIZE=$(du -h "$GOPATH_BIN/$tool" 2>/dev/null | cut -f1)
563+
echo " ✅ $tool: $SIZE"
564+
else
565+
echo " ❌ $tool: NOT FOUND"
566+
fi
567+
done
568+
else
569+
echo " ❌ Directory does not exist"
570+
fi
571+
echo ""
572+
echo "📂 ~/.cache/go-pre-commit contents:"
573+
if [[ -d "$HOME/.cache/go-pre-commit" ]]; then
574+
echo " Directory exists"
575+
find "$HOME/.cache/go-pre-commit" -type f -name "golangci-lint" -o -name "gofumpt" -o -name "gitleaks" -o -name "goimports" 2>/dev/null || echo " No tools found"
576+
else
577+
echo " ❌ Directory does not exist"
578+
fi
579+
echo ""
580+
echo "📂 ~/.cache/go-pre-commit-tools contents:"
581+
if [[ -d "$HOME/.cache/go-pre-commit-tools" ]]; then
582+
ls -lah "$HOME/.cache/go-pre-commit-tools" 2>/dev/null || echo " Empty"
583+
else
584+
echo " ❌ Directory does not exist"
585+
fi
586+
echo "============================================================"
587+
538588
# --------------------------------------------------------------------
539589
# Run pre-commit checks
540590
# --------------------------------------------------------------------
@@ -644,12 +694,73 @@ jobs:
644694
echo ""
645695
echo "✅ All pre-commit checks passed successfully"
646696
697+
# --------------------------------------------------------------------
698+
# Debug: Show tool locations after go-pre-commit runs
699+
# Only runs when GO_PRE_COMMIT_DEBUG=true
700+
# --------------------------------------------------------------------
701+
- name: 🔍 Debug tool locations (after execution)
702+
if: always() && (steps.install-pre-commit.outputs.install_success == 'true' || steps.install-pre-commit-cached.outputs.install_success == 'true')
703+
run: |
704+
# Skip debug output unless explicitly enabled
705+
if [[ "${{ env.GO_PRE_COMMIT_DEBUG }}" != "true" ]]; then
706+
echo "🔍 Debug mode disabled (set GO_PRE_COMMIT_DEBUG=true to enable)"
707+
exit 0
708+
fi
709+
710+
echo "🔍 Checking tool locations AFTER go-pre-commit execution..."
711+
echo "==========================================================="
712+
GOPATH_BIN="$(go env GOPATH)/bin"
713+
echo ""
714+
echo "📂 GOPATH/bin contents ($GOPATH_BIN):"
715+
if [[ -d "$GOPATH_BIN" ]]; then
716+
for tool in golangci-lint gofumpt gitleaks goimports go-pre-commit; do
717+
if [[ -f "$GOPATH_BIN/$tool" ]]; then
718+
SIZE=$(du -h "$GOPATH_BIN/$tool" 2>/dev/null | cut -f1)
719+
VERSION=$("$GOPATH_BIN/$tool" --version 2>&1 | head -1 || echo "unknown")
720+
echo " ✅ $tool: $SIZE - $VERSION"
721+
else
722+
echo " ❌ $tool: NOT FOUND"
723+
fi
724+
done
725+
else
726+
echo " ❌ Directory does not exist"
727+
fi
728+
echo ""
729+
echo "📂 ~/.cache/go-pre-commit contents:"
730+
if [[ -d "$HOME/.cache/go-pre-commit" ]]; then
731+
echo " 📊 Directory exists - checking for tools:"
732+
find "$HOME/.cache/go-pre-commit" -type f \( -name "golangci-lint" -o -name "gofumpt" -o -name "gitleaks" -o -name "goimports" \) -exec ls -lh {} \; 2>/dev/null || echo " No tools found"
733+
echo " 📊 Directory size: $(du -sh "$HOME/.cache/go-pre-commit" 2>/dev/null | cut -f1)"
734+
else
735+
echo " ❌ Directory does not exist"
736+
fi
737+
echo ""
738+
echo "📂 ~/.cache/go-pre-commit-tools contents:"
739+
if [[ -d "$HOME/.cache/go-pre-commit-tools" ]]; then
740+
echo " 📊 Directory exists:"
741+
ls -lah "$HOME/.cache/go-pre-commit-tools" 2>/dev/null || echo " Empty"
742+
echo " 📊 Directory size: $(du -sh "$HOME/.cache/go-pre-commit-tools" 2>/dev/null | cut -f1)"
743+
else
744+
echo " ❌ Directory does not exist"
745+
fi
746+
echo ""
747+
echo "📂 Searching entire home directory for tool binaries:"
748+
echo " (This may take a moment...)"
749+
for tool in golangci-lint gofumpt gitleaks goimports; do
750+
echo " 🔍 Searching for $tool:"
751+
find "$HOME" -type f -name "$tool" 2>/dev/null | head -5 | sed 's/^/ /' || echo " Not found"
752+
done
753+
echo "==========================================================="
754+
647755
# --------------------------------------------------------------------
648756
# Cache tools that were installed during pre-commit execution
649-
# This step ensures tools like golangci-lint and gofumpt are cached for future runs
757+
# Primary tool: gitleaks (installed as binary by go-pre-commit)
758+
# Note: golangci-lint, gofumpt, goimports are not installed as binaries
759+
# (managed by MAGE-X or invoked via go run by go-pre-commit)
760+
# Runs on every successful execution to ensure cache is always complete and up-to-date
650761
# --------------------------------------------------------------------
651762
- name: 💾 Cache go-pre-commit tools after installation
652-
if: steps.go-pre-commit-tools-cache.outputs.cache-hit != 'true' && (steps.install-pre-commit.outputs.install_success == 'true' || steps.install-pre-commit-cached.outputs.install_success == 'true')
763+
if: steps.install-pre-commit.outputs.install_success == 'true' || steps.install-pre-commit-cached.outputs.install_success == 'true'
653764
run: |
654765
set -euo pipefail # Enable strict error handling
655766
echo "💾 Caching go-pre-commit tools..."
@@ -660,7 +771,7 @@ jobs:
660771
mkdir -p "$TOOLS_DIR"
661772
662773
# Cache tools that may have been installed by go-pre-commit
663-
for tool in golangci-lint gofumpt; do
774+
for tool in golangci-lint gofumpt gitleaks goimports; do
664775
if [[ -f "$GOPATH_BIN/$tool" ]]; then
665776
echo " • Caching $tool"
666777
cp "$GOPATH_BIN/$tool" "$TOOLS_DIR/"

.github/workflows/fortress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ------------------------------------------------------------------------------------
22
# 🏰 GoFortress - Enterprise-grade CI/CD fortress for Go applications
33
#
4-
# Version: 1.1.0 | Released: 2025-09-15
4+
# Version: 1.2.0 | Released: 2025-11-20
55
#
66
# Built Strong. Tested Harder.
77
#

0 commit comments

Comments
 (0)