feat(site): implement preview deployment support #144

Merged
fuzzy merged 1 commit from feat/preview-deployments into main 2026-08-03 10:08:21 +00:00
Owner

What

Add preview deployments for pushes to test/* branches:

  • Ref classification (internal/webhook) — IsBranch/BranchName/IsTag/IsPreviewBranch distinguish branch pushes from tag pushes and match the test/* pattern (#79, #80).
  • Receiver routing (internal/webhook/receiver.go) — test/* branch pushes route to SiteService.PublishPreview when the site has PreviewEnabled; all other pushes (tags, other branches) route to production Publish (#81).
  • SiteService.PublishPreview — deploys the branch by creating the preview Ingress via KubernetesService.CreatePreviewIngress (path-based /preview/<branch> routing on the site host, #82) and records an active Deployment with the branch as the version.
  • KubernetesClient structural interface extended with CreatePreviewIngress (satisfied by the concrete client).

Why

Phase 6 task #83 — lets users preview site changes on test/* branches alongside the production deployment.

Testing

  • go build ./...
  • go vet ./...
  • go test -race ./... — ref classification (4 subtests), receiver routing (preview push, preview-disabled, tag push), PublishPreview (happy path, preview-disabled); full suite passes
  • gofmt -l ./cmd ./internal ./pkg clean
  • golangci-lint run — 0 issues
  • pre-commit hooks all pass

Breaking Changes

None.

Notes

  • Preview content population into the serving volume remains deferred (same as production).
  • Issues #79–#83 were closed via the Forgejo API as part of this task per the workflow.

Closes #79
Closes #80
Closes #81
Closes #82
Closes #83

## What Add preview deployments for pushes to `test/*` branches: - **Ref classification** (`internal/webhook`) — `IsBranch`/`BranchName`/`IsTag`/`IsPreviewBranch` distinguish branch pushes from tag pushes and match the `test/*` pattern (#79, #80). - **Receiver routing** (`internal/webhook/receiver.go`) — `test/*` branch pushes route to `SiteService.PublishPreview` when the site has `PreviewEnabled`; all other pushes (tags, other branches) route to production `Publish` (#81). - **`SiteService.PublishPreview`** — deploys the branch by creating the preview Ingress via `KubernetesService.CreatePreviewIngress` (path-based `/preview/<branch>` routing on the site host, #82) and records an active `Deployment` with the branch as the version. - **`KubernetesClient`** structural interface extended with `CreatePreviewIngress` (satisfied by the concrete client). ## Why Phase 6 task #83 — lets users preview site changes on `test/*` branches alongside the production deployment. ## Testing - [x] `go build ./...` - [x] `go vet ./...` - [x] `go test -race ./...` — ref classification (4 subtests), receiver routing (preview push, preview-disabled, tag push), `PublishPreview` (happy path, preview-disabled); full suite passes - [x] `gofmt -l ./cmd ./internal ./pkg` clean - [x] `golangci-lint run` — 0 issues - [x] pre-commit hooks all pass ## Breaking Changes None. ## Notes - Preview content population into the serving volume remains deferred (same as production). - Issues #79–#83 were closed via the Forgejo API as part of this task per the workflow. Closes #79 Closes #80 Closes #81 Closes #82 Closes #83
feat(site): implement preview deployment support
All checks were successful
Test and Release / lint (pull_request) Successful in 4m19s
Test and Release / test (pull_request) Successful in 23m11s
c6a1e326f9
Add preview deployments for pushes to test/* branches:

- webhook ref classification: IsBranch/BranchName/IsTag/IsPreviewBranch
  distinguish branch pushes from tag pushes and match the test/* pattern
- webhook receiver routes test/* branch pushes to PublishPreview when
  the site has previews enabled, and production Publish otherwise
- SiteService.PublishPreview deploys the branch: creates the preview
  Ingress via KubernetesService.CreatePreviewIngress (path-based
  /preview/<branch> routing on the site host) and records an active
  Deployment with the branch as the version
- KubernetesClient structural interface extended with
  CreatePreviewIngress

Preview content population remains deferred like production. Add tests
for ref classification, receiver routing (preview, disabled, tag), and
PublishPreview (happy path, preview-disabled). Mark task done in
ROADMAP.md.

closes #79
closes #80
closes #81
closes #82
closes #83
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-03 09:45:27 +00:00
the.auditor left a comment

Review Summary

Verified locally on the PR head (c6a1e32): go build, go vet, gofmt, golangci-lint run all clean; full suite passes with -race (ref classification, receiver routing, PublishPreview + existing).

Solid, well-factored implementation. The ref-classification helpers (IsBranch/BranchName/IsTag/IsPreviewBranch) are simple and correct, and the receiver routing cleanly separates test/* branch pushes (→ PublishPreview, silent no-op when the site has previews disabled) from everything else (→ production Publish). PublishPreview correctly guards on PreviewEnabled (defensive, since the receiver pre-checks), and records the branch as the deployment version. The KubernetesClient structural interface extension matches the concrete client's existing CreatePreviewIngress, so the compile-time assertion still holds. Test coverage is good — the receiver-routing tests assert the right service method is called (and the wrong one isn't).

No blocking issues.

Non-blocking observations:

  1. Non-preview branch pushes (e.g. main) still route to production Publish, re-selecting the highest v* tag — pre-existing behavior carried over from #142, still worth filtering to tag refs eventually.
  2. Preview branch deletion / stale-preview cleanup is the next roadmap task (#84/#85) — the deleted flag in Forgejo push payloads isn't parsed yet, so deleted branches leave stale preview ingresses until that lands. Expected, not blocking.
  3. Preview content population into the serving volume remains deferred, consistent with production.

Approving.

## Review Summary Verified locally on the PR head (`c6a1e32`): `go build`, `go vet`, `gofmt`, `golangci-lint run` all clean; full suite passes with `-race` (ref classification, receiver routing, PublishPreview + existing). Solid, well-factored implementation. The ref-classification helpers (`IsBranch`/`BranchName`/`IsTag`/`IsPreviewBranch`) are simple and correct, and the receiver routing cleanly separates `test/*` branch pushes (→ `PublishPreview`, silent no-op when the site has previews disabled) from everything else (→ production `Publish`). `PublishPreview` correctly guards on `PreviewEnabled` (defensive, since the receiver pre-checks), and records the branch as the deployment version. The `KubernetesClient` structural interface extension matches the concrete client's existing `CreatePreviewIngress`, so the compile-time assertion still holds. Test coverage is good — the receiver-routing tests assert the *right* service method is called (and the wrong one isn't). **No blocking issues.** Non-blocking observations: 1. Non-preview branch pushes (e.g. `main`) still route to production `Publish`, re-selecting the highest `v*` tag — pre-existing behavior carried over from #142, still worth filtering to tag refs eventually. 2. Preview branch deletion / stale-preview cleanup is the next roadmap task (#84/#85) — the `deleted` flag in Forgejo push payloads isn't parsed yet, so deleted branches leave stale preview ingresses until that lands. Expected, not blocking. 3. Preview content population into the serving volume remains deferred, consistent with production. Approving.
fuzzy merged commit c6a1e326f9 into main 2026-08-03 10:08:21 +00:00
fuzzy deleted branch feat/preview-deployments 2026-08-03 10:08:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!144
No description provided.