Skip to content

feat: per-PR preview environments — deploy on open, sticky outputs comment, teardown on close #1223

Closed

Description

@lex00

Filed for review. Scope and approach not yet confirmed.

A documented, end-to-end story for short-lived per-PR deployments: open a PR, get an isolated live copy of the stack; close the PR, it is gone.

Finding

chant has every ingredient — CI lexicons (github/gitlab/forgejo) to declare the workflow, build-time parameters to vary a build per environment, ApplyOp to apply, ownership markers for isolation — but nothing assembles them, and no docs page mentions per-PR environments. Searched issues and docs: no existing story.

Want

1. The recipe, as a tutorial

One docs page (guide or tutorial) covering the loop:

2. A composite, if the recipe warrants it

If the workflow shape is stable across CI targets, ship it as a composite in each CI lexicon (working name PreviewEnvironmentWorkflow({ stack, applyOp, teardownOp })) that emits the on-open / on-sync / on-close jobs. Start with the tutorial; promote to composite only when the copy-paste is proven.

3. Dynamic env names

environments is a static list; pr-<n> is unbounded. Decide the contract — either allow a pattern entry ({ pattern: "pr-*" }) or allow --env values outside the list for build/teardown with a warning. Needs a decision, flagging explicitly for review.

Acceptance

  • Tutorial builds in CI like other examples; the emitted workflow passes the CI lexicon's own lint (pinned actions etc.).
  • Runtime proof on one CI target via the existing runtime E2E harness (just gitlab-runtime-e2e or forgejo), against an emulator env.
  • PR comment updates in place across pushes (stable identity), not one comment per push.
  • Explicitly documents cost/limits: per-PR copies are real resources; which resource kinds are too heavy to clone per PR.

Depends on #1221 (naming) and #1222 (teardown).

Activity

  1. added
    documentation
    enhancement
    needs-review
    on Jul 30, 2026
  2. added
    area:ci
    on Aug 23, 2026
  3. lex00 commented on Aug 24, 2026

    @lex00
    ContributorAuthor

    Scope confirmed (build, modified). Verified against current code; two premises moved since filing.

    Already exists, shrinks v1: gitlab ReviewApp and github DeployEnvironment composites carry the deploy/stop job shape; chant build --env + --param exist; and #1396 (PR #1788) made ownership.env resolve from the env build parameter, so per-PR ownership markers already work. The real gaps: dynamic env names (pr-<n>) are rejected by unknownEnvError against the static environments list, there is no teardown verb, and no sticky-comment machinery.

    V1 = docs + example for the GitHub dialect, runtime-proven on the forgejo harness (thin github dialect, locally provable; no act integration). PR open/update → chant build --param env=pr-<n> (names via #1221, marker via #1396) → ApplyOp local executor → sticky PR comment via a scripted gh api step keyed on a marker string (no marketplace action, passes the pinned-actions lints). PR close → #1222 teardown with the long-lived-env guard. The workflow itself is declared in chant and emitted by chant build. Cost/limits section as filed.

    Out: gitlab/forgejo tutorial parity (gitlab users pointed at ReviewApp), a PreviewEnvironmentWorkflow composite (follow-up if the copy-paste proves stable), any dynamic-env machinery here (that contract is decided once, in #1221 — pr-* and #1224's test-*-<nonce> are the same case), component-pipeline integration.

    Blocked on: #1221 (dynamic-env legality + envName()), #1222 (CI-runnable non-interactive teardown, loud-but-zero on empty, refuse-long-lived-env guard).

    Plan: PR A tutorial example + docs page (GitHub dialect, GHA lints clean); PR B forgejo runtime-E2E fixture proving on-open deploy and on-close teardown against an emulator env.

  4. removed
    needs-review
    on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cidocumentationenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions