@rexezuge/tooling 1.14.0 → 1.15.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.
- package/README.md +42 -30
- package/dist/eslint-rules.d.ts.map +1 -1
- package/dist/eslint-rules.js +1 -1
- package/dist/eslint-rules.js.map +2 -2
- package/dist/eslint-strict.d.ts +2 -1
- package/dist/eslint-strict.d.ts.map +1 -1
- package/dist/eslint-strict.js +2 -1
- package/dist/eslint-strict.js.map +3 -3
- package/dist/manifest-validate.d.ts.map +1 -1
- package/dist/manifest-validate.js +1 -1
- package/dist/manifest-validate.js.map +3 -3
- package/dist/manifest.d.ts +21 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js.map +2 -2
- package/dist/scripts/backup/destinations.d.ts +40 -0
- package/dist/scripts/backup/destinations.d.ts.map +1 -0
- package/dist/scripts/backup/destinations.js +1 -0
- package/dist/scripts/backup/destinations.js.map +7 -0
- package/dist/scripts/backup/encrypt-backup.d.ts +5 -2
- package/dist/scripts/backup/encrypt-backup.d.ts.map +1 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -3
- package/dist/scripts/backup/encrypt-backup.js.map +3 -3
- package/dist/scripts/backup/naming.d.ts +1 -1
- package/dist/scripts/backup/naming.d.ts.map +1 -1
- package/dist/scripts/backup/naming.js +1 -1
- package/dist/scripts/backup/naming.js.map +3 -3
- package/dist/scripts/prepare-wrangler-config.d.ts.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -1
- package/dist/scripts/prepare-wrangler-config.js.map +3 -3
- package/dist/scripts/wrangler-config/resources.d.ts +11 -2
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +1 -1
- package/dist/scripts/wrangler-config/resources.js.map +3 -3
- package/dist/vitest-aliases.d.ts +7 -1
- package/dist/vitest-aliases.d.ts.map +1 -1
- package/dist/vitest-aliases.js +1 -1
- package/dist/vitest-aliases.js.map +3 -3
- package/dist/vitest-integration.d.ts.map +1 -1
- package/dist/vitest-integration.js +1 -1
- package/dist/vitest-integration.js.map +3 -3
- package/dist/vitest-repo.js +1 -1
- package/dist/vitest-repo.js.map +3 -3
- package/dist/vitest-web.js +1 -1
- package/dist/vitest-web.js.map +3 -3
- package/dist/vitest.d.ts +1 -1
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +1 -1
- package/dist/vitest.js.map +3 -3
- package/package.json +3 -3
- package/presets/tsconfig/web.json +2 -2
- package/schema/manifest.schema.json +28 -1
- package/src/eslint-rules.ts +4 -0
- package/src/eslint-strict.test.ts +29 -0
- package/src/eslint-strict.ts +36 -4
- package/src/github/dependabot.yml +14 -4
- package/src/github/workflows/backup-d1.yml +15 -0
- package/src/github/workflows/backup-main.yml +9 -126
- package/src/github/workflows/continuous-deployment.yml +11 -180
- package/src/github/workflows/continuous-integration.yml +9 -249
- package/src/github/workflows/scheduled-version-update.yml +8 -31
- package/src/github/workflows/upstream-sync.yml +8 -49
- package/src/manifest-validate.ts +31 -2
- package/src/manifest.test.ts +22 -0
- package/src/manifest.ts +22 -0
- package/src/presets.test.ts +5 -1
- package/src/scripts/backup/backup-rules.test.ts +22 -0
- package/src/scripts/backup/destinations.ts +59 -0
- package/src/scripts/backup/encrypt-backup.ts +58 -48
- package/src/scripts/backup/naming.ts +2 -2
- package/src/scripts/prepare-wrangler-config.ts +9 -1
- package/src/scripts/wrangler-config/resources.test.ts +10 -0
- package/src/scripts/wrangler-config/resources.ts +21 -4
- package/src/vitest-aliases.test.ts +33 -0
- package/src/vitest-aliases.ts +37 -7
- package/src/vitest-integration.ts +2 -5
- package/src/vitest-repo.ts +2 -2
- package/src/vitest-web.ts +2 -2
- package/src/vitest.ts +3 -3
- package/src/github/actions/retry-step/action.yml +0 -55
- package/src/github/actions/setup-env/action.yml +0 -20
|
@@ -1,259 +1,19 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# The most-common superset of the nine repos' CI workflows. Each job exists because
|
|
4
|
-
# its failure is invisible to every other job: a locale defect still typechecks, a
|
|
5
|
-
# god file still lints, an edited migration still deploys. A job per gate means the
|
|
6
|
-
# run log names the tool that broke rather than burying it in a `checks` job.
|
|
7
|
-
#
|
|
8
|
-
# PLACEHOLDERS — the things a consumer must change for this to run at all:
|
|
9
|
-
# * REPLACE_ME_SCOPE the npm scope, in the `pnpm --filter @REPLACE_ME_SCOPE/web build`
|
|
10
|
-
# invocations below.
|
|
11
|
-
# * REPLACE_ME_WEB_FILTER the workspace filter for the SPA (usually @REPLACE_ME_SCOPE/web).
|
|
12
|
-
# * REPLACE_ME_MIGRATIONS the D1 binding `wrangler d1 migrations apply` targets.
|
|
13
|
-
#
|
|
14
|
-
# The script names in the `run:` steps are the ones this package's scripts suggest;
|
|
15
|
-
# see README.md for the package.json wiring.
|
|
16
|
-
|
|
1
|
+
# A thin caller: the pipeline lives in Rexezuge-CloudflareWorkers/SDK/.github/workflows/worker-ci.yml (tag v1).
|
|
2
|
+
# Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.
|
|
17
3
|
name: Continuous Integration
|
|
18
4
|
|
|
19
|
-
permissions:
|
|
20
|
-
contents: read
|
|
21
|
-
|
|
22
5
|
on:
|
|
23
|
-
repository_dispatch:
|
|
24
|
-
types:
|
|
25
|
-
- Upstream Sync Integration
|
|
26
|
-
pull_request:
|
|
27
6
|
push:
|
|
28
|
-
branches:
|
|
29
|
-
|
|
7
|
+
branches: [main]
|
|
8
|
+
pull_request:
|
|
9
|
+
repository_dispatch:
|
|
10
|
+
types: [upstream-sync]
|
|
30
11
|
workflow_dispatch:
|
|
31
12
|
|
|
32
|
-
concurrency:
|
|
33
|
-
group: continuous-integration-${{ github.ref }}
|
|
34
|
-
cancel-in-progress: true
|
|
35
|
-
|
|
36
13
|
jobs:
|
|
37
|
-
|
|
38
|
-
# nothing but a checkout while the gates are read-only consumers of the tree.
|
|
39
|
-
checks:
|
|
40
|
-
name: Checks
|
|
41
|
-
runs-on: ubuntu-latest
|
|
42
|
-
|
|
43
|
-
steps:
|
|
44
|
-
- name: Checkout Repository
|
|
45
|
-
uses: actions/checkout@v6
|
|
46
|
-
|
|
47
|
-
- name: Setup Environment
|
|
48
|
-
uses: ./.github/actions/setup-env
|
|
49
|
-
|
|
50
|
-
# `pnpm -r typecheck` reaches every workspace package, `test/` among them.
|
|
51
|
-
- name: Run Type Check and Lint
|
|
52
|
-
run: pnpm -r typecheck && pnpm run lint
|
|
53
|
-
|
|
54
|
-
# Its own step, and read-only, because the `lint` job cannot catch this:
|
|
55
|
-
# `pnpm run lint` is `eslint --fix --quiet`, and `--fix` repairs what it can
|
|
56
|
-
# while `--quiet` suppresses the rest — so CI exits 0 on a tree Prettier
|
|
57
|
-
# rejects, the repairs land in the runner's checkout, and they are thrown
|
|
58
|
-
# away. `prettier --check` is the one command that fails instead of
|
|
59
|
-
# repairing. Edge-Sonic had 242 files in exactly that state.
|
|
60
|
-
- name: Check Formatting
|
|
61
|
-
run: pnpm run format:check
|
|
62
|
-
|
|
63
|
-
- name: Check God-Files
|
|
64
|
-
uses: ./.github/actions/retry-step
|
|
65
|
-
with:
|
|
66
|
-
command: pnpm run check:god-files
|
|
67
|
-
max_attempts: '2'
|
|
68
|
-
|
|
69
|
-
# A locale defect is invisible to the unit tests: the catalogs are data, and
|
|
70
|
-
# a key missing from every bundle still typechecks and still builds.
|
|
71
|
-
- name: Validate Locale Bundles
|
|
72
|
-
uses: ./.github/actions/retry-step
|
|
73
|
-
with:
|
|
74
|
-
command: pnpm run validate:locales
|
|
75
|
-
max_attempts: '2'
|
|
76
|
-
|
|
77
|
-
# Editing an already-applied migration is invisible to every other check:
|
|
78
|
-
# the deploy succeeds, fresh databases pick up the edited statements, and
|
|
79
|
-
# production keeps the schema it had. The lock is what turns that into a
|
|
80
|
-
# failure, and this job is read-only — `migrations-lock` is the operator's
|
|
81
|
-
# command, deliberately not CI's.
|
|
82
|
-
- name: Verify Migration Lock
|
|
83
|
-
uses: ./.github/actions/retry-step
|
|
84
|
-
with:
|
|
85
|
-
command: pnpm run validate:migrations
|
|
86
|
-
max_attempts: '2'
|
|
87
|
-
|
|
88
|
-
unit-tests:
|
|
89
|
-
name: Unit Tests
|
|
90
|
-
runs-on: ubuntu-latest
|
|
91
|
-
|
|
92
|
-
steps:
|
|
93
|
-
- name: Checkout Repository
|
|
94
|
-
uses: actions/checkout@v6
|
|
95
|
-
|
|
96
|
-
- name: Setup Environment
|
|
97
|
-
uses: ./.github/actions/setup-env
|
|
98
|
-
|
|
99
|
-
- name: Run Tests with Coverage
|
|
100
|
-
uses: ./.github/actions/retry-step
|
|
101
|
-
with:
|
|
102
|
-
command: pnpm run test:coverage
|
|
103
|
-
max_attempts: '2'
|
|
104
|
-
|
|
105
|
-
- name: Upload Coverage Report
|
|
106
|
-
if: always()
|
|
107
|
-
uses: actions/upload-artifact@v4
|
|
108
|
-
with:
|
|
109
|
-
name: coverage-report
|
|
110
|
-
path: coverage/
|
|
111
|
-
retention-days: 14
|
|
112
|
-
|
|
113
|
-
# The SPA's own suite. Only repositories with a Vite SPA keep this job; the two
|
|
114
|
-
# configs partition the suite rather than each running all of it, so a jsdom
|
|
115
|
-
# suite under `node` cannot pass while failing.
|
|
116
|
-
web-tests:
|
|
117
|
-
name: Web Tests
|
|
118
|
-
runs-on: ubuntu-latest
|
|
119
|
-
|
|
120
|
-
steps:
|
|
121
|
-
- name: Checkout Repository
|
|
122
|
-
uses: actions/checkout@v6
|
|
123
|
-
|
|
124
|
-
- name: Setup Environment
|
|
125
|
-
uses: ./.github/actions/setup-env
|
|
126
|
-
|
|
127
|
-
- name: Run SPA Unit Tests
|
|
128
|
-
run: pnpm run test:web
|
|
129
|
-
|
|
130
|
-
integration-tests:
|
|
131
|
-
name: Integration Tests
|
|
132
|
-
runs-on: ubuntu-latest
|
|
133
|
-
|
|
134
|
-
steps:
|
|
135
|
-
- name: Checkout Repository
|
|
136
|
-
uses: actions/checkout@v6
|
|
137
|
-
|
|
138
|
-
- name: Setup Environment
|
|
139
|
-
uses: ./.github/actions/setup-env
|
|
140
|
-
|
|
141
|
-
- name: Run Integration Tests
|
|
142
|
-
run: pnpm run test:integration
|
|
143
|
-
|
|
144
|
-
# Only the SPA build. The API worker is typechecked by `pnpm -r typecheck` above,
|
|
145
|
-
# so repeating it here would run the same `tsc --noEmit` against the same
|
|
146
|
-
# tsconfig a second time.
|
|
147
|
-
build:
|
|
148
|
-
name: Build Web App
|
|
149
|
-
runs-on: ubuntu-latest
|
|
150
|
-
|
|
151
|
-
steps:
|
|
152
|
-
- name: Checkout Repository
|
|
153
|
-
uses: actions/checkout@v6
|
|
154
|
-
|
|
155
|
-
- name: Setup Environment
|
|
156
|
-
uses: ./.github/actions/setup-env
|
|
157
|
-
|
|
158
|
-
# PLACEHOLDER: the workspace filter for the SPA.
|
|
159
|
-
- name: Build Web App
|
|
160
|
-
run: pnpm --filter @REPLACE_ME_SCOPE/web build
|
|
161
|
-
|
|
162
|
-
# Verifies the shell the API worker *serves*, which is a different artifact from
|
|
163
|
-
# `apps/web/dist/` — it is embedded into `apps/api/src/generated/spa-shell.ts` by
|
|
164
|
-
# the Vite plugin, and both are gitignored. A stale-but-present shell is a deploy
|
|
165
|
-
# that serves yesterday's operator UI.
|
|
166
|
-
#
|
|
167
|
-
# It builds first rather than depending on `build`, so the failure says "the
|
|
168
|
-
# served shell is wrong" instead of arriving inside a build log. That costs a
|
|
169
|
-
# second Vite build per run; the alternative — verifying inside `build` — is free
|
|
170
|
-
# and is the trade being made here.
|
|
171
|
-
spa-shell:
|
|
172
|
-
name: Verify SPA Shell
|
|
173
|
-
runs-on: ubuntu-latest
|
|
174
|
-
|
|
175
|
-
steps:
|
|
176
|
-
- name: Checkout Repository
|
|
177
|
-
uses: actions/checkout@v6
|
|
178
|
-
|
|
179
|
-
- name: Setup Environment
|
|
180
|
-
uses: ./.github/actions/setup-env
|
|
181
|
-
|
|
182
|
-
# PLACEHOLDER: the workspace filter for the SPA.
|
|
183
|
-
- name: Build Web App
|
|
184
|
-
run: pnpm --filter @REPLACE_ME_SCOPE/web build
|
|
185
|
-
|
|
186
|
-
# The build is a **precondition**, not a convenience: a fresh checkout has
|
|
187
|
-
# neither `apps/web/dist/` nor `apps/api/src/generated/`, and postinstall
|
|
188
|
-
# writes a deliberately empty stub so `tsc` can resolve `SPA_HTML` before
|
|
189
|
-
# anyone has built. Verifying without building cannot pass, and it fails
|
|
190
|
-
# with precisely the message the check exists to give.
|
|
191
|
-
- name: Verify The SPA Shell
|
|
192
|
-
uses: ./.github/actions/retry-step
|
|
193
|
-
with:
|
|
194
|
-
command: pnpm run verify:spa-shell
|
|
195
|
-
max_attempts: '2'
|
|
196
|
-
|
|
197
|
-
dependabot-auto-merge:
|
|
198
|
-
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.state == 'open' && !github.event.repository.fork }}
|
|
199
|
-
name: Auto-Merge Dependabot PR
|
|
200
|
-
needs:
|
|
201
|
-
- checks
|
|
202
|
-
- unit-tests
|
|
203
|
-
- web-tests
|
|
204
|
-
- integration-tests
|
|
205
|
-
- build
|
|
206
|
-
- spa-shell
|
|
14
|
+
worker-ci:
|
|
207
15
|
permissions:
|
|
208
16
|
contents: write
|
|
209
17
|
pull-requests: write
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
steps:
|
|
213
|
-
- name: Checkout Repository
|
|
214
|
-
uses: actions/checkout@v6
|
|
215
|
-
|
|
216
|
-
# Auto-merge only after every gate above is green, which is what makes it
|
|
217
|
-
# safe: a dependency bump that breaks the suite waits for a human instead of
|
|
218
|
-
# merging itself.
|
|
219
|
-
- name: Enable Auto-Merge
|
|
220
|
-
uses: ./.github/actions/retry-step
|
|
221
|
-
with:
|
|
222
|
-
command: gh pr merge --auto --merge "$PR_URL"
|
|
223
|
-
max_attempts: '5'
|
|
224
|
-
env:
|
|
225
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
226
|
-
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
227
|
-
|
|
228
|
-
dispatch-upstream-sync-deployment:
|
|
229
|
-
if: ${{ github.event_name == 'repository_dispatch' && github.event.action == 'Upstream Sync Integration' }}
|
|
230
|
-
name: Dispatch Upstream Sync Deployment
|
|
231
|
-
needs:
|
|
232
|
-
- checks
|
|
233
|
-
- unit-tests
|
|
234
|
-
- web-tests
|
|
235
|
-
- integration-tests
|
|
236
|
-
- build
|
|
237
|
-
- spa-shell
|
|
238
|
-
permissions:
|
|
239
|
-
contents: write
|
|
240
|
-
runs-on: ubuntu-latest
|
|
241
|
-
|
|
242
|
-
steps:
|
|
243
|
-
- name: Checkout Repository
|
|
244
|
-
uses: actions/checkout@v6
|
|
245
|
-
|
|
246
|
-
# The second half of the upstream-sync contract: a fork's sync runs CI, and
|
|
247
|
-
# CI — not the sync workflow — is what authorises the deploy.
|
|
248
|
-
- name: Dispatch Deployment
|
|
249
|
-
uses: ./.github/actions/retry-step
|
|
250
|
-
with:
|
|
251
|
-
command: >
|
|
252
|
-
printf '{"event_type":"Upstream Sync Deployment","client_payload":{"branch":"%s","sha":"%s"}}\n'
|
|
253
|
-
"$PAYLOAD_BRANCH" "$PAYLOAD_SHA"
|
|
254
|
-
| gh api repos/${{ github.repository }}/dispatches --method POST --input -
|
|
255
|
-
max_attempts: '2'
|
|
256
|
-
env:
|
|
257
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
258
|
-
PAYLOAD_BRANCH: ${{ github.event.client_payload.branch || 'main' }}
|
|
259
|
-
PAYLOAD_SHA: ${{ github.event.client_payload.sha || github.sha }}
|
|
18
|
+
uses: Rexezuge-CloudflareWorkers/SDK/.github/workflows/worker-ci.yml@v1
|
|
19
|
+
secrets: inherit
|
|
@@ -1,38 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# The stamp is the family's cache-buster: the CD workflow reads it, and the
|
|
4
|
-
# backup workflows use it in branch names. Forked repos skip the schedule
|
|
5
|
-
# (`if: !github.event.repository.fork`) because a fork must not race its
|
|
6
|
-
# upstream's push.
|
|
7
|
-
|
|
1
|
+
# A thin caller: the pipeline lives in Rexezuge-CloudflareWorkers/SDK/.github/workflows/version-update.yml (tag v1).
|
|
2
|
+
# Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.
|
|
8
3
|
name: Scheduled Version Update
|
|
9
4
|
|
|
10
5
|
on:
|
|
11
6
|
schedule:
|
|
12
7
|
- cron: '0 0 1,15 * *'
|
|
13
|
-
|
|
14
|
-
permissions:
|
|
15
|
-
contents: write
|
|
8
|
+
workflow_dispatch:
|
|
16
9
|
|
|
17
10
|
jobs:
|
|
18
|
-
update
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- name: Checkout Repository
|
|
24
|
-
uses: actions/checkout@v6
|
|
25
|
-
with:
|
|
26
|
-
persist-credentials: true
|
|
27
|
-
|
|
28
|
-
- name: Write Current Unix Timestamp
|
|
29
|
-
run: date +%s > .github/.version
|
|
30
|
-
|
|
31
|
-
- name: Commit and Push
|
|
32
|
-
run: |
|
|
33
|
-
git config user.name "github-actions[bot]"
|
|
34
|
-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
35
|
-
|
|
36
|
-
git add .github/.version
|
|
37
|
-
git diff --staged --quiet || git commit -m "chore: update .version stamp"
|
|
38
|
-
git push
|
|
11
|
+
version-update:
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
uses: Rexezuge-CloudflareWorkers/SDK/.github/workflows/version-update.yml@v1
|
|
15
|
+
secrets: inherit
|
|
@@ -1,56 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Converged from eight repos (all but Records-Provider and CalDAV-Bridge ship this
|
|
4
|
-
# file, and the two that differ do so only in the upstream repository name).
|
|
5
|
-
#
|
|
6
|
-
# The contract has two sides and they change in the same commit: this workflow
|
|
7
|
-
# publishes `Upstream Sync Integration`, and continuous-integration.yml listens for
|
|
8
|
-
# it. The event is named `Upstream Sync Integration` rather than `Upstream Sync`
|
|
9
|
-
# precisely so it cannot be confused with the `Upstream Sync Deployment` event the
|
|
10
|
-
# deploy workflow listens for — one sync, two dispatches, and the name is what keeps
|
|
11
|
-
# a reader from wiring the wrong one.
|
|
12
|
-
|
|
1
|
+
# A thin caller: the pipeline lives in Rexezuge-CloudflareWorkers/SDK/.github/workflows/upstream-sync.yml (tag v1).
|
|
2
|
+
# Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.
|
|
13
3
|
name: Upstream Sync
|
|
14
4
|
|
|
15
5
|
on:
|
|
16
6
|
schedule:
|
|
17
|
-
|
|
18
|
-
# workflows that share a minute with high-traffic crons.
|
|
19
|
-
- cron: '0 2 * * 1'
|
|
7
|
+
- cron: '17 2 * * 1'
|
|
20
8
|
workflow_dispatch:
|
|
21
9
|
|
|
22
|
-
permissions:
|
|
23
|
-
contents: write
|
|
24
|
-
|
|
25
10
|
jobs:
|
|
26
|
-
sync:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
steps:
|
|
32
|
-
- name: Checkout Repository
|
|
33
|
-
uses: actions/checkout@v6
|
|
34
|
-
|
|
35
|
-
# Pinned by commit rather than a tag: this action writes a config file and
|
|
36
|
-
# fetches a binary onto the runner, so a moved tag is a supply-chain change
|
|
37
|
-
# arriving through a version bump nobody reviewed.
|
|
38
|
-
- name: Sync Changes
|
|
39
|
-
id: sync
|
|
40
|
-
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
|
|
41
|
-
with:
|
|
42
|
-
# PLACEHOLDER: the upstream repository this one forks, as owner/name.
|
|
43
|
-
upstream_sync_repo: REPLACE_ME_ORG/REPLACE_ME_REPO
|
|
44
|
-
upstream_sync_branch: main
|
|
45
|
-
target_sync_branch: main
|
|
46
|
-
target_repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
47
|
-
test_mode: false
|
|
48
|
-
|
|
49
|
-
- name: Trigger Continuous Integration
|
|
50
|
-
if: steps.sync.outputs.has_new_commits == 'true'
|
|
51
|
-
uses: ./.github/actions/retry-step
|
|
52
|
-
with:
|
|
53
|
-
command: gh api repos/${{ github.repository }}/dispatches --method POST -f event_type='Upstream Sync Integration'
|
|
54
|
-
max_attempts: '2'
|
|
55
|
-
env:
|
|
56
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
11
|
+
upstream-sync:
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
uses: Rexezuge-CloudflareWorkers/SDK/.github/workflows/upstream-sync.yml@v1
|
|
15
|
+
secrets: inherit
|
package/src/manifest-validate.ts
CHANGED
|
@@ -56,10 +56,28 @@ class Check {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const BINDING_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
60
|
+
|
|
61
|
+
function checkKv(c: Check, value: unknown): void {
|
|
62
|
+
const kv = c.obj('features.kv', value);
|
|
63
|
+
if (!kv) return;
|
|
64
|
+
c.keys('features.kv', kv, ['bindings', 'namespaceNames']);
|
|
65
|
+
const bindings = c.strings('features.kv.bindings', kv.bindings) ? kv.bindings : [];
|
|
66
|
+
for (const binding of bindings) c.str('features.kv.bindings', binding, BINDING_RE, 'an UPPER_SNAKE binding name');
|
|
67
|
+
if (kv.namespaceNames === undefined) return;
|
|
68
|
+
const names = c.obj('features.kv.namespaceNames', kv.namespaceNames);
|
|
69
|
+
if (!names) return;
|
|
70
|
+
for (const [binding, name] of Object.entries(names)) {
|
|
71
|
+
const at = `features.kv.namespaceNames.${binding}`;
|
|
72
|
+
if (!bindings.includes(binding)) c.fail(at, 'is not listed in features.kv.bindings');
|
|
73
|
+
c.str(at, name);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
function checkFeatures(c: Check, value: unknown): void {
|
|
60
78
|
const features = c.obj('features', value);
|
|
61
79
|
if (!features) return;
|
|
62
|
-
c.keys('features', features, ['d1', 'web', 'background', 'backupD1', 'durableObjects', 'queues', 'workflows', 'email', 'android']);
|
|
80
|
+
c.keys('features', features, ['d1', 'kv', 'web', 'background', 'backupD1', 'durableObjects', 'queues', 'workflows', 'email', 'android']);
|
|
63
81
|
if (features.d1 !== undefined) {
|
|
64
82
|
const d1 = c.obj('features.d1', features.d1);
|
|
65
83
|
if (d1) {
|
|
@@ -69,12 +87,23 @@ function checkFeatures(c: Check, value: unknown): void {
|
|
|
69
87
|
if (d1.migrationsDir !== undefined) c.str('features.d1.migrationsDir', d1.migrationsDir);
|
|
70
88
|
}
|
|
71
89
|
}
|
|
90
|
+
if (features.kv !== undefined) checkKv(c, features.kv);
|
|
72
91
|
if (features.web !== undefined) {
|
|
73
92
|
const web = c.obj('features.web', features.web);
|
|
74
93
|
if (web) {
|
|
75
|
-
c.keys('features.web', web, ['pages', 'spaShell']);
|
|
94
|
+
c.keys('features.web', web, ['pages', 'spaShell', 'buildScript', 'pagesProject']);
|
|
76
95
|
c.bool('features.web.pages', web.pages);
|
|
77
96
|
c.bool('features.web.spaShell', web.spaShell);
|
|
97
|
+
if (web.buildScript !== undefined)
|
|
98
|
+
c.str('features.web.buildScript', web.buildScript, /^[\w:.-]+$/, 'a root package.json script name');
|
|
99
|
+
if (web.pagesProject !== undefined) {
|
|
100
|
+
c.str(
|
|
101
|
+
'features.web.pagesProject',
|
|
102
|
+
web.pagesProject,
|
|
103
|
+
/^[a-z0-9][a-z0-9-]{0,57}$/,
|
|
104
|
+
'lower-case letters, digits and hyphens, at most 58',
|
|
105
|
+
);
|
|
106
|
+
}
|
|
78
107
|
}
|
|
79
108
|
}
|
|
80
109
|
for (const flag of ['background', 'backupD1', 'email', 'android'] as const) {
|
package/src/manifest.test.ts
CHANGED
|
@@ -131,6 +131,28 @@ describe('validateManifest', () => {
|
|
|
131
131
|
expect(errorsOf({ ...MINIMAL, extensions: [] })).toEqual(['extensions: must be an object']);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
+
it('validates features.kv: UPPER_SNAKE bindings, namespace names only for declared bindings', () => {
|
|
135
|
+
expect(errorsOf({ ...MINIMAL, features: { kv: { bindings: ['CACHE'], namespaceNames: { CACHE: 'old-cache' } } } })).toEqual([]);
|
|
136
|
+
expect(errorsOf({ ...MINIMAL, features: { kv: { bindings: [] } } })).toEqual([]);
|
|
137
|
+
const errors = errorsOf({ ...MINIMAL, features: { kv: { bindings: ['cache'], namespaceNames: { OTHER: 'x', CACHE: '' }, extra: 1 } } });
|
|
138
|
+
expect(errors).toEqual(
|
|
139
|
+
expect.arrayContaining([
|
|
140
|
+
expect.stringContaining('features.kv.bindings: "cache" is invalid'),
|
|
141
|
+
expect.stringContaining('features.kv.extra: unknown key'),
|
|
142
|
+
expect.stringContaining('features.kv.namespaceNames.OTHER: is not listed'),
|
|
143
|
+
]),
|
|
144
|
+
);
|
|
145
|
+
expect(errorsOf({ ...MINIMAL, features: { kv: { bindings: 'CACHE', namespaceNames: [] } } })).toHaveLength(2);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('validates the SPA build script and the Pages project name', () => {
|
|
149
|
+
const web = (fields: object): string[] => errorsOf({ ...MINIMAL, features: { web: { pages: true, spaShell: false, ...fields } } });
|
|
150
|
+
expect(web({ buildScript: 'build:web', pagesProject: 'my-app-web' })).toEqual([]);
|
|
151
|
+
expect(web({ buildScript: 'build web; rm -rf /' })).toEqual([expect.stringContaining('features.web.buildScript')]);
|
|
152
|
+
expect(web({ pagesProject: 'My_App' })).toEqual([expect.stringContaining('features.web.pagesProject')]);
|
|
153
|
+
expect(web({ pagesProject: '' })).toEqual([expect.stringContaining('features.web.pagesProject')]);
|
|
154
|
+
});
|
|
155
|
+
|
|
134
156
|
it('checks feature value types', () => {
|
|
135
157
|
const errors = errorsOf({
|
|
136
158
|
...MINIMAL,
|
package/src/manifest.ts
CHANGED
|
@@ -37,6 +37,18 @@ export interface ManifestD1 {
|
|
|
37
37
|
readonly migrationsDir?: string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export interface ManifestKv {
|
|
41
|
+
/**
|
|
42
|
+
KV binding names the deployment needs (UPPER_SNAKE). `prepare-wrangler` adds any a hand-written config lacks and provisions
|
|
43
|
+
their namespaces; a repo that declares none gets no KV binding and no namespace.
|
|
44
|
+
*/
|
|
45
|
+
readonly bindings: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
Binding to namespace name, for a namespace that predates the kit's `<worker>-<binding>` convention. Keys must be listed in `bindings`.
|
|
48
|
+
*/
|
|
49
|
+
readonly namespaceNames?: Readonly<Record<string, string>>;
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
export interface ManifestWeb {
|
|
41
53
|
/**
|
|
42
54
|
The SPA is served by Cloudflare Pages.
|
|
@@ -46,10 +58,20 @@ export interface ManifestWeb {
|
|
|
46
58
|
The SPA shell is embedded into the worker (`spa-shell` scripts).
|
|
47
59
|
*/
|
|
48
60
|
readonly spaShell: boolean;
|
|
61
|
+
/**
|
|
62
|
+
A **root** `package.json` script that builds the SPA, for a repo whose build has wrappers (`verify:tailwind && build`).
|
|
63
|
+
CI and CD run `pnpm run <script>` instead of `pnpm --filter <scope>/web run build`.
|
|
64
|
+
*/
|
|
65
|
+
readonly buildScript?: string;
|
|
66
|
+
/**
|
|
67
|
+
The Cloudflare Pages project, when it is not `<name>-web`. Wins over the `CLOUDFLARE_PAGES_PROJECT_NAME` variable.
|
|
68
|
+
*/
|
|
69
|
+
readonly pagesProject?: string;
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
export interface ManifestFeatures {
|
|
52
73
|
readonly d1?: ManifestD1;
|
|
74
|
+
readonly kv?: ManifestKv;
|
|
53
75
|
readonly web?: ManifestWeb;
|
|
54
76
|
readonly background?: boolean;
|
|
55
77
|
readonly backupD1?: boolean;
|
package/src/presets.test.ts
CHANGED
|
@@ -32,7 +32,11 @@ describe('tsconfig presets', () => {
|
|
|
32
32
|
expect(worker.extends).toBe('./base.json');
|
|
33
33
|
expect(web.extends).toBe('./base.json');
|
|
34
34
|
expect(worker.compilerOptions['lib']).toEqual(['ES2022', 'DOM']);
|
|
35
|
-
expect(web.compilerOptions).toMatchObject({ jsx: 'react-jsx', target: '
|
|
35
|
+
expect(web.compilerOptions).toMatchObject({ jsx: 'react-jsx', target: 'ES2022', lib: ['ES2022', 'DOM', 'DOM.Iterable'] });
|
|
36
|
+
// The SPA type-checks the shared contracts package, so it may never be behind the base on target or lib.
|
|
37
|
+
expect(web.compilerOptions['target']).toBe(base['target']);
|
|
38
|
+
expect(web.compilerOptions['lib']).toEqual(expect.arrayContaining(base['lib'] as string[]));
|
|
39
|
+
expect(worker.compilerOptions['lib']).toEqual(base['lib']);
|
|
36
40
|
});
|
|
37
41
|
});
|
|
38
42
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import { resolveD1Target } from './d1-target.ts';
|
|
3
3
|
import { evaluateConfig } from './destination-config.ts';
|
|
4
|
+
import { backupPrefix, isBackupArtifact, parseS3ListRow, shouldDeleteBackup, webdavTargetDir } from './destinations.ts';
|
|
4
5
|
import { backupFileName, backupStamp, requireRetentionDays, retentionCutoff } from './naming.ts';
|
|
5
6
|
|
|
6
7
|
describe('resolveD1Target', () => {
|
|
@@ -103,3 +104,24 @@ describe('naming', () => {
|
|
|
103
104
|
}
|
|
104
105
|
});
|
|
105
106
|
});
|
|
107
|
+
|
|
108
|
+
describe('destinations', () => {
|
|
109
|
+
it('prefixes every backup with the repo name, and only prunes backup artifacts older than the cutoff', () => {
|
|
110
|
+
expect(backupPrefix('mail-meow')).toBe('mail-meow/production');
|
|
111
|
+
expect(parseS3ListRow('2026-01-02 03:04:05 123 backup_prod_x.sql.xz.enc')).toStrictEqual({
|
|
112
|
+
fileDate: '2026-01-02',
|
|
113
|
+
fileName: 'backup_prod_x.sql.xz.enc',
|
|
114
|
+
});
|
|
115
|
+
expect(parseS3ListRow('PRE nested/')).toBeUndefined();
|
|
116
|
+
const old = { fileDate: '2026-01-01', fileName: 'a.sql.xz.enc' };
|
|
117
|
+
expect(shouldDeleteBackup(old, '2026-01-02')).toBe(true);
|
|
118
|
+
expect(shouldDeleteBackup(old, '2026-01-01')).toBe(false);
|
|
119
|
+
expect(shouldDeleteBackup({ fileDate: '2020-01-01', fileName: 'notes.txt' }, '2026-01-02')).toBe(false);
|
|
120
|
+
expect(isBackupArtifact('a.sql.gz')).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('resolves the WebDAV directory, falling back to the repo name', () => {
|
|
124
|
+
expect(webdavTargetDir('', 'mail-meow')).toBe('webdav:mail-meow/production');
|
|
125
|
+
expect(webdavTargetDir('custom', 'mail-meow')).toBe('webdav:custom/production');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where backups land, and which listed objects the retention prune may delete.
|
|
3
|
+
*
|
|
4
|
+
* Provenance: the `s3-prune.ts` and `webdav-target.ts` that Mail-Meow, Edge-Sonic and AWS-AccessBridge each carry,
|
|
5
|
+
* converged with the repo-specific prefix lifted into a parameter (the manifest's `name`). Pure, so the safety rules
|
|
6
|
+
* are asserted without a bucket or a WebDAV host.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Every backup of one repo lives under `<name>/production`, so a prune can never touch an unrelated object.
|
|
11
|
+
*/
|
|
12
|
+
export function backupPrefix(name: string): string {
|
|
13
|
+
return `${name}/production`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BackupListingEntry {
|
|
17
|
+
/**
|
|
18
|
+
`YYYY-MM-DD` as reported by `aws s3 ls`.
|
|
19
|
+
*/
|
|
20
|
+
fileDate: string;
|
|
21
|
+
fileName: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* True only for files this workflow produced. The prune is the one destructive operation in the backup, so it refuses
|
|
26
|
+
* anything that is not a backup artifact. `.gz` is kept so objects written before the switch to xz still age out.
|
|
27
|
+
*/
|
|
28
|
+
export function isBackupArtifact(fileName: string): boolean {
|
|
29
|
+
return (
|
|
30
|
+
fileName.endsWith('.sql.xz') || fileName.endsWith('.sql.xz.enc') || fileName.endsWith('.sql.gz') || fileName.endsWith('.sql.gz.enc')
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Parse one `aws s3 ls` row: `<date> <time> <size> <key>`.
|
|
36
|
+
*/
|
|
37
|
+
export function parseS3ListRow(line: string): BackupListingEntry | undefined {
|
|
38
|
+
const fields = line.trim().split(/\s+/);
|
|
39
|
+
return fields.length < 4 ? undefined : { fileDate: fields[0], fileName: fields.slice(3).join(' ') };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Decide whether a listed object should be pruned. Dates are `YYYY-MM-DD`, so lexicographic and chronological order agree.
|
|
44
|
+
*/
|
|
45
|
+
export function shouldDeleteBackup(entry: BackupListingEntry, cutoffDate: string): boolean {
|
|
46
|
+
return isBackupArtifact(entry.fileName) && entry.fileDate < cutoffDate;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The rclone remote name the WebDAV upload configures from the environment.
|
|
51
|
+
*/
|
|
52
|
+
export const WEBDAV_REMOTE = 'webdav';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Where backups land on the remote, e.g. `webdav:my-app/production`. An empty base path falls back to `name`.
|
|
56
|
+
*/
|
|
57
|
+
export function webdavTargetDir(basePath: string, name: string): string {
|
|
58
|
+
return `${WEBDAV_REMOTE}:${basePath || name}/production`;
|
|
59
|
+
}
|