cpflow 6.0.1 → 6.1.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.agents/bin/README.md +3 -2
  3. data/.agents/bin/docs +2 -1
  4. data/.agents/bin/lint +2 -1
  5. data/.agents/shaka/bin/setup +6 -0
  6. data/.agents/shaka/bin/test +6 -0
  7. data/.agents/shaka/bin/validate +7 -0
  8. data/.agents/{agent-workflow.yml → shaka/config.yml} +1 -1
  9. data/.agents/shaka.md +3 -2
  10. data/.github/actions/cpflow-setup-environment/action.yml +1 -1
  11. data/.github/dependabot.yml +10 -5
  12. data/.github/scripts/deployment_lock.py +141 -0
  13. data/.github/workflows/claude-code-review.yml +1 -1
  14. data/.github/workflows/claude.yml +1 -1
  15. data/.github/workflows/command_docs.yml +1 -1
  16. data/.github/workflows/cpflow-cleanup-stale-review-apps.yml +1 -1
  17. data/.github/workflows/cpflow-delete-review-app.yml +2 -2
  18. data/.github/workflows/cpflow-deploy-review-app.yml +219 -95
  19. data/.github/workflows/cpflow-promote-staging-to-production.yml +1 -1
  20. data/.github/workflows/rspec-shared.yml +3 -3
  21. data/.github/workflows/rspec.yml +2 -2
  22. data/.github/workflows/rubocop.yml +1 -1
  23. data/.github/workflows/trigger-docs-site.yml +1 -1
  24. data/AGENTS.md +4 -4
  25. data/CHANGELOG.md +18 -1
  26. data/CONTRIBUTING.md +6 -2
  27. data/Gemfile.lock +15 -10
  28. data/cpflow.gemspec +1 -1
  29. data/docs/ci-automation.md +89 -8
  30. data/docs/commands.md +3 -1
  31. data/lib/command/apply_template.rb +12 -1
  32. data/lib/command/base.rb +10 -0
  33. data/lib/command/run.rb +7 -7
  34. data/lib/command/setup_app.rb +6 -1
  35. data/lib/core/bootstrap_image.rb +21 -0
  36. data/lib/core/controlplane.rb +7 -6
  37. data/lib/cpflow/version.rb +1 -1
  38. data/lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml +1 -1
  39. data/script/check_shell_scripts +3 -3
  40. metadata +11 -9
  41. data/.agents/bin/setup +0 -5
  42. data/.agents/bin/test +0 -5
  43. data/.agents/bin/validate +0 -6
  44. /data/.agents/{trusted-github-actors.yml → shaka/trusted-github-actors.yml} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5339d75233bef2f62028093b5037a44155a56d2c4f39741efbc4861c47848e86
4
- data.tar.gz: bd30c3c9da8a468b6e5cc9479ed6be3912066b70e03f021533a815498756f162
3
+ metadata.gz: e63ae5cf2a0e75d2a6f27b289092424ca29016cf750210f0ac97a479473673e8
4
+ data.tar.gz: 395893220380625ddde1e6617654ee283897b6c32e485ea96078d122db971c46
5
5
  SHA512:
6
- metadata.gz: 417be2b206c02fda8ff5f2374ba3874ebc61c05ac00af7a8ff163306f359a9f323c3af268fad415b3422603b59bb7d1572335af4e5de9b88a0a5a7e6659f485b
7
- data.tar.gz: 72f2e06d1325fc09028ad8454454fda8dfd0b8fa1a0a075050b5fe997b7ed1653d1abfcb5ccc35382caa1737325b40a52b4575de11d7f4a3707ccfc8d4e9803f
6
+ metadata.gz: 388c087c13843e60b978febb128ec02952f05beeb28efeef2e403f88d031c499381caa514160762752c116ee662320c9342147bfdf401be2b8a7d90b50e9766d
7
+ data.tar.gz: d91bedc9b2cffb416b1150061051deff0630b3667e4d05c5630ae15186aa560dccc4f1360b28c898521a991f5e289c86470b527bcf2a7548a99689b59d39e1d6
@@ -1,7 +1,8 @@
1
1
  # Agent Workflow Scripts
2
2
 
3
3
  Thin, repo-owned command wrappers. Shaka's typed contract uses `setup`,
4
- `validate`, and `test`; the remaining scripts are additional repository helpers.
4
+ `validate`, and `test`, which live in [`../shaka/bin/`](../shaka/bin/); the
5
+ scripts here are additional repository helpers.
5
6
  A script that is **absent** means that capability is n/a here.
6
7
 
7
8
  | Script | Purpose | This repo runs |
@@ -25,6 +26,6 @@ suffix for automatic inclusion. Declared paths must remain tracked and readable.
25
26
  Unlisted extensionless files and non-shell files are outside this check.
