Skip to content

Commit e4302c5

Browse files
committed
Address cpflow testing doc reviews
1 parent 0323be2 commit e4302c5

3 files changed

Lines changed: 69 additions & 14 deletions

File tree

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,28 @@ from `master` until the fix is merged there.
2020

2121
## Local Checks
2222

23-
After regenerating the flow, run these checks from the repository root. When
24-
testing an unreleased upstream `control-plane-flow` checkout, invoke that
25-
checkout's `bin/cpflow` directly:
23+
After regenerating the flow, run these checks from the repository root. If
24+
`cpflow` is installed as a gem, use `cpflow` directly:
25+
26+
```sh
27+
bin/conductor-exec cpflow generate-github-actions --staging-branch master
28+
bin/test-cpflow-github-flow
29+
```
30+
31+
When testing an unreleased upstream `control-plane-flow` checkout, replace
32+
`cpflow` with that checkout's `bin/cpflow`:
2633

2734
```sh
2835
bin/conductor-exec ruby /path/to/control-plane-flow/bin/cpflow generate-github-actions --staging-branch master
29-
bin/conductor-exec ruby /path/to/control-plane-flow/bin/cpflow github-flow-readiness
30-
bin/conductor-exec ruby -e 'require "yaml"; Dir[".github/actions/**/action.yml", ".github/workflows/*.yml"].sort.each { |path| YAML.load_file(path, aliases: true); puts "parsed #{path}" }'
31-
bin/conductor-exec ruby -e 'require "yaml"; bad=[]; Dir[".github/actions/**/action.yml"].sort.each { |path| doc=YAML.load_file(path, aliases: true); doc.fetch("inputs", {}).each { |name, spec| bad << "#{path}:#{name}" if spec["description"].to_s.include?("${{") } }; }; abort bad.join("\n") unless bad.empty?; puts "no action metadata descriptions contain GitHub expressions"'
32-
actionlint -ignore 'SC2129' .github/workflows/cpflow-*.yml
36+
bin/test-cpflow-github-flow ruby /path/to/control-plane-flow/bin/cpflow
3337
```
3438

3539
Why the explicit description check exists: GitHub parses expression-like snippets
3640
inside composite action metadata, including `description:` fields. Literal
3741
examples such as `${{ vars.SOME_VALUE }}` can fail action loading before any
38-
shell step starts.
42+
shell step starts. The wrapper runs `cpflow github-flow-readiness`, parses the
43+
generated YAML, checks action input descriptions for literal GitHub expressions,
44+
and runs `actionlint -ignore 'SC2129' .github/workflows/cpflow-*.yml`.
3945

4046
## PR Checks
4147

@@ -77,8 +83,10 @@ Use the generated app name from the workflow log:
7783
APP_NAME: ${REVIEW_APP_PREFIX}-${PR_NUMBER}
7884
```
7985

80-
For this repo, verify the actual `REVIEW_APP_PREFIX` repository variable before
81-
assuming the final app name.
86+
This is a template from the workflow output, not a literal command to evaluate
87+
unless those environment variables are already set. For this repo, verify the
88+
actual `REVIEW_APP_PREFIX` repository variable before assuming the final app
89+
name.
8290

8391
## Troubleshooting Signals
8492

@@ -120,8 +128,8 @@ Create the first review app by commenting exactly:
120128

121129
- Add a no-secret GitHub Actions smoke workflow that loads generated local
122130
composite actions from the PR branch and fails fast on action metadata parsing.
123-
- Add a small repo script, for example `bin/test-cpflow-github-flow`, that wraps
124-
the local YAML, metadata-description, readiness, and `actionlint` checks.
131+
- Extend `bin/test-cpflow-github-flow` as more local cpflow GitHub Actions
132+
checks become worth standardizing.
125133
- Add an early token sanity step after `Setup environment` so invalid
126134
`CPLN_TOKEN_STAGING` and `CPLN_TOKEN_PRODUCTION` values fail with a named
127135
"validate Control Plane token" step instead of surfacing later during

.controlplane/readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ For this app, validate a regenerated flow with:
426426
```bash
427427
bin/conductor-exec ruby /path/to/control-plane-flow/bin/cpflow generate-github-actions --staging-branch master
428428
bin/conductor-exec ruby /path/to/control-plane-flow/bin/cpflow github-flow-readiness
429-
actionlint .github/workflows/cpflow-*.yml
429+
actionlint -ignore 'SC2129' .github/workflows/cpflow-*.yml
430430
bin/conductor-exec bundle exec rubocop
431431
```
432432

@@ -435,12 +435,17 @@ staging, lint, JS, and RSpec workflows before merging. For review-app workflow
435435
changes, test both the local workflow syntax and a real deployment. GitHub runs
436436
`issue_comment` workflows from the default branch, so a `+review-app-deploy`
437437
comment on the PR does not fully exercise command changes that are only on the
438-
PR branch. Before merge, run the PR branch workflow explicitly:
438+
PR branch. For top-level workflow edits, run the PR branch workflow explicitly:
439439

440440
```bash
441441
gh workflow run cpflow-deploy-review-app.yml --ref <branch> -f pr_number=<pr-number>
442442
```
443443

444+
This loads the workflow file from `<branch>`, but trusted local composite
445+
actions still come from the default branch before secrets are used. Treat it as
446+
a partial smoke test, then verify a real deploy after the workflow changes land
447+
on `master`.
448+
444449
After the workflow reports a review-app URL, verify the URL returns HTTP 200.
445450
If a project needs to track generator changes automatically, use a scheduled
446451
maintenance PR or Renovate-style workflow that bumps the `cpflow` version,

bin/test-cpflow-github-flow

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$ROOT"
6+
7+
cpflow_cmd=(cpflow)
8+
if [[ $# -gt 0 ]]; then
9+
cpflow_cmd=("$@")
10+
fi
11+
12+
echo "==> cpflow github-flow-readiness"
13+
bin/conductor-exec "${cpflow_cmd[@]}" github-flow-readiness
14+
15+
echo "==> parse generated GitHub Actions YAML"
16+
bin/conductor-exec ruby <<'RUBY'
17+
require "yaml"
18+
19+
Dir[".github/actions/**/action.yml", ".github/workflows/*.yml"].sort.each do |path|
20+
YAML.load_file(path, aliases: true)
21+
puts "parsed #{path}"
22+
end
23+
RUBY
24+
25+
echo "==> check composite action input descriptions"
26+
bin/conductor-exec ruby <<'RUBY'
27+
require "yaml"
28+
29+
bad = []
30+
Dir[".github/actions/**/action.yml"].sort.each do |path|
31+
doc = YAML.load_file(path, aliases: true)
32+
doc.fetch("inputs", {}).each do |name, spec|
33+
bad << "#{path}:#{name}" if spec["description"].to_s.include?("${{")
34+
end
35+
end
36+
37+
abort bad.join("\n") unless bad.empty?
38+
puts "no action metadata descriptions contain GitHub expressions"
39+
RUBY
40+
41+
echo "==> actionlint"
42+
actionlint -ignore "SC2129" .github/workflows/cpflow-*.yml

0 commit comments

Comments
 (0)