chore: Add pre-commit blocker report and improve Go version management

- Created a comprehensive pre-commit blocker report detailing GolangCI-Lint and TypeScript type check failures, including remediation steps and verification commands.
- Enhanced the golangci-lint pre-commit hook to automatically rebuild the tool if a Go version mismatch is detected.
- Introduced a new script `rebuild-go-tools.sh` to rebuild essential Go development tools, ensuring they are compiled with the current Go version.
- Improved error handling and user feedback in the rebuilding process, providing clear instructions for manual intervention if needed.
- Updated supervisor review report to reflect the successful implementation of Go version management and associated documentation.
This commit is contained in:
GitHub Actions
2026-02-12 23:50:13 +00:00
parent 8a207ad846
commit 54f5ff5db3
11 changed files with 2983 additions and 1399 deletions
@@ -40,6 +40,35 @@ if [[ -z "$GOLANGCI_LINT" ]]; then
exit 1
fi
# Version compatibility check
# Extract Go versions from golangci-lint and system Go
LINT_GO_VERSION=$("$GOLANGCI_LINT" version 2>/dev/null | grep -oP 'go\K[0-9]+\.[0-9]+(?:\.[0-9]+)?' || echo "")
SYSTEM_GO_VERSION=$(go version 2>/dev/null | grep -oP 'go\K[0-9]+\.[0-9]+(?:\.[0-9]+)?' || echo "")
if [[ -n "$LINT_GO_VERSION" && -n "$SYSTEM_GO_VERSION" && "$LINT_GO_VERSION" != "$SYSTEM_GO_VERSION" ]]; then
echo "⚠️ golangci-lint Go version mismatch detected:"
echo " golangci-lint: $LINT_GO_VERSION"
echo " system Go: $SYSTEM_GO_VERSION"
echo ""
echo "🔧 Auto-rebuilding golangci-lint with current Go version..."
if go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest 2>&1; then
echo "✅ golangci-lint rebuilt successfully"
# Re-verify the tool is still accessible
if command -v golangci-lint >/dev/null 2>&1; then
GOLANGCI_LINT="golangci-lint"
else
GOLANGCI_LINT="$HOME/go/bin/golangci-lint"
fi
else
echo "❌ Failed to rebuild golangci-lint"
echo " Please run manually: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
exit 1
fi
echo ""
fi
# Change to backend directory and run golangci-lint
cd "$(dirname "$0")/../../backend" || exit 1
exec "$GOLANGCI_LINT" run --config .golangci-fast.yml ./...
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# Rebuild Go development tools with the current Go version
# This ensures tools like golangci-lint are compiled with the same Go version as the project
set -euo pipefail
echo "🔧 Rebuilding Go development tools..."
echo "Current Go version: $(go version)"
echo ""
# Core development tools (ordered by priority)
declare -A TOOLS=(
["golangci-lint"]="github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
["gopls"]="golang.org/x/tools/gopls@latest"
["govulncheck"]="golang.org/x/vuln/cmd/govulncheck@latest"
["dlv"]="github.com/go-delve/delve/cmd/dlv@latest"
)
FAILED_TOOLS=()
SUCCESSFUL_TOOLS=()
for tool_name in "${!TOOLS[@]}"; do
tool_path="${TOOLS[$tool_name]}"
echo "📦 Installing $tool_name..."
if go install "$tool_path" 2>&1; then
SUCCESSFUL_TOOLS+=("$tool_name")
echo "$tool_name installed successfully"
else
FAILED_TOOLS+=("$tool_name")
echo "❌ Failed to install $tool_name"
fi
echo ""
done
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Tool rebuild complete"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📊 Installed versions:"
echo ""
# Display versions for each tool
if command -v golangci-lint >/dev/null 2>&1; then
echo "golangci-lint:"
golangci-lint version 2>&1 | grep -E 'version|built with' | sed 's/^/ /'
else
echo " golangci-lint: not found in PATH"
fi
echo ""
if command -v gopls >/dev/null 2>&1; then
echo "gopls:"
gopls version 2>&1 | head -1 | sed 's/^/ /'
else
echo " gopls: not found in PATH"
fi
echo ""
if command -v govulncheck >/dev/null 2>&1; then
echo "govulncheck:"
govulncheck -version 2>&1 | sed 's/^/ /'
else
echo " govulncheck: not found in PATH"
fi
echo ""
if command -v dlv >/dev/null 2>&1; then
echo "dlv:"
dlv version 2>&1 | head -1 | sed 's/^/ /'
else
echo " dlv: not found in PATH"
fi
echo ""
# Summary
if [ ${#FAILED_TOOLS[@]} -eq 0 ]; then
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ All tools rebuilt successfully!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit 0
else
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "⚠️ Some tools failed to install:"
for tool in "${FAILED_TOOLS[@]}"; do
echo " - $tool"
done
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit 1
fi