26
27
 
27
28
  Canonical typed Shaka policy lives in
28
- [`../agent-workflow.yml`](../agent-workflow.yml). The GitHub Actions dependency allowlist lives in
29
+ [`../shaka/config.yml`](../shaka/config.yml). The GitHub Actions dependency allowlist lives in
29
30
  [`../trusted-actions.yml`](../trusted-actions.yml). Additional agent-binding repository policy,
30
31
  including the release-QA runbook reference, lives in [`../../AGENTS.md`](../../AGENTS.md).
data/.agents/bin/docs CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # Check generated command docs are current.
3
3
  set -euo pipefail
4
- cd "$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)"
4
+ root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_PREFIX -u GIT_CEILING_DIRECTORIES git -C "$(dirname -- "$0")" rev-parse --show-toplevel) || exit $?
5
+ cd "$root"
5
6
  exec bundle exec rake check_command_docs
data/.agents/bin/lint CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # Lint / format check. Pass -A to autocorrect.
3
3
  set -euo pipefail
4
- cd "$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)"
4
+ root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_PREFIX -u GIT_CEILING_DIRECTORIES git -C "$(dirname -- "$0")" rev-parse --show-toplevel) || exit $?
5
+ cd "$root"
5
6
  exec bundle exec rubocop "$@"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ # Install dependencies.
3
+ set -euo pipefail
4
+ root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_PREFIX -u GIT_CEILING_DIRECTORIES git -C "$(dirname -- "$0")" rev-parse --show-toplevel) || exit $?
5
+ cd "$root"
6
+ exec bundle install
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ # Run the test suite. Extra args pass through to rspec.
3
+ set -euo pipefail
4
+ root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_PREFIX -u GIT_CEILING_DIRECTORIES git -C "$(dirname -- "$0")" rev-parse --show-toplevel) || exit $?
5
+ cd "$root"
6
+ exec bundle exec rspec "$@"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ # Pre-push gate: full local validation (run before pushing).
3
+ set -euo pipefail
4
+ root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_PREFIX -u GIT_CEILING_DIRECTORIES git -C "$(dirname -- "$0")" rev-parse --show-toplevel) || exit $?
5
+ cd "$root"
6
+ ./script/check_shell_scripts
7
+ exec bundle exec rake
@@ -14,4 +14,4 @@ merge:
14
14
  branches:
15
15
  name: "{login}-{host}/{issue}-{description}"
16
16
  wip:
17
- include_locations: false
17
+ include_checkout_path: false
data/.agents/shaka.md CHANGED
@@ -5,10 +5,11 @@ Shaka package / skill release: `0.1.0.pre.1`.
5
5
  ## Migration reference
6
6
 
