@crewhaus/migration-runner 0.3.0 → 0.3.2
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.
- package/package.json +5 -5
- package/templates/README.md +23 -0
- package/templates/crewhaus-upgrade.yml +88 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/migration-runner",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Batch-migrate every spec in a registry: dry-run + write, idempotent re-runs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"test": "bun test src"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@crewhaus/errors": "0.3.
|
|
19
|
-
"@crewhaus/migration-engine": "0.3.
|
|
20
|
-
"@crewhaus/spec-registry": "0.3.
|
|
18
|
+
"@crewhaus/errors": "0.3.2",
|
|
19
|
+
"@crewhaus/migration-engine": "0.3.2",
|
|
20
|
+
"@crewhaus/spec-registry": "0.3.2",
|
|
21
21
|
"yaml": "^2.6.0"
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"files": ["dist", "README.md", "LICENSE", "NOTICE"]
|
|
41
|
+
"files": ["dist", "templates", "README.md", "LICENSE", "NOTICE"]
|
|
42
42
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# migration-runner templates
|
|
2
|
+
|
|
3
|
+
Copy-in starting points for keeping a harness spec current with the CLI's spec
|
|
4
|
+
schema on a schedule. These are **templates, not active workflows** — nothing
|
|
5
|
+
in this directory runs from inside the factory repo.
|
|
6
|
+
|
|
7
|
+
- [`crewhaus-upgrade.yml`](crewhaus-upgrade.yml) — GitHub Actions cron template
|
|
8
|
+
(item 43). Copy it into your harness repository's `.github/workflows/` and
|
|
9
|
+
edit the `<PLACEHOLDER>` comments. On a schedule it:
|
|
10
|
+
|
|
11
|
+
1. installs the latest `crewhaus`,
|
|
12
|
+
2. runs `crewhaus upgrade crewhaus.yaml --dry-run` to detect spec version
|
|
13
|
+
drift against the CLI's current spec version,
|
|
14
|
+
3. when a migration is available, applies it with `--write` (each migrated
|
|
15
|
+
spec is validated with `parseSpec` before it can be written), and
|
|
16
|
+
4. opens a pull request with the migrated spec for human review.
|
|
17
|
+
|
|
18
|
+
Accepted migrations arrive as PRs — nothing is committed to the default
|
|
19
|
+
branch automatically.
|
|
20
|
+
|
|
21
|
+
The schedule (not on-push) is deliberate: a spec upgrade is driven by a **new
|
|
22
|
+
CLI version shipping a migration**, not by a change to your repo. Re-run
|
|
23
|
+
`crewhaus upgrade --dry-run` locally to reproduce a PR's diff.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# crewhaus-upgrade.yml — scheduled spec auto-migration TEMPLATE (item 43).
|
|
2
|
+
#
|
|
3
|
+
# This is a TEMPLATE, not an active workflow: copy it into your harness
|
|
4
|
+
# repository's `.github/workflows/` and edit the <PLACEHOLDER> comments.
|
|
5
|
+
#
|
|
6
|
+
# On a schedule it installs the latest `crewhaus`, runs `crewhaus upgrade` on
|
|
7
|
+
# your spec, and — when a newer CLI has shipped a migration your spec has not
|
|
8
|
+
# taken yet — opens a pull request with the migrated spec for human review.
|
|
9
|
+
# Accepted migrations arrive as PRs; nothing is ever committed to your default
|
|
10
|
+
# branch automatically.
|
|
11
|
+
#
|
|
12
|
+
# WHY A SCHEDULE (not on-push): a spec upgrade is driven by a NEW CLI VERSION,
|
|
13
|
+
# not by a change to your repo. The cron re-checks against the freshest CLI, so
|
|
14
|
+
# the day a migration ships you get a PR without touching your repo.
|
|
15
|
+
#
|
|
16
|
+
# Prerequisites:
|
|
17
|
+
# - Your spec lives at `<SPEC-PATH>` (default `crewhaus.yaml` at the repo root).
|
|
18
|
+
# - The workflow has permission to open PRs (see `permissions:` below).
|
|
19
|
+
|
|
20
|
+
name: crewhaus-upgrade
|
|
21
|
+
|
|
22
|
+
on:
|
|
23
|
+
schedule:
|
|
24
|
+
# <CRON> Weekly, Monday 07:23 UTC. `crewhaus upgrade` is a no-op when the
|
|
25
|
+
# spec is already current, so a more frequent cron is safe (it just exits
|
|
26
|
+
# "up-to-date" and opens no PR).
|
|
27
|
+
- cron: "23 7 * * 1"
|
|
28
|
+
# Manual trigger for an immediate check after a known CLI release.
|
|
29
|
+
workflow_dispatch: {}
|
|
30
|
+
|
|
31
|
+
# The PR-opening step needs write access to contents (to push the branch) and
|
|
32
|
+
# pull-requests (to open the PR). Nothing writes to the default branch directly.
|
|
33
|
+
permissions:
|
|
34
|
+
contents: write
|
|
35
|
+
pull-requests: write
|
|
36
|
+
|
|
37
|
+
jobs:
|
|
38
|
+
upgrade:
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
|
|
43
|
+
- name: Install the latest crewhaus
|
|
44
|
+
# Any channel works: npm i -g crewhaus, brew install crewhaus/tap/crewhaus, ...
|
|
45
|
+
# Pinning to @latest is deliberate — the schedule exists to pick up the
|
|
46
|
+
# newest migrations the day they ship.
|
|
47
|
+
run: npm install -g crewhaus@latest
|
|
48
|
+
|
|
49
|
+
- name: Check for a spec upgrade (dry-run)
|
|
50
|
+
id: check
|
|
51
|
+
# <SPEC-PATH> Point at your spec if it is not ./crewhaus.yaml.
|
|
52
|
+
# Exit code: 0 when up-to-date OR a clean migration is available; 1 only
|
|
53
|
+
# when a migration FAILS validation (a broken chain — a real alert).
|
|
54
|
+
# We capture the diff to decide whether to open a PR.
|
|
55
|
+
run: |
|
|
56
|
+
set -o pipefail
|
|
57
|
+
crewhaus upgrade crewhaus.yaml --dry-run | tee upgrade.out
|
|
58
|
+
if grep -q '^upgrade: v' upgrade.out; then
|
|
59
|
+
echo "has_upgrade=true" >> "$GITHUB_OUTPUT"
|
|
60
|
+
else
|
|
61
|
+
echo "has_upgrade=false" >> "$GITHUB_OUTPUT"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
- name: Apply the migration
|
|
65
|
+
if: steps.check.outputs.has_upgrade == 'true'
|
|
66
|
+
# --write rewrites the spec in place; every migrated spec was already
|
|
67
|
+
# validated by the dry-run above (upgrade validates via parseSpec before
|
|
68
|
+
# it will write), so this cannot land an unparseable spec.
|
|
69
|
+
run: crewhaus upgrade crewhaus.yaml --write
|
|
70
|
+
|
|
71
|
+
- name: Open a migration PR
|
|
72
|
+
if: steps.check.outputs.has_upgrade == 'true'
|
|
73
|
+
# <PR-ACTION> Uses peter-evans/create-pull-request to branch, commit the
|
|
74
|
+
# migrated spec, and open a PR. Pin to a full SHA in production.
|
|
75
|
+
uses: peter-evans/create-pull-request@v6
|
|
76
|
+
with:
|
|
77
|
+
commit-message: "chore(spec): migrate crewhaus.yaml to the current schema version"
|
|
78
|
+
branch: crewhaus/spec-upgrade
|
|
79
|
+
delete-branch: true
|
|
80
|
+
title: "Migrate crewhaus.yaml to the current spec schema version"
|
|
81
|
+
body: |
|
|
82
|
+
An updated `crewhaus` CLI shipped a spec migration this spec had not
|
|
83
|
+
taken. `crewhaus upgrade --write` applied it; the migrated spec was
|
|
84
|
+
validated with `parseSpec` before this PR was opened.
|
|
85
|
+
|
|
86
|
+
Review the diff and merge to adopt the new schema version. Re-run
|
|
87
|
+
`crewhaus upgrade --dry-run` locally to reproduce.
|
|
88
|
+
labels: automated,spec-migration
|