@@ -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/"
0 commit comments