fix: add rateTracker to host report tests and block direct tag pushes

Initialize rateTracker in ApplyHostReport test monitors to prevent nil
pointer panic when CalculateRates is called during host report processing.

Add pre-push hook guard that blocks pushing version tags directly —
releases must go through the create-release.yml workflow.
This commit is contained in:
rcourtman 2026-02-04 16:47:31 +00:00
parent 25285e64bc
commit c9547f226e
2 changed files with 22 additions and 0 deletions

View file

@ -1,2 +1,20 @@
# Block pushing version tags directly — releases must go through the GitHub Actions workflow
# (workflow_dispatch on create-release.yml). Pushing tags manually bypasses the release
# pipeline which builds binaries, Docker images, and validates assets.
while read local_ref local_sha remote_ref remote_sha; do
if echo "$local_ref" | grep -qE "^refs/tags/v[0-9]"; then
echo ""
echo "BLOCKED: Direct push of version tag '${local_ref#refs/tags/}' is not allowed."
echo ""
echo " Releases must be created via the GitHub Actions release workflow:"
echo " gh workflow run create-release.yml -f version=X.Y.Z -f release_notes=\"...\""
echo ""
echo " Pushing tags directly skips the build pipeline and publishes a broken release"
echo " with no binaries, no Docker images, and no checksums."
echo ""
exit 1
fi
done
# TypeScript type-check before push to prevent CI failures
cd frontend-modern && npm run type-check

View file

@ -125,6 +125,7 @@ func TestApplyHostReportAllowsTokenReuseAcrossHosts(t *testing.T) {
alertManager: alerts.NewManager(),
hostTokenBindings: make(map[string]string),
config: &config.Config{},
rateTracker: NewRateTracker(),
}
t.Cleanup(func() { monitor.alertManager.Stop() })
@ -189,6 +190,7 @@ func TestApplyHostReportDisambiguatesCollidingIdentifiersAcrossTokens(t *testing
alertManager: alerts.NewManager(),
hostTokenBindings: make(map[string]string),
config: &config.Config{},
rateTracker: NewRateTracker(),
}
t.Cleanup(func() { monitor.alertManager.Stop() })
@ -780,6 +782,7 @@ func TestApplyHostReport_NilTokenBindingsMap(t *testing.T) {
alertManager: alerts.NewManager(),
hostTokenBindings: nil, // Nil map
config: &config.Config{},
rateTracker: NewRateTracker(),
}
t.Cleanup(func() { monitor.alertManager.Stop() })
@ -813,6 +816,7 @@ func TestApplyHostReport_FallbackIdentifier(t *testing.T) {
alertManager: alerts.NewManager(),
hostTokenBindings: make(map[string]string),
config: &config.Config{},
rateTracker: NewRateTracker(),
}
t.Cleanup(func() { monitor.alertManager.Stop() })