cpflow 6.0.0.rc.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.agents/agent-workflow.yml +16 -38
- data/.agents/bin/README.md +7 -8
- data/.agents/legacy-workflow-policy.yml +11 -0
- data/.agents/shaka.md +20 -0
- data/.agents/trusted-actions.yml +12 -0
- data/.coderabbit.yaml +1 -0
- data/.github/actions/cpflow-build-docker-image/action.yml +153 -22
- data/.github/actions/cpflow-delete-control-plane-app/delete-app.sh +3 -0
- data/.github/actions/cpflow-preview-promotion/action.yml +82 -0
- data/.github/actions/cpflow-preview-promotion/preview-promotion.sh +90 -0
- data/.github/workflows/cpflow-cleanup-stale-review-apps.yml +3 -10
- data/.github/workflows/cpflow-delete-review-app.yml +4 -11
- data/.github/workflows/cpflow-deploy-review-app.yml +19 -14
- data/.github/workflows/cpflow-deploy-staging.yml +17 -12
- data/.github/workflows/cpflow-promote-staging-to-production.yml +132 -13
- data/.github/workflows/rspec.yml +24 -0
- data/AGENTS.md +18 -3
- data/CHANGELOG.md +26 -3
- data/CONTRIBUTING.md +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/docs/ai-github-flow-prompt.md +104 -8
- data/docs/ci-automation.md +258 -60
- data/docs/commands.md +32 -16
- data/docs/postgres-review-apps.md +90 -0
- data/docs/postgres.md +233 -375
- data/docs/secrets-and-env-values.md +42 -0
- data/docs/sidebars.ts +1 -0
- data/lib/command/ai_github_flow_prompt.rb +10 -13
- data/lib/command/ai_github_flow_prompt.txt +103 -0
- data/lib/command/apply_template.rb +36 -4
- data/lib/command/base.rb +56 -3
- data/lib/command/delete.rb +174 -4
- data/lib/command/deploy_image.rb +6 -0
- data/lib/command/generate.rb +247 -3
- data/lib/command/generate_github_actions.rb +15 -17
- data/lib/command/setup_app.rb +92 -10
- data/lib/command/update_github_actions.rb +107 -43
- data/lib/core/config.rb +73 -0
- data/lib/core/controlplane.rb +22 -2
- data/lib/core/controlplane_api.rb +28 -2
- data/lib/core/controlplane_api_direct.rb +17 -0
- data/lib/core/disposable_postgres_helpers.rb +167 -0
- data/lib/core/doctor_service.rb +7 -0
- data/lib/core/github_flow_readiness/checks.rb +2 -1
- data/lib/core/github_flow_readiness_service.rb +4 -0
- data/lib/core/repo_introspection.rb +112 -2
- data/lib/cpflow/version.rb +1 -1
- data/lib/generator_templates/.dockerignore +16 -0
- data/lib/generator_templates/Dockerfile +9 -5
- data/lib/generator_templates/entrypoint.sh +2 -0
- data/lib/generator_templates/templates/postgres.yml +9 -0
- data/lib/generator_templates_sqlite/controlplane.yml +2 -1
- data/lib/generator_templates_sqlite/release_script.sh +1 -1
- data/lib/generator_templates_sqlite/templates/rails.yml +2 -1
- data/lib/github_flow_templates/.github/cpflow-help.md +39 -12
- data/lib/github_flow_templates/.github/workflows/cpflow-deploy-review-app.yml +1 -0
- data/lib/github_flow_templates/.github/workflows/cpflow-deploy-staging.yml +1 -0
- data/lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml +132 -13
- data/lib/github_flow_templates/bin/pin-cpflow-github-ref +37 -13
- data/lib/github_flow_templates/bin/test-cpflow-github-flow +88 -47
- metadata +12 -3
data/CONTRIBUTING.md
CHANGED
|
@@ -40,7 +40,7 @@ overcommit --install
|
|
|
40
40
|
Every repository-based external `uses:` entry under `.github/workflows/` or `.github/actions/` must use an immutable,
|
|
41
41
|
lowercase 40-character commit SHA followed by the exact release tag in a same-line comment. Do not use moving
|
|
42
42
|
major-version tags or branch names. New action repositories also require explicit review before they are added to
|
|
43
|
-
`trusted_actions` in `.agents/
|
|
43
|
+
`trusted_actions` in `.agents/trusted-actions.yml`. Docker actions must use an exact `sha256:` image digest; manually
|
|
44
44
|
review the registry, image, and digest because Docker references are outside the repository allowlist.
|
|
45
45
|
Generated downstream calls to Control Plane Flow's cross-repository reusable workflows are the deliberate exception:
|
|
46
46
|
they use an exact `vX.Y.Z` release tag so the workflow source stays aligned with the released `cpflow` gem.
|
|
@@ -150,10 +150,10 @@ cpflow test
|
|
|
150
150
|
|
|
151
151
|
## Developing the GitHub flow generator
|
|
152
152
|
|
|
153
|
-
`cpflow generate-github-actions` copies workflow templates in `lib/github_flow_templates/`
|
|
153
|
+
`cpflow generate-github-actions` copies workflow templates in `lib/github_flow_templates/` into a target repo's `.github/` directory. The composite actions those workflows call stay in this repository's `.github/actions/cpflow-*`; workflows load them from the pinned `.cpflow` checkout as `./.cpflow/.github/actions/cpflow-*`. To work on this feature:
|
|
154
154
|
|
|
155
|
-
- **Edit each canonical source in place.** The generator does no string-mangling beyond a small set of substitutions handled in `lib/command/generate_github_actions.rb`; what you put in `lib/github_flow_templates/.github/` is (almost) exactly what ships into a generated repo. Edit composite actions in the root `.github/actions/cpflow-*` directories. Make changes in those canonical sources, not in a generated copy.
|
|
156
|
-
- **Surface area to keep consistent.** A change to a PR command (e.g. `+review-app-deploy`) usually touches three places: the trigger workflow (`lib/github_flow_templates/.github/workflows/cpflow-deploy-review-app.yml`), the PR-open quick reference (`cpflow-review-app-help.yml`), and the long-form help (`lib/github_flow_templates/.github/cpflow-help.md`). The AI flow prompt (`lib/command/ai_github_flow_prompt.
|
|
155
|
+
- **Edit each canonical source in place.** The generator does no string-mangling beyond a small set of substitutions handled in `lib/command/generate_github_actions.rb`; what you put in `lib/github_flow_templates/.github/` is (almost) exactly what ships into a generated repo. Edit composite actions in the root `.github/actions/cpflow-*` directories; they are not copied downstream. Make changes in those canonical sources, not in a generated copy.
|
|
156
|
+
- **Surface area to keep consistent.** A change to a PR command (e.g. `+review-app-deploy`) usually touches three places: the trigger workflow (`lib/github_flow_templates/.github/workflows/cpflow-deploy-review-app.yml`), the PR-open quick reference (`cpflow-review-app-help.yml`), and the long-form help (`lib/github_flow_templates/.github/cpflow-help.md`). The AI flow prompt (`lib/command/ai_github_flow_prompt.txt`, mirrored in `docs/ai-github-flow-prompt.md`) also names commands and should be kept in sync.
|
|
157
157
|
- **Run the generator spec on every change:**
|
|
158
158
|
|
|
159
159
|
```sh
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -29,7 +29,7 @@ _If you need a free demo account for Control Plane (no CC required), you can con
|
|
|
29
29
|
To bootstrap a new project, run three commands from the repo root:
|
|
30
30
|
|
|
31
31
|
1. **`cpflow github-flow-readiness`** — gate for common rollout blockers (missing Rails runtime scaffold, legacy Ruby or Bundler toolchains, unpublished exact-pinned gems or npm packages, missing production Dockerfiles). Exits non-zero on any blocker.
|
|
32
|
-
2. **`cpflow generate`** — creates `.controlplane/` scaffolding.
|
|
32
|
+
2. **`cpflow generate`** — creates `.controlplane/` scaffolding and a safe root `.dockerignore` when one is missing. It infers the app prefix from the repo directory, the base Ruby version from `.ruby-version`/`.tool-versions`/`Gemfile`, the JS package manager from `package.json`, repo-defined frontend precompile hooks (Shakapacker `precompile_hook`, React on Rails auto bundle generation), and switches to persistent SQLite data + Active Storage volume templates when `config/database.yml` shows SQLite in production.
|
|
33
33
|
3. **`cpflow generate-github-actions`** — adds the reusable GitHub Actions pipeline for review apps, staging deploys, and manual production promotion.
|
|
34
34
|
|
|
35
35
|
The generated scaffold is a starting point. After generation, adapt `.controlplane/` for app-specific workloads (Sidekiq, Node renderer), wire any private-dependency Docker build settings (SSH key, optional known-host overrides), and verify that the production Docker build succeeds.
|
|
@@ -398,7 +398,7 @@ cpflow generate-github-actions
|
|
|
398
398
|
bin/test-cpflow-github-flow
|
|
399
399
|
```
|
|
400
400
|
|
|
401
|
-
`cpflow github-flow-readiness` exits non-zero when it finds blockers such as unpublished exact-pinned packages or a missing production Dockerfile, so use it as the gate before generation. Then review the generated `.controlplane/controlplane.yml` entries, adjust any app-specific workloads, and configure the GitHub repository variables and secrets described in [CI automation](./docs/ci-automation.md), including the optional Docker build settings for private GitHub dependencies and custom SSH known hosts. `cpflow generate-github-actions`
|
|
401
|
+
`cpflow github-flow-readiness` exits non-zero when it finds blockers such as unpublished exact-pinned packages or a missing production Dockerfile, so use it as the gate before generation. Then review the generated `.controlplane/controlplane.yml` entries, adjust any app-specific workloads, and configure the GitHub repository variables and secrets described in [CI automation](./docs/ci-automation.md), including the optional Docker build settings for private GitHub dependencies and custom SSH known hosts. `cpflow generate-github-actions` writes the workflows, which load cpflow's composite actions from the pinned upstream ref, and also writes `bin/test-cpflow-github-flow` for local validation and `bin/pin-cpflow-github-ref` for temporarily pinning downstream wrappers to an upstream commit SHA during pre-release testing. `cpflow generate` already switches to persistent `/app/data` and `/app/storage` volumes when `config/database.yml` shows SQLite in production, redirects every detected production SQLite database into persistent storage, keeps migrations visible under `/app/db`, and preserves detected frontend precompile hooks. You should still confirm that the generated Dockerfile picked a Ruby base image compatible with the app's declared Ruby requirement and that the emitted workload set matches the real app. If you want an AI agent to do this end to end, give it the [AI rollout prompt](./docs/ai-github-flow-prompt.md) rather than a vague "set up CI" request.
|
|
402
402
|
|
|
403
403
|
For a live example, see the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/readme.md) repository.
|
|
404
404
|
|
|
@@ -545,6 +545,9 @@ If you want to run PostgreSQL on Control Plane instead of keeping a Heroku add-o
|
|
|
545
545
|
persistent storage and optional scheduled backups. Additionally, we provide a default `postgres` template in this
|
|
546
546
|
repository optimized for Control Plane and suitable for development purposes.
|
|
547
547
|
|
|
548
|
+
For disposable review apps, see [PostgreSQL for review apps](./docs/postgres-review-apps.md)
|
|
549
|
+
for helper ownership, automatic cleanup, and recovery after interrupted deletion.
|
|
550
|
+
|
|
548
551
|
## In-memory Databases
|
|
549
552
|
|
|
550
553
|
E.g., Redis, Memcached.
|
|
@@ -8,13 +8,109 @@ first.
|
|
|
8
8
|
## Recommended Prompt
|
|
9
9
|
|
|
10
10
|
```text
|
|
11
|
-
Set up Control Plane GitHub Flow for this repo.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
Set up Control Plane GitHub Flow for this repo.
|
|
12
|
+
|
|
13
|
+
Before generating anything:
|
|
14
|
+
- First make sure the `cpflow` CLI is available: use the repo's existing `bundle exec cpflow` if
|
|
15
|
+
present, otherwise install the published `cpflow` Ruby gem with `gem install cpflow`; if neither
|
|
16
|
+
is possible, stop and report that blocker.
|
|
17
|
+
- Use the same `cpflow` invocation for the rest of the rollout.
|
|
18
|
+
- Start with `cpflow github-flow-readiness` and stop on any reported blockers.
|
|
19
|
+
- The repo must be deployable from a clean clone: published package versions, complete runtime
|
|
20
|
+
scaffold, and a production Dockerfile that can build the app.
|
|
21
|
+
- If any package version is unpublished, inaccessible from CI, or requires credentials that are not
|
|
22
|
+
already modeled in the repo or GitHub settings, stop and report the blocker instead of generating
|
|
23
|
+
workflow files.
|
|
24
|
+
- If the repo is a legacy sample pinned to an obsolete Ruby or Bundler toolchain, if it does not
|
|
25
|
+
even have a production Dockerfile yet, or if it is a monorepo without an already-decided single
|
|
26
|
+
app boundary for this flow, stop and report that as a prerequisite instead of forcing the rollout.
|
|
27
|
+
|
|
28
|
+
Generate the flow:
|
|
29
|
+
- If `.controlplane/` is missing, run `cpflow generate`.
|
|
30
|
+
- Treat the generated app names as the repo-name default and rename them only if the
|
|
31
|
+
project needs a different prefix.
|
|
32
|
+
- Then run `cpflow generate-github-actions` (or `cpflow generate-github-actions --staging-branch
|
|
33
|
+
BRANCH` when staging should deploy from a branch other than `main`/`master`).
|
|
34
|
+
- Keep review apps opt-in via `+review-app-deploy`.
|
|
35
|
+
- Make sure any `STAGING_APP_BRANCH` repository variable is also present in the generated staging
|
|
36
|
+
workflow's `on.push.branches` filter.
|
|
37
|
+
- List the GitHub secrets and variables that must be configured.
|
|
38
|
+
|
|
39
|
+
Keep the Control Plane Flow source pins together:
|
|
40
|
+
- Do not hand-edit duplicated upstream refs into the generated wrappers.
|
|
41
|
+
- Keep every generated Control Plane Flow source pin synchronized at the same `vX.Y.Z`: each
|
|
42
|
+
reusable-workflow `uses: ...@vX.Y.Z` ref, the production promotion `.cpflow` checkout ref, and its
|
|
43
|
+
`control_plane_flow_ref` setup input.
|
|
44
|
+
- By default, `cpflow generate-github-actions` derives these values from the installed `cpflow` gem
|
|
45
|
+
version; temporary explicit ref overrides are for unreleased testing and must keep all three
|
|
46
|
+
values synchronized.
|
|
47
|
+
- Do not add `.github/actions/cpflow-*` copies; the workflows load cpflow's composite actions and
|
|
48
|
+
runtime source from the pinned `.cpflow` checkout.
|
|
49
|
+
|
|
50
|
+
When bumping the `cpflow` gem in a downstream repo:
|
|
51
|
+
- `cpflow update-github-actions` refreshes helpers while preserving all top-level workflows,
|
|
52
|
+
including their refs and triggers.
|
|
53
|
+
- It reports `.github/actions/cpflow-*` copies left by cpflow 6.0.0; delete them once no workflow is
|
|
54
|
+
pinned to 6.0.0 or names one.
|
|
55
|
+
- Use `cpflow update-github-actions --workflows FILE...` to explicitly select wrappers for
|
|
56
|
+
replacement, then review the diff and reapply downstream customizations.
|
|
57
|
+
- A differing existing validator blocks all writes: preserve its downstream checks in executable
|
|
58
|
+
`bin/test-cpflow-github-flow-custom`, then remove or rename the old generated validator before
|
|
59
|
+
retrying.
|
|
60
|
+
- The generated validator invokes that preserved extension and propagates its failures.
|
|
61
|
+
- Follow `docs/ci-automation.md` for the migration procedure, keep source pins compatible with the
|
|
62
|
+
updated actions, and run `bin/test-cpflow-github-flow` in the same PR (or
|
|
63
|
+
`bin/test-cpflow-github-flow bundle exec cpflow` when using Bundler).
|
|
64
|
+
|
|
65
|
+
Review apps and workload sizing:
|
|
66
|
+
- Keep the normal generated review-app setup simple: review apps require only `CPLN_TOKEN_STAGING`
|
|
67
|
+
when the generated review app config can be inferred.
|
|
68
|
+
- For public demos, starter staging apps, and long-lived review apps, keep the app workload `type:
|
|
69
|
+
standard` with one warm replica, set its autoscaling metric to `disabled`, and enable `capacityAI:
|
|
70
|
+
true` so Control Plane can right-size CPU and memory allocation at that fixed replica count.
|
|
71
|
+
- Shared Postgres and other stateful workloads are the usual exceptions and should stay manually
|
|
72
|
+
sized; Capacity AI is for supported stateless app/service workloads.
|
|
73
|
+
- If true idle scale-to-zero is explicitly required, create a separate `serverless` workload before
|
|
74
|
+
first deploy or plan a delete/recreate migration because Control Plane will not change an existing
|
|
75
|
+
`standard` workload to `serverless` in place.
|
|
76
|
+
- For shared review-app resources such as one staging database, use `shared_secret_grants` and
|
|
77
|
+
`{{SHARED_SECRET_DATABASE}}` placeholders instead of hardcoding the base app secret name; this
|
|
78
|
+
keeps review-app policy binding and cleanup automatic while avoiding per-PR database cost.
|
|
79
|
+
|
|
80
|
+
Staging and production:
|
|
81
|
+
- Document the one-time Control Plane bootstrap command for persistent staging and production apps
|
|
82
|
+
with `cpflow setup-app --skip-post-creation-hook`; for existing apps or later template updates,
|
|
83
|
+
document `cpflow apply-template` and the need for the app identity to have `reveal` on the app
|
|
84
|
+
secret policy.
|
|
85
|
+
- Do not imply the staging deploy or promotion workflows create those persistent GVCs.
|
|
86
|
+
- For production promotion, document a protected `production` GitHub Environment with required
|
|
87
|
+
reviewers, prevent self-review, and `CPLN_TOKEN_PRODUCTION` stored as an environment secret, not
|
|
88
|
+
as a repository or organization secret.
|
|
89
|
+
|
|
90
|
+
Docker image and runtime:
|
|
91
|
+
- Keep Node available in the final image if asset compilation or SSR depends on ExecJS, Yarn,
|
|
92
|
+
`pnpm`, or npm after the main install layer.
|
|
93
|
+
- Make sure the generated Dockerfile uses a Ruby base image compatible with the app's declared Ruby
|
|
94
|
+
requirement.
|
|
95
|
+
- Preserve repo-defined frontend build hooks: if `config/shakapacker.yml` defines a
|
|
96
|
+
`precompile_hook`, or React on Rails enables `config.auto_load_bundle = true`, confirm the
|
|
97
|
+
generated Dockerfile runs that codegen step before `rails assets:precompile`.
|
|
98
|
+
- If `config/database.yml` shows SQLite in production, confirm that the generated scaffold redirects
|
|
99
|
+
every production database file into persistent `/app/data` (or keeps it under persistent
|
|
100
|
+
`/app/storage`) without mounting over the image's `/app/db` migrations, stores Active Storage
|
|
101
|
+
under `/app/storage`, and runs `rails db:prepare`; otherwise keep the default Postgres workload.
|
|
102
|
+
- If the public workload is not named `rails`, set `PRIMARY_WORKLOAD` or adjust the generated
|
|
103
|
+
workflows.
|
|
104
|
+
- Inspect the Dockerfile and package sources for private GitHub dependencies or `RUN
|
|
105
|
+
--mount=type=ssh`; if present, wire `DOCKER_BUILD_SSH_KEY`, optionally set
|
|
106
|
+
`DOCKER_BUILD_SSH_KNOWN_HOSTS` for non-GitHub SSH hosts, and keep `DOCKER_BUILD_EXTRA_ARGS` to
|
|
107
|
+
newline-delimited single tokens such as `--build-arg=FOO=bar`.
|
|
108
|
+
|
|
109
|
+
Validate and finish:
|
|
110
|
+
- Run the real local validations you can: Docker build if feasible, repo tests or smoke checks, YAML
|
|
111
|
+
validation, and any CI-equivalent build steps.
|
|
112
|
+
- Push the branch and check the GitHub Actions results.
|
|
113
|
+
- Only stop early for a real external blocker or a product decision that changes scope.
|
|
18
114
|
```
|
|
19
115
|
|
|
20
116
|
## Local Shortcut
|
|
@@ -46,7 +142,7 @@ Stop and report the blocker instead of generating `cpflow-*` workflow files when
|
|
|
46
142
|
The rollout is done when all of the following are true:
|
|
47
143
|
|
|
48
144
|
- `.controlplane/` exists and matches the actual app shape
|
|
49
|
-
- `.github/cpflow-help.md
|
|
145
|
+
- `.github/cpflow-help.md` and `.github/workflows/cpflow-*` are in place, with no `.github/actions/cpflow-*` copies
|
|
50
146
|
- review apps are opt-in, staging auto-deploys from one branch, and production promotion is manual
|
|
51
147
|
- required GitHub secrets and variables are documented for the repo
|
|
52
148
|
- the production image build path is validated for the real app
|