mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
ci: move both pipelines to GitHub Actions (spec-v6)
GitHub becomes the primary repository host; the site keeps its VPS + nginx + Dockge host, the three-job pipeline and the same concurrency, so what moves is the CI host and the write-path target. .github/workflows/{deploy,deploy-infra}.yml are ports of the Gitea files with permissions: contents: read on every job. .gitea/workflows/ stays until the first green GitHub run (D9); its infra test step carries the new template variable names because the template it validates is the one this repository now ships.
The write-path values are renamed GITEA_TOKEN / GITEA_CONTENTS_API -> CONTENT_API_TOKEN / CONTENT_API_BASE and the upstream header becomes Bearer — in nginx.conf, in the compose envsubst filter and in the dev proxy, so dev and production send the identical header (D4). draft.ts learns GitHub's answer to a stale blob sha (409) while keeping the 422 "does not match" and 412 legs; smoke-draft.ts check 14 drives a stubbed proxy that answers 409 with GitHub's body and asserts the conflict refreshes the base, keeps the draft and never stops the save sequence.
Both workflows read the stack directory and the compose service / container name from the STACK_DIR and CONTAINER_NAME repository variables instead of hard-coding them, and each job refuses a missing, relative, trailing-slash or compose-disagreeing value in its first step, before any artifact download or rsync reaches the VPS (D15).
Verified: tsc -b and oxlint pass with no new warnings; validate:content, smoke-draft (14 checks) and smoke-generated-ids (7 checks) pass; both workflows parse, every run/script block passes bash -n with the variables substituted, and the guard refuses every bad value against the real compose.yaml. Owner-side variables, secrets, the write token and the VPS config rewrite stay open in spec-v6 §6.
This commit is contained in:
1 parent
1cfeda7987
commit
cff981c5f3
15 files changed
+568
-83
No files matched your search
+52
-4
@@ -5,9 +5,9 @@
|
||||
// writes, record add/delete/rename, conflicts and rebase, the validator rules
|
||||
// a rejected edit is reported through, and the scoped-baseline rules of
|
||||
// spec-v4-live-edit §5.1 (adoptBase, and a save that must not PUT a
|
||||
// bundle-seeded document).
|
||||
// bundle-seeded document), and the Contents API conflict answer of spec-v6 D5.
|
||||
// Run: pnpm tsx scripts/smoke-draft.ts
|
||||
import { DraftStore, bundledBase, saveDraft } from '../src/i18n/draft';
|
||||
import { DraftStore, bundledBase, PROXY_BASE, saveDraft } from '../src/i18n/draft';
|
||||
import type { CategoryLabels } from '../src/i18n/validate';
|
||||
import type { DocBase } from '../src/i18n/draft';
|
||||
import projectsEnUiJson from '../src/i18n/locales/en/ui/projects.json';
|
||||
@@ -190,7 +190,7 @@ if ((store8.dataOf('profile.vi') as Record<string, unknown>).bio !== 'KEEP MINE'
|
||||
fail('a late read replaced drafted work');
|
||||
|
||||
// 13. A baseline that came from the bundle carries no blob sha, so the save
|
||||
// pipeline must not PUT it over the branch (Gitea reads an empty sha as a
|
||||
// pipeline must not PUT it over the branch (the API reads an empty sha as a
|
||||
// create). It reads the branch first — with no proxy reachable here that read
|
||||
// fails, so the document reports a failure, the save stops before any write,
|
||||
// and the draft survives.
|
||||
@@ -208,4 +208,52 @@ if (saveProbe.results.length !== 1) fail('the save kept going past the stopped d
|
||||
if ((store9.dataOf('profile.vi') as Record<string, unknown>).bio !== 'SCOPED BASELINE')
|
||||
fail('a failed save lost the draft');
|
||||
|
||||
console.log('draft store smoke: all 13 checks passed');
|
||||
// 14. A blob-sha conflict belongs to the conflict flow, not to a hard stop.
|
||||
// GitHub answers 409 Conflict with a body the Gitea-era message matcher would
|
||||
// not recognise — the status alone must drive the flow: refresh that document's
|
||||
// base from the branch, report a conflict, and keep the sequence going.
|
||||
const store10 = new DraftStore(structuredClone(bases), LABELS);
|
||||
for (const id of ['profile.vi', 'profile.en'] as const) {
|
||||
const branchCopy = structuredClone(bases[id]);
|
||||
branchCopy.sha = `branch-${id}`;
|
||||
store10.resetBase(id, branchCopy);
|
||||
}
|
||||
if (store10.setValue('vi', 'profile.bio', 'CONFLICT MINE') !== null)
|
||||
fail('the conflict-probe edit was rejected');
|
||||
if (store10.setValue('en', 'profile.bio', 'CONFLICT MINE EN') !== null)
|
||||
fail('the second conflict-probe edit was rejected');
|
||||
|
||||
const branchDoc = (id: 'profile.vi' | 'profile.en', bio: string) => {
|
||||
const data = structuredClone(bases[id].data) as Record<string, unknown>;
|
||||
data.bio = bio;
|
||||
return { encoded: Buffer.from(JSON.stringify(data, null, 2)).toString('base64'), sha: `moved-${id}` };
|
||||
};
|
||||
const viBranch = branchDoc('profile.vi', 'THEIR BIO');
|
||||
const enBranch = branchDoc('profile.en', 'THEIR BIO EN');
|
||||
|
||||
const realFetch = globalThis.fetch;
|
||||
globalThis.fetch = (async (input: unknown, init?: { method?: string }) => {
|
||||
const url = String(input);
|
||||
if (!url.startsWith(PROXY_BASE)) fail(`the save left the proxy: ${url}`);
|
||||
const branch = url.includes('/vi/content/') ? viBranch : enBranch;
|
||||
if ((init?.method ?? 'GET') === 'PUT')
|
||||
return new Response(JSON.stringify({ message: 'Conflict', documentation_url: 'https://docs.github.com/rest' }), { status: 409 });
|
||||
return new Response(JSON.stringify({ content: branch.encoded, sha: branch.sha }), { status: 200 });
|
||||
}) as unknown as typeof fetch;
|
||||
|
||||
const conflictSave = await saveDraft(store10, () => {}, 'master');
|
||||
globalThis.fetch = realFetch;
|
||||
if (conflictSave.results.length !== 2)
|
||||
fail(`a 409 cut the save short: ${JSON.stringify(conflictSave.results)}`);
|
||||
if (!conflictSave.results.every((r) => r.status === 'conflict' && r.http === 409))
|
||||
fail(`a 409 was not reported as a conflict: ${JSON.stringify(conflictSave.results)}`);
|
||||
if (conflictSave.stoppedEarly) fail('a conflict stopped the save sequence');
|
||||
if (store10.shaOf('profile.vi') !== 'moved-profile.vi') fail('the conflict did not refresh the base from the branch');
|
||||
if (store10.shaOf('profile.en') !== 'moved-profile.en') fail('the second conflict did not refresh its base');
|
||||
if ((store10.dataOf('profile.vi') as Record<string, unknown>).bio !== 'CONFLICT MINE')
|
||||
fail('a conflict dropped the draft');
|
||||
// The refreshed base is what the conflict UI resolves against: my path and the
|
||||
// branch path both moved, so the store must hand the field over, not pick a side.
|
||||
if (store10.rebase('profile.vi') === null) fail('a 409 left nothing for the conflict UI to resolve');
|
||||
|
||||
console.log('draft store smoke: all 14 checks passed');
|
||||
Reference in new issue
Block a user