7
7
  This repo pins its Shaka reader source to the revision containing the [migration
8
- procedure at `8431a718cfd91e9ce7cb4276baae076848e05d13`](https://github.com/shakacode/shaka/blob/8431a718cfd91e9ce7cb4276baae076848e05d13/skills/shaka/references/migration.md).
8
+ procedure at `1a62cbcbe21da241668b2b108bc8588de4058aee`](https://github.com/shakacode/shaka/blob/1a62cbcbe21da241668b2b108bc8588de4058aee/skills/shaka/references/migration.md).
9
9
  At that Shaka revision, `skills/shaka/lib/shaka/version.rb` defines the package
10
10
  release and `docs/settings.md` documents the typed seam. The migration procedure
11
- describes key changes and the two-step validation used for first adoption.
11
+ describes key changes, the two-step validation used for first adoption, and the
12
+ `seam upgrade` move to the `.agents/shaka/` layout this repository uses.
12
13
 
13
14
  ## Check configuration edits
14
15
 
@@ -84,7 +84,7 @@ runs:
84
84
  echo "ruby_version=${ruby_version}" >> "$GITHUB_OUTPUT"
85
85
 
86
86
  - name: Set up Ruby
87
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
87
+ uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
88
88
  with:
89
89
  ruby-version: ${{ steps.ruby-version.outputs.ruby_version }}
90
90
  working-directory: ${{ inputs.working_directory }}
@@ -1,10 +1,15 @@
1
1
  version: 2
2
2
  updates:
3
3
  - package-ecosystem: github-actions
4
- directory: "/"
5
- schedule:
6
- interval: weekly
7
- - package-ecosystem: github-actions
8
- directory: "/.github/actions/cpflow-setup-environment"
4
+ directories:
5
+ - "/"
6
+ - "/.github/actions/cpflow-setup-environment"
9
7
  schedule:
10
8
  interval: weekly
9
+ # Keep SHA-pinned actions current in one grouped weekly version PR.
10
+ open-pull-requests-limit: 1
11
+ groups:
12
+ action-updates:
13
+ applies-to: version-updates
14
+ patterns:
15
+ - "*"
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env python3
2
+ """Cross-runner deployment mutex. Interrupted owners retain their lock."""
3
+
4
+ import argparse
5
+ import hashlib
6
+ import json
7
+ import os
8
+ from pathlib import Path
9
+ import re
10
+ import subprocess
11
+ import sys
12
+ import urllib.error
13
+ import urllib.request
14
+
15
+
16
+ class LockError(Exception):
17
+ pass
18
+
19
+
20
+ class NoRedirect(urllib.request.HTTPRedirectHandler):
21
+ def redirect_request(self, req, fp, code, msg, headers, newurl):
22
+ return None
23
+
24
+
25
+ class DeploymentLock:
26
+ def __init__(self, org, app, owner, receipt):
27
+ for value in (org, app):
28
+ if not re.fullmatch(r"[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", value):
29
+ raise LockError("The org and app must be valid Control Plane names.")
30
+ if not owner or len(owner) > 200 or not owner.isprintable():
31
+ raise LockError("A printable deployment owner of at most 200 characters is required.")
32
+ self.org, self.app, self.owner = org, app, owner
33
+ self.receipt = Path(receipt)
34
+ self.name = "cpflow-deploy-lock-" + hashlib.sha256(app.encode()).hexdigest()[:32]
35
+ self.path = f"/org/{org}/secret/{self.name}"
36
+
37
+ def request(self, method, path, body=None):
38
+ token = os.environ.get("CPLN_TOKEN", "")
39
+ if not token:
40
+ raise LockError("CPLN_TOKEN is required for deployment locking.")
41
+ request = urllib.request.Request(
42
+ "https://api.cpln.io" + path,
43
+ data=json.dumps(body).encode() if body is not None else None,
44
+ headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
45
+ method=method,
46
+ )
47
+ try:
48
+ opener = urllib.request.build_opener(NoRedirect())
49
+ with opener.open(request, timeout=20) as response:
50
+ expected = {"POST": 201, "GET": 200, "DELETE": 202}[method]
51
+ if response.status != expected:
52
+ raise LockError(f"Lock {method} returned HTTP {response.status}; refusing to proceed.")
53
+ return json.load(response) if method == "GET" else None
54
+ except urllib.error.HTTPError as error:
55
+ raise LockError(f"Lock {method} returned HTTP {error.code}; lock may be held or inaccessible.") from None
56
+ except (OSError, ValueError):
57
+ raise LockError(f"Lock {method} did not complete reliably; retain any existing lock.") from None
58
+
59
+ def acquire(self):
60
+ if self.receipt.exists():
61
+ raise LockError("A lock receipt already exists; refusing to reuse another acquisition.")
62
+ # POST creates only; apply/PUT would overwrite another runner's ownership.
63
+ self.request("POST", f"/org/{self.org}/secret", {
64
+ "name": self.name,
65
+ "type": "opaque",
66
+ "description": "Deployment mutex; stop the recorded owner before manual recovery.",
67
+ "tags": {"cpflow/app": self.app, "cpflow/deploy-owner": self.owner},
68
+ "data": {"encoding": "plain", "payload": "deployment mutex"},
69
+ })
70
+ current = self.request("GET", self.path)
71
+ if (current.get("tags", {}).get("cpflow/app") != self.app
72
+ or current.get("tags", {}).get("cpflow/deploy-owner") != self.owner
73
+ or not isinstance(current.get("id"), str) or not current["id"]):
74
+ raise LockError("Created lock ownership could not be verified; retain it for inspection.")
75
+ receipt = {"org": self.org, "app": self.app, "owner": self.owner, "id": current["id"]}
76
+ fd = os.open(self.receipt, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
77
+ with os.fdopen(fd, "w") as handle:
78
+ json.dump(receipt, handle)
79
+ print("Acquired deployment lock for " + self.app, flush=True)
80
+
81
+ def release(self):
82
+ receipt = json.loads(self.receipt.read_text())
83
+ if not isinstance(receipt.get("id"), str) or not receipt["id"]:
84
+ raise LockError("Receipt has no verified resource identity; refusing to release.")
85
+ if {key: receipt.get(key) for key in ("org", "app", "owner")} != {
86
+ "org": self.org, "app": self.app, "owner": self.owner}:
87
+ raise LockError("Receipt belongs to another deployment; refusing to release.")
88
+ current = self.request("GET", self.path)
89
+ if (current.get("id") != receipt.get("id")
90
+ or current.get("tags", {}).get("cpflow/app") != self.app
91
+ or current.get("tags", {}).get("cpflow/deploy-owner") != self.owner):
92
+ raise LockError("Deployment lock ownership changed; refusing to release.")
93
+ self.request("DELETE", self.path)
94
+ self.receipt.unlink()
95
+ print("Released deployment lock for " + self.app, flush=True)
96
+
97
+
98
+ def main():
99
+ parser = argparse.ArgumentParser(description=__doc__, allow_abbrev=False)
100
+ parser.add_argument("operation", choices=("acquire", "release", "run"))
101
+ parser.add_argument("--org", required=True)
102
+ parser.add_argument("--app", required=True)
103
+ parser.add_argument("--owner", required=True)
104
+ parser.add_argument("--receipt", required=True)
105
+ options, command = parser.parse_known_args()
106
+ if options.operation == "run" and command[:1] != ["--"]:
107
+ parser.error("run requires a command after --.")
108
+ if command[:1] == ["--"]:
109
+ command = command[1:]
110
+ if (options.operation == "run") != bool(command):
111
+ parser.error("Only run accepts a command, and it requires one after --.")
112
+ lock = DeploymentLock(options.org, options.app, options.owner, options.receipt)
113
+ if options.operation == "release":
114
+ lock.release()
115
+ return 0
116
+ lock.acquire()
117
+ if options.operation == "acquire":
118
+ return 0
119
+ try:
120
+ result = subprocess.run(command, check=False)
121
+ except BaseException:
122
+ print("Deployment interrupted; retaining its lock for operator inspection.", file=sys.stderr)
123
+ raise
124
+ if result.returncode < 0:
125
+ raise LockError("Deployment terminated by signal; retaining its lock for operator inspection.")
126
+ if result.returncode != 0:
127
+ print("Deployment failed; remote work may still be running. Retaining its lock for operator inspection.",
128
+ file=sys.stderr)
129
+ return result.returncode
130
+ lock.release()
131
+ return result.returncode
132
+
133
+
134
+ if __name__ == "__main__":
135
+ try:
136
+ sys.exit(main())
137
+ except (LockError, OSError, ValueError) as error:
138
+ # API bodies, request headers and raw transport errors can contain credentials.
139
+ message = str(error) if isinstance(error, LockError) else type(error).__name__
140
+ print("Deployment lock failed: " + message, file=sys.stderr)
141
+ sys.exit(1)
@@ -24,7 +24,7 @@ jobs:
24
24
 
25
25
  - name: Run Claude Code Review
26
26
  id: claude-review
27
- uses: anthropics/claude-code-action@8251c103ac8c1d761882c86aba1412c7f583c844 # v1.0.213
27
+ uses: anthropics/claude-code-action@d535f5172dec02b204866b393d6b20b9b2aaf98d # v1.0.266
28
28
  env:
29
29
  CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
30
30
  with:
@@ -128,7 +128,7 @@ jobs:
128
128
 
129
129
  - name: Run Claude Code
130
130
  id: claude
131
- uses: anthropics/claude-code-action@8251c103ac8c1d761882c86aba1412c7f583c844 # v1.0.213
131
+ uses: anthropics/claude-code-action@d535f5172dec02b204866b393d6b20b9b2aaf98d # v1.0.266
132
132
  env:
133
133
  CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
134
134
  with:
@@ -19,7 +19,7 @@ jobs:
19
19
  with:
20
20
  persist-credentials: false
21
21
  - name: Set up Ruby
22
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
22
+ uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
23
23
  with:
24
24
  ruby-version: "3.2"
25
25
  bundler-cache: true
@@ -20,7 +20,7 @@ concurrency:
20
20
 
21
21
  jobs:
22
22
  cleanup:
23
- runs-on: ubuntu-latest
23
+ runs-on: ubuntu-24.04
24
24
  timeout-minutes: 30
25
25
  steps:
26
26
  - name: Checkout control-plane-flow actions
@@ -19,7 +19,7 @@ env:
19
19
 
20
20
  jobs:
21
21
  authorize-comment-command:
22
- runs-on: ubuntu-latest
22
+ runs-on: ubuntu-24.04
23
23
  timeout-minutes: 5
24
24
  permissions:
25
25
  actions: read
@@ -278,7 +278,7 @@ jobs:
278
278
  contains(fromJson('["+review-app-delete","+review-app-delete\n","+review-app-delete\r\n"]'), github.event.comment.body)) ||
279
279
  (github.event_name == 'pull_request_target' && github.event.action == 'closed') ||
280
280
  github.event_name == 'workflow_dispatch')
281
- runs-on: ubuntu-latest
281
+ runs-on: ubuntu-24.04
282
282
  timeout-minutes: 15
283
283
  concurrency:
284
284
  group: cpflow-review-app-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.pr_number }}