diff --git a/docs/cli/github.md b/docs/cli/github.md index 258506037e..9173d15a8d 100644 --- a/docs/cli/github.md +++ b/docs/cli/github.md @@ -30,21 +30,34 @@ fullsend github setup \ The values passed to `--inference-gateway-*` and `--openai-*` come from the gateway operator and the OpenAI organization admin; see [Using an inference gateway](../guides/user/inference-gateway.md) and [OpenAI Workload Identity](../guides/infrastructure/openai-workload-identity.md). -**Re-running per-repo setup** (for example after a fullsend upgrade) refreshes the managed -workflow files but never rewrites an existing `.fullsend/config.yaml` on its own: `agents:` entries and -their per-agent settings, allowlists and hand-written comments stay as they are, the runtime prompt is skipped, -and the setup PR reports the runtime the file already selects. Passing a flag that targets a -config key — `--runtime`, `--agents`, `--mint-url`, `--inference-*` — changes that key on the -existing file and keeps the rest (the file is re-serialized, so comments are not preserved in -that case). `--config` rewrites `config.base.yaml` from the preset (byte-for-byte) and keeps -the existing overlay unless a persistent setup flag is also passed, in which case that flag is -written into the overlay. Persistent setup flags may be combined with `--config`; they override -the corresponding preset values. When an explicitly passed persistent flag equals the value the -overlay would otherwise inherit from `config.base.yaml` or a compiled default, setup still writes -it and warns that the key is now pinned locally and will not receive later changes from that -layer. Remove the key from `.fullsend/config.yaml` to inherit again. Omitted flags and per-run -flags (`--dry-run`, `--direct`, `--vendor`, …) do not pin or warn. A `config.yaml` that no longer -parses fails the re-run rather than being regenerated. +### Re-running per-repo setup + +A re-run with no flags is the supported way to upgrade a single repository that is not declared in a [`fullsend repos`](repos.md) manifest, because `fullsend repos install` needs one. The steps are in [Upgrading a single repository](../guides/getting-started/operations.md#upgrading-a-single-repository). + +**What the re-run changes:** + +| Change | When it takes effect | +|---|---| +| Managed workflow files, including the shim trigger (`pull_request_target` → `pull_request`) and the workflow pins (moved to the CLI's release, or to `--fullsend-ref`) | In one setup PR, when you merge it | +| Repository variables and secrets, resolved from the repository's configuration (`.fullsend/config.yaml` over `config.base.yaml` over compiled defaults) | When the command runs, before the PR is merged | +| Vendored assets, when the re-run has no `--vendor` | Deleted by a separate commit on the default branch when the command runs | + +Run with `--dry-run` first: it lists the files it would commit, the variable values it would set and the vendored assets it would remove. + +**What the re-run keeps:** +- An existing `.fullsend/config.yaml`: `agents:` entries and their settings, allowlists and hand-written comments stay as they are. The runtime prompt is skipped, and the setup PR reports the runtime the file selects. A `config.yaml` that no longer parses fails the re-run rather than being regenerated. +- `config.base.yaml`, unchanged. Only `--config` refreshes it. +- A custom `FULLSEND_APP_SET` repository variable. +- Existing GCP secrets for `inference.project` and `inference.wif_provider` when the configuration does not set them. When the configuration sets one of the two but not the other, the re-run reuses the other's existing secret and fails with `--inference-wif-provider is required for per-repo setup (no existing secret found)` (or the `--inference-project` equivalent) when that secret is missing. + +**When to add flags:** +- **`--vendor`:** pass it again if the install is vendored, or the re-run deletes the vendored assets. +- **`--config` (and `--config-hash`):** pass them again to refresh `config.base.yaml` from the preset. +- **`--fullsend-ref`:** pass it only with a ref at or after the release that installs the `pull_request` shim. An older ref pins the new shim to a reusable workflow that predates it. Without the flag the pins move to the CLI's release. +- **A value set only as a repository variable,** such as `FULLSEND_MINT_URL` or `FULLSEND_GCP_REGION`, goes back to the configuration value or the default. Put it in `config.yaml`, or pass its flag (`--mint-url`, `--inference-region`). +- **A config flag** (`--runtime`, `--agents`, `--mint-url`, `--inference-*`) changes that key on the existing `config.yaml` and keeps the rest. The file is re-serialized, so its comments are lost. + +**How `--config` and config flags combine:** `--config` rewrites `config.base.yaml` from the preset (byte-for-byte) and keeps the existing overlay unless a persistent setup flag is also passed, in which case that flag is written into the overlay. Persistent setup flags may be combined with `--config`; they override the corresponding preset values. When an explicitly passed persistent flag equals the value the overlay would otherwise inherit from `config.base.yaml` or a compiled default, setup still writes it and warns that the key is now pinned locally and will not receive later changes from that layer. Remove the key from `.fullsend/config.yaml` to inherit again. Omitted flags and per-run flags (`--dry-run`, `--direct`, `--vendor`, ...) do not pin or warn. ### Flags diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index 13f96db6b4..cb1c09990c 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -116,14 +116,67 @@ To upgrade the fullsend CLI, download the latest release from [GitHub Releases](https://github.com/fullsend-ai/fullsend/releases), or run [`fullsend self-update`](../../cli/self-update.md) on v0.55.0 or later. -After upgrading the fullsend CLI, re-run `github setup` to update the workflow file for a single repo: +### Upgrading a single repository -```bash -fullsend github setup "$OWNER/$REPO" \ - --inference-project "" \ - --inference-wif-provider "" +Use this route for a repository set up with `fullsend github setup` and not declared in a `repos.yaml` manifest. `fullsend repos install` needs a manifest; manifest repositories follow [Upgrading manifest-managed repositories](#upgrading-manifest-managed-repositories) below. + +**You need:** admin access to the repository, and GitHub CLI authentication (`gh auth login`, or `GH_TOKEN` set) with the `repo` and `workflow` scopes. + +1. Upgrade the CLI: + + ```bash + fullsend self-update # or download the release + ``` + +2. Preview the re-run. It changes nothing: + + ```bash + fullsend github setup "$OWNER/$REPO" --dry-run + ``` + + Check the repository variables it lists. Variables and secrets are written as soon as step 3 runs, before you merge anything. A `FULLSEND_MINT_URL` or `FULLSEND_GCP_REGION` that you set only as a repository variable goes back to the configuration value or the default; put it in `.fullsend/config.yaml` first. If the install is vendored (the repository has `.fullsend/bin/`), add `--vendor` in step 3; without it the vendored assets are deleted from the default branch right away. + +3. Re-run setup with no flags (add `--vendor` for a vendored install): + + ```bash + fullsend github setup "$OWNER/$REPO" + ``` + +4. Review and merge the setup PR it prints. The default branch keeps the old shim until you merge. + +**What success looks like.** Output from upgrading a v0.56.1 install (shortened, repository name replaced): + +``` +→ Setting up per-repo fullsend for owner/repo + + Keeping existing .fullsend/config.yaml unchanged (pass --runtime, --agents, --mint-url or --inference-* to change a key) + • Checking token permissions + ✓ Token permissions verified + + • Creating scaffold PR for owner/repo (target: main) + ✓ Created PR #2: https://github.com/owner/repo/pull/2 + Merge the PR to apply these changes + • Configuring repository variables + ✓ Set 5 repository variables + • Configuring repository secrets + ✓ Set 2 repository secrets + + ✓ Per-repo setup complete for owner/repo ``` +The PR has one commit. It moves the shim trigger and the workflow pins, and leaves `.fullsend/config.yaml` alone: + +```diff +- pull_request_target: ++ pull_request: +- uses: fullsend-ai/fullsend/.github/workflows/reusable-dispatch.yml@27c1d6ce1d384fa8b85b6789653fb3505d93c9d3 # v0.56.1 ++ uses: fullsend-ai/fullsend/.github/workflows/reusable-dispatch.yml@f24e7d3bb03c44371e58653f0fd051ed9c445b0f # v0.57.0 +``` + +Add other flags only if the install used `--config` or `--fullsend-ref`, or to change a configuration key; see [Re-running per-repo setup](../../cli/github.md#re-running-per-repo-setup). + +### Upgrading manifest-managed repositories + For manifest-managed installations (including GitLab repos), use `repos install` to converge all repos (including workflow ref upgrades): ```bash diff --git a/docs/guides/getting-started/repo-management.md b/docs/guides/getting-started/repo-management.md index e371d92ddc..2fc5e31b83 100644 --- a/docs/guides/getting-started/repo-management.md +++ b/docs/guides/getting-started/repo-management.md @@ -1010,17 +1010,27 @@ December 2, 2026. Repositories whose `.github/workflows/fullsend.yaml` still triggers on it lose automatic review and retro from that date. Triage, `/fs-*` commands (including `/fs-review`) and the fix loop keep working. -Upgrade every public repository before that date, using the steps in -[Rolling out a new fullsend version](#rolling-out-a-new-fullsend-version). +Upgrade every public repository before that date. Use the route that matches +how the repository was set up: + +- **Repositories declared in a manifest:** run `fullsend repos install`, + using the steps in + [Rolling out a new fullsend version](#rolling-out-a-new-fullsend-version). + It rewrites the trigger and the workflow pin in one commit. If it cannot + fetch the templates of the new version, it upgrades only the pin and prints + `template fetch at the target ref failed: delivering the pin upgrade only; + run install again to deliver template changes`. Run it again once the + fetch works to deliver the trigger. +- **Single repositories set up with `fullsend github setup`** and no manifest: + upgrade the CLI, re-run `fullsend github setup "$OWNER/$REPO"` with no + flags, and merge the setup PR it opens. Follow + [Upgrading a single repository](operations.md#upgrading-a-single-repository): + the re-run writes repository variables before the PR merges. + Private and internal repositories are not blocked, and a shim that is not upgraded keeps working there (the warning appears only in public repositories). Any upgrade to a fullsend version with the new shim installs -the same `pull_request` shim, with the effects below. -`fullsend repos install` rewrites the trigger and the workflow pin in one -commit. If it cannot fetch the templates of the new version, it upgrades -only the pin and prints `template fetch at the target ref failed: delivering -the pin upgrade only; run install again to deliver template changes`. Run it -again once the fetch works to deliver the trigger. After the upgrade: +the same `pull_request` shim, with the effects below. After the upgrade: - **Same-repo PRs** are reviewed automatically, as before, except while the PR has a merge conflict: GitHub does not run `pull_request` workflows until diff --git a/internal/cli/github_test.go b/internal/cli/github_test.go index 8d76a7e115..9db119f2d8 100644 --- a/internal/cli/github_test.go +++ b/internal/cli/github_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" "github.com/fullsend-ai/fullsend/internal/appsetup" "github.com/fullsend-ai/fullsend/internal/config" @@ -1589,6 +1590,80 @@ func TestRunGitHubSetupPerRepo_Rerun_KeepsExistingConfigVerbatim(t *testing.T) { assert.NotContains(t, out.String(), "runtime?", "no runtime prompt on a re-run") } +// oldPullRequestTargetShim is a shim as releases before the move to +// pull_request installed it: PR events trigger on pull_request_target and +// the reusable workflow is pinned to an older release. +const oldPullRequestTargetShim = `name: fullsend + +on: + issues: + types: [opened, edited, labeled] + issue_comment: + types: [created] + pull_request_target: + types: [opened, synchronize, ready_for_review, closed, labeled, unlabeled] + pull_request_review: + types: [submitted] + +permissions: {} + +jobs: + dispatch: + if: github.event_name != 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository + uses: fullsend-ai/fullsend/.github/workflows/reusable-dispatch.yml@v0.56.1 + secrets: inherit +` + +// TestRunGitHubSetupPerRepo_Rerun_UpgradesPullRequestTargetShim covers the +// documented single-repo upgrade (#9715): a bare re-run of github setup on a +// repo without a manifest, whose shim still triggers on pull_request_target, +// opens one setup PR whose single commit carries the pull_request shim pinned +// to this CLI's release, and leaves .fullsend/config.yaml out. Setup renders +// the shim from the embedded template and never reads the existing one, so +// the fixture only models the repository being upgraded; the assertions pin +// the result. +func TestRunGitHubSetupPerRepo_Rerun_UpgradesPullRequestTargetShim(t *testing.T) { + t.Setenv("GH_TOKEN", "test-token") + const releaseSHA = "0123456789abcdef0123456789abcdef01234567" + origOverride := upstreamRefOverride + upstreamRefOverride = releaseSHA + t.Cleanup(func() { upstreamRefOverride = origOverride }) + client := newRerunSetupClient(t, existingPerRepoConfigForRerun) + client.FileContents["acme/widget/.github/workflows/fullsend.yaml"] = []byte(oldPullRequestTargetShim) + printer := ui.New(&discardWriter{}) + + err := runGitHubSetupPerRepo(context.Background(), client, printer, githubSetupConfig{ + target: "acme/widget", + agents: strings.Join(config.PerRepoDefaultRoles(), ","), + changedFlags: map[string]bool{}, + }) + require.NoError(t, err) + require.Len(t, client.CommittedFilesToBranch, 1, "the upgrade is delivered in one setup commit") + require.Len(t, client.CreatedProposals, 1, "the upgrade opens one setup PR") + + shim, present := committedScaffoldFile(client, ".github/workflows/fullsend.yaml") + require.True(t, present, "the setup commit delivers the shim") + assert.NotEqual(t, oldPullRequestTargetShim, string(shim), "the old shim is replaced") + var wf struct { + On map[string]any `yaml:"on"` + Jobs map[string]struct { + If string `yaml:"if"` + Uses string `yaml:"uses"` + } `yaml:"jobs"` + } + require.NoError(t, yaml.Unmarshal(shim, &wf)) + assert.Contains(t, wf.On, "pull_request", "the upgraded shim triggers on pull_request") + assert.NotContains(t, wf.On, "pull_request_target", "the upgraded shim no longer triggers on pull_request_target") + dispatch, ok := wf.Jobs["dispatch"] + require.True(t, ok, "dispatch job not found") + assert.NotContains(t, dispatch.If, "pull_request_target") + assert.True(t, strings.HasSuffix(dispatch.Uses, "/reusable-dispatch.yml@"+releaseSHA), + "the workflow pin moves to the CLI's release, got %q", dispatch.Uses) + + _, cfgPresent := committedScaffoldFile(client, ".fullsend/config.yaml") + assert.False(t, cfgPresent, "the upgrade does not commit .fullsend/config.yaml") +} + func TestRunGitHubSetupPerRepo_Rerun_ChangesOnlyTheFlaggedKey(t *testing.T) { t.Setenv("GH_TOKEN", "test-token") client := newRerunSetupClient(t, existingPerRepoConfigForRerun)