Skip to content

Commit 050e04f

Browse files
authored
Document cpflow upstream ref pinning
1 parent b589e5e commit 050e04f

4 files changed

Lines changed: 70 additions & 2 deletions

File tree

.controlplane/docs/testing-cpflow-github-actions.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,48 @@ Control Plane secrets to local composite actions. A PR branch can contain fixed
1818
`.github/actions/*` files, but the deploy job still loads those local actions
1919
from `master` until the fix is merged there.
2020

21+
## How Upstream Code Is Pinned
22+
23+
Generated `cpflow-*` workflows are thin wrappers around reusable workflows in
24+
`shakacode/control-plane-flow`. GitHub reusable workflows cannot be loaded from
25+
a Ruby gem; GitHub resolves them from a repository ref. Each wrapper therefore
26+
has two upstream pins that must stay in sync:
27+
28+
```yaml
29+
uses: shakacode/control-plane-flow/.github/workflows/cpflow-deploy-review-app.yml@<ref>
30+
with:
31+
control_plane_flow_ref: <ref>
32+
```
33+
34+
`uses: ...@<ref>` chooses the reusable workflow file. `control_plane_flow_ref`
35+
chooses the same upstream checkout for shared composite actions and, when
36+
`CPFLOW_VERSION` is unset, the source used to build and install the `cpflow` gem
37+
inside the workflow.
38+
39+
The stable release path is still gem-driven:
40+
41+
1. Install or update to a released `cpflow` gem.
42+
2. Run `cpflow generate-github-actions --staging-branch master`.
43+
3. The generated wrappers use `v<cpflow gem version>` as the upstream ref.
44+
45+
That tag should point to the same source that produced the RubyGems release, so
46+
the workflow code is locked to a release tag rather than a moving branch. Do not
47+
pin production workflows to `main` or a feature branch. For unreleased testing,
48+
pin to an immutable commit SHA, not a branch name, then regenerate or repin to
49+
the release tag after the upstream release is published.
50+
51+
`CPFLOW_VERSION` is separate from the GitHub workflow ref. If the repository
52+
variable is set, the setup action runs `gem install cpflow -v <version>`. If it
53+
is unset, the setup action builds `cpflow` from the checked-out upstream ref.
54+
For normal releases, either leave `CPFLOW_VERSION` unset while using the matching
55+
`v<version>` upstream tag, or set `CPFLOW_VERSION` to the same released gem
56+
version without the leading `v`.
57+
58+
This repo is currently pinned to an upstream commit SHA because the reusable
59+
workflow change was tested before a new `cpflow` gem release existed. That is
60+
safer than pinning a branch, but it should be treated as a temporary test pin
61+
until the next upstream release tag is available.
62+
2163
## Local Checks
2264

2365
After regenerating the flow, run these checks from the repository root. If

.controlplane/readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,22 @@ GitHub Actions flow, update a project by regenerating the flow from the desired
421421
`cpflow` version or branch, reviewing the diff, and keeping any local app names,
422422
repository variables, secrets, and docs aligned with `.controlplane/controlplane.yml`.
423423

424+
The generated workflows are intentionally thin wrappers around reusable
425+
workflows in `shakacode/control-plane-flow`. GitHub loads reusable workflows from
426+
a repository ref, not from the Ruby gem, so each wrapper has a `uses: ...@<ref>`
427+
line plus a matching `control_plane_flow_ref: <ref>`. For stable releases,
428+
generate these files from a released `cpflow` gem; the default ref is the
429+
matching upstream release tag, `v<gem version>`. Avoid `main` or feature-branch
430+
refs in production. Use an immutable commit SHA only when testing unreleased
431+
upstream changes, then move back to the release tag after the upstream release
432+
is published.
433+
434+
`CPFLOW_VERSION` is a runtime gem-install override. When it is unset, the setup
435+
action builds `cpflow` from the checked-out upstream ref. When it is set, the
436+
setup action installs that RubyGems version instead. For normal release pins,
437+
either leave it unset while using the matching `v<version>` workflow tag, or set
438+
it to the same gem version without the leading `v`.
439+
424440
For this app, validate a regenerated flow with:
425441

426442
```bash

.controlplane/shakacode-team.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ Optional repository settings:
5151
- `DOCKER_BUILD_EXTRA_ARGS`: newline-delimited Docker build tokens, such as `--build-arg=FOO=bar`.
5252
- `DOCKER_BUILD_SSH_KNOWN_HOSTS`: custom `known_hosts` entries when SSH build hosts are not GitHub.com.
5353
- `CPLN_CLI_VERSION`: pin a specific `@controlplane/cli` version; defaults to the generated action pin.
54-
- `CPFLOW_VERSION`: pin a specific cpflow gem version; defaults to the generated action pin.
54+
- `CPFLOW_VERSION`: optional runtime gem-install override. When unset, workflows build
55+
`cpflow` from the checked-out upstream workflow ref. When set, use the RubyGems
56+
version number without a leading `v`.
5557
- `HEALTH_CHECK_ACCEPTED_STATUSES`: production promotion health statuses; defaults to `200 301 302`.
5658
- `HEALTH_CHECK_RETRIES` / `HEALTH_CHECK_INTERVAL`: production health polling controls; defaults to `24` retries and `15` seconds.
5759
- `ROLLBACK_READINESS_RETRIES` / `ROLLBACK_READINESS_INTERVAL`: post-rollback health polling controls; defaults to `24` retries and `15` seconds.
@@ -71,6 +73,14 @@ that the deploy workflow checks out trusted local actions from `master` before
7173
passing Control Plane secrets; PR-branch composite action changes are not fully
7274
tested until they land on `master` and a real review-app deploy is rerun.
7375

76+
Generated workflow wrappers point to upstream reusable workflows with
77+
`uses: shakacode/control-plane-flow/...@<ref>` and pass the same
78+
`control_plane_flow_ref`. For stable releases, `<ref>` should be the
79+
`v<cpflow gem version>` tag produced by the released gem. Do not use `main` or a
80+
feature branch for production automation. A commit SHA is acceptable for
81+
unreleased testing, but regenerate or repin to the release tag once the upstream
82+
release exists.
83+
7484
See [readme.md](readme.md) and
7585
[Testing cpflow GitHub Actions Changes](docs/testing-cpflow-github-actions.md)
7686
for more details.

.github/cpflow-help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ You asked for review app help. These commands are generated by [cpflow](https://
5454
| `DOCKER_BUILD_SSH_KNOWN_HOSTS` | optional | SSH known_hosts entries when SSH build hosts are not GitHub.com. |
5555
| `HEALTH_CHECK_ACCEPTED_STATUSES` | optional | Space-separated HTTP statuses considered healthy on promote (default `200 301 302`). |
5656
| `CPLN_CLI_VERSION` | optional | Pin a specific `@controlplane/cli` version; falls back to the action default when unset. |
57-
| `CPFLOW_VERSION` | optional | Pin a specific cpflow gem version; falls back to the generated default when unset. |
57+
| `CPFLOW_VERSION` | optional | Runtime gem-install override. When unset, cpflow is built from the pinned upstream workflow ref. When set, use the RubyGems version without a leading `v`. |
5858

5959
</details>
6060

0 commit comments

Comments
 (0)