Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcec206060 |
@@ -5,6 +5,8 @@ on:
|
||||
# truth, enforced by frontend/tests/staging-backend-workflows.test.ts). A push
|
||||
# touching none of them is docs-only: it neither reruns this gate nor cancels
|
||||
# a gate already running for a code push.
|
||||
# BUG-2415: `next` (integration for the next version) runs the checks only; the
|
||||
# publish job still deploys only refs/heads/staging, which the release workflows move.
|
||||
pull_request:
|
||||
paths:
|
||||
- '.dockerignore'
|
||||
@@ -25,7 +27,7 @@ on:
|
||||
- 'vendor/**'
|
||||
- 'contracts/**'
|
||||
push:
|
||||
branches: [staging]
|
||||
branches: [staging, next]
|
||||
paths:
|
||||
- '.dockerignore'
|
||||
- '.gitea/**'
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
name: 封板 Freeze release (cut release/x.y from next)
|
||||
|
||||
# BUG-2415 (owner 2026-11-26): the owner decides two things — when to freeze and when to
|
||||
# ship. Freezing cuts release/<version> from the current `next` head, sets the app version on
|
||||
# the release branch, and pushes it with RELEASE_PUSH_TOKEN; that push starts
|
||||
# "Release branch to staging", which deploys it to the single staging environment.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Version to freeze, for example 1.6
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
concurrency:
|
||||
group: release-flow
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
freeze:
|
||||
runs-on: xiaoxin
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
GITEA_API_URL: ${{ gitea.api_url }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
RELEASE_PUSH_TOKEN: ${{ secrets.RELEASE_PUSH_TOKEN }}
|
||||
VERSION: ${{ inputs.version }}
|
||||
steps:
|
||||
- name: Cut release branch from next
|
||||
run: |
|
||||
set -euo pipefail
|
||||
work="$(mktemp -d "${RUNNER_TEMP:-/tmp}/jyotisha-freeze.XXXXXX")"
|
||||
trap 'rm -rf -- "$work"' EXIT
|
||||
flow="$work/branch-flow.sh"
|
||||
curl --fail --silent --show-error --connect-timeout 15 --max-time 60 \
|
||||
--header "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$GITEA_REPOSITORY/raw/deploy/branch-flow.sh?ref=next" --output "$flow"
|
||||
chmod +x "$flow"
|
||||
bash "$flow" validate-version "$VERSION"
|
||||
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]] || { echo "freeze takes x.y; hotfixes are cut by hand as hotfix/x.y.z from main" >&2; exit 1; }
|
||||
branch="release/$VERSION"
|
||||
if [ -n "$(bash "$flow" tag-sha "v$VERSION")" ]; then
|
||||
echo "v$VERSION is already released; choose a new version" >&2; exit 1
|
||||
fi
|
||||
if [ -n "$(bash "$flow" ref-sha "$branch")" ]; then
|
||||
echo "$branch already exists" >&2; exit 1
|
||||
fi
|
||||
next_sha="$(bash "$flow" ref-sha next)"
|
||||
[[ "$next_sha" =~ ^[0-9a-f]{40}$ ]] || { echo "branch next does not exist" >&2; exit 1; }
|
||||
cd "$work"
|
||||
mkdir repo && cd repo
|
||||
bash "$flow" prepare-git
|
||||
bash "$flow" fetch next
|
||||
git checkout -q -b "$branch" "$next_sha"
|
||||
version_file=frontend/src/lib/app-version.ts
|
||||
current="$(sed -nE 's/^export const APP_VERSION = "([^"]+)";.*/\1/p' "$version_file")"
|
||||
if [ "$current" != "$VERSION" ]; then
|
||||
sed -i -E "s/^export const APP_VERSION = \"[^\"]+\";/export const APP_VERSION = \"$VERSION\";/" "$version_file"
|
||||
grep -q "^export const APP_VERSION = \"$VERSION\";" "$version_file"
|
||||
git add "$version_file"
|
||||
git commit -q -m "chore(release): freeze $VERSION [release-bump]"
|
||||
fi
|
||||
git push origin "HEAD:refs/heads/$branch"
|
||||
echo "froze $branch at $(git rev-parse HEAD) (next was $next_sha)"
|
||||
@@ -0,0 +1,86 @@
|
||||
name: Release branch to staging
|
||||
|
||||
# BUG-2415: a push to release/x.y or hotfix/x.y.z moves the `staging` branch to that head,
|
||||
# using RELEASE_PUSH_TOKEN so the existing staging pipeline (quality gate → database
|
||||
# migration → deploy → full release checks) runs unchanged for that exact SHA. Every new
|
||||
# commit on a release or hotfix branch must name a BUG-NNNN. A release branch's fixes are
|
||||
# then merged back into `next`.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'release/**'
|
||||
- 'hotfix/**'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
concurrency:
|
||||
group: release-flow
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
to-staging:
|
||||
runs-on: xiaoxin
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
GITEA_API_URL: ${{ gitea.api_url }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
RELEASE_PUSH_TOKEN: ${{ secrets.RELEASE_PUSH_TOKEN }}
|
||||
HEAD_SHA: ${{ gitea.sha }}
|
||||
BEFORE_SHA: ${{ gitea.event.before }}
|
||||
GITEA_REF: ${{ gitea.ref }}
|
||||
steps:
|
||||
- name: Move staging to the release head
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[[ "$HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]
|
||||
branch="${GITEA_REF#refs/heads/}"
|
||||
[[ "$branch" =~ ^(release/[0-9]+\.[0-9]+|hotfix/[0-9]+\.[0-9]+\.[0-9]+)$ ]] || {
|
||||
echo "branch $branch is not release/x.y or hotfix/x.y.z" >&2; exit 1; }
|
||||
work="$(mktemp -d "${RUNNER_TEMP:-/tmp}/jyotisha-release.XXXXXX")"
|
||||
trap 'rm -rf -- "$work"' EXIT
|
||||
flow="$work/branch-flow.sh"
|
||||
curl --fail --silent --show-error --connect-timeout 15 --max-time 60 \
|
||||
--header "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$GITEA_REPOSITORY/raw/deploy/branch-flow.sh?ref=$HEAD_SHA" --output "$flow"
|
||||
chmod +x "$flow"
|
||||
|
||||
main_sha="$(bash "$flow" ref-sha main)"
|
||||
staging_sha="$(bash "$flow" ref-sha staging)"
|
||||
# Every commit new to this branch names a BUG number (merges and the freeze bump excepted).
|
||||
base="$BEFORE_SHA"
|
||||
if [[ ! "$base" =~ ^[0-9a-f]{40}$ ]] || [[ "$base" =~ ^0+$ ]]; then base="$main_sha"; fi
|
||||
bash "$flow" commit-messages "$base" "$HEAD_SHA" | bash "$flow" bug-ids-ok || {
|
||||
echo "every commit on $branch must name a BUG-NNNN; staging was not moved" >&2; exit 1; }
|
||||
|
||||
cd "$work" && mkdir repo && cd repo
|
||||
bash "$flow" prepare-git
|
||||
bash "$flow" fetch main staging "$branch"
|
||||
git cat-file -e "$HEAD_SHA^{commit}"
|
||||
if git merge-base --is-ancestor "$staging_sha" "$HEAD_SHA"; then
|
||||
git push origin "$HEAD_SHA:refs/heads/staging"
|
||||
elif [ "$staging_sha" = "$main_sha" ] || [[ "$branch" == hotfix/* ]]; then
|
||||
# staging still shows the last shipped version (or a hotfix takes over the test
|
||||
# environment): staging is only a deploy pointer, so it may be reset.
|
||||
git push --force-with-lease="refs/heads/staging:$staging_sha" origin "$HEAD_SHA:refs/heads/staging"
|
||||
else
|
||||
echo "staging ($staging_sha) holds another unshipped release; ship or abandon it first" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "staging → $HEAD_SHA ($branch); the staging pipeline deploys it"
|
||||
|
||||
if [[ "$branch" == release/* ]]; then
|
||||
bash "$flow" fetch next
|
||||
git checkout -q -B next refs/remotes/origin/next
|
||||
if git merge-base --is-ancestor "$HEAD_SHA" HEAD; then
|
||||
echo "next already contains $HEAD_SHA"
|
||||
elif git merge -q --no-edit -m "Merge $branch into next" "$HEAD_SHA"; then
|
||||
git push origin HEAD:refs/heads/next
|
||||
echo "merged $branch into next"
|
||||
else
|
||||
git merge --abort || true
|
||||
echo "::warning::$branch could not be merged into next automatically (conflict); merge it by hand"
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,112 @@
|
||||
name: 发版 Ship release to production
|
||||
|
||||
# BUG-2415 (owner 2026-11-26): the owner's second decision. Ships release/x.y (or
|
||||
# hotfix/x.y.z) after the owner tested it on staging:
|
||||
# 1. the branch head must be what staging is running, carry APP_VERSION = the version,
|
||||
# and have a successful full release check (release-quality-gate) for that exact SHA;
|
||||
# 2. main fast-forwards to it (never a merge or a rewrite);
|
||||
# 3. recovery point + production migration run only when migrations changed since the
|
||||
# last release tag; then the existing exact-SHA production deploy (which tags v<version>);
|
||||
# 4. main is merged back into next.
|
||||
# The three production workflows keep every check they already make (main == staging,
|
||||
# exact staging-gate images); this workflow only runs them in order.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Version to ship, for example 1.6 (release/1.6) or 1.6.1 (hotfix/1.6.1)
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
|
||||
# Not production-mutation: the workflows it starts take that queue themselves.
|
||||
concurrency:
|
||||
group: release-flow
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
ship:
|
||||
runs-on: xiaoxin
|
||||
timeout-minutes: 150
|
||||
env:
|
||||
GITEA_API_URL: ${{ gitea.api_url }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
RELEASE_PUSH_TOKEN: ${{ secrets.RELEASE_PUSH_TOKEN }}
|
||||
VERSION: ${{ inputs.version }}
|
||||
STAGING_URL: ${{ vars.STAGING_URL }}
|
||||
steps:
|
||||
- name: Ship
|
||||
run: |
|
||||
set -euo pipefail
|
||||
work="$(mktemp -d "${RUNNER_TEMP:-/tmp}/jyotisha-ship.XXXXXX")"
|
||||
trap 'rm -rf -- "$work"' EXIT
|
||||
flow="$work/branch-flow.sh"
|
||||
curl --fail --silent --show-error --connect-timeout 15 --max-time 60 \
|
||||
--header "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$GITEA_REPOSITORY/raw/deploy/branch-flow.sh?ref=staging" --output "$flow"
|
||||
chmod +x "$flow"
|
||||
bash "$flow" validate-version "$VERSION"
|
||||
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then branch="release/$VERSION"; else branch="hotfix/$VERSION"; fi
|
||||
|
||||
sha="$(bash "$flow" ref-sha "$branch")"
|
||||
[[ "$sha" =~ ^[0-9a-f]{40}$ ]] || { echo "$branch does not exist" >&2; exit 1; }
|
||||
[ -z "$(bash "$flow" tag-sha "v$VERSION")" ] || { echo "v$VERSION is already shipped" >&2; exit 1; }
|
||||
staging_sha="$(bash "$flow" ref-sha staging)"
|
||||
[ "$staging_sha" = "$sha" ] || { echo "staging runs $staging_sha, not $branch ($sha); wait for its deploy" >&2; exit 1; }
|
||||
deployed="$(curl --fail --silent --show-error --connect-timeout 15 --max-time 60 "${STAGING_URL:-https://staging.jyotisha.chat}/api/health" |
|
||||
jq -r '.deployment.gitCommit // ""')"
|
||||
[ "$deployed" = "$sha" ] || { echo "staging is still deploying ($deployed); ship after it is live" >&2; exit 1; }
|
||||
bash "$flow" release-gate-passed "$sha" || {
|
||||
echo "no successful full release check for $sha yet; it runs after each staging deploy (or dispatch Jyotish Release Quality Gate)" >&2; exit 1; }
|
||||
|
||||
cd "$work" && mkdir repo && cd repo
|
||||
bash "$flow" prepare-git
|
||||
bash "$flow" fetch main next "$branch"
|
||||
version_now="$(git show "$sha:frontend/src/lib/app-version.ts" | sed -nE 's/^export const APP_VERSION = "([^"]+)";.*/\1/p')"
|
||||
[ "$version_now" = "$VERSION" ] || { echo "$branch says APP_VERSION $version_now, not $VERSION" >&2; exit 1; }
|
||||
main_before="$(git rev-parse refs/remotes/origin/main)"
|
||||
git merge-base --is-ancestor "$main_before" "$sha" || {
|
||||
echo "main ($main_before) is not an ancestor of $sha; merge main into $branch first" >&2; exit 1; }
|
||||
git push origin "$sha:refs/heads/main"
|
||||
echo "main → $sha"
|
||||
|
||||
if bash "$flow" migrations-changed "$main_before" "$sha"; then
|
||||
run="$(bash "$flow" dispatch create-production-recovery.yml refs/heads/main "$(jq -cn --arg s "$sha" '{deploy_sha:$s}')")"
|
||||
echo "recovery point run $run"
|
||||
bash "$flow" wait-run "$run" 45
|
||||
job="$(curl --fail --silent --show-error --header "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$GITEA_REPOSITORY/actions/runs/$run/jobs" | jq -r '.jobs[0].id')"
|
||||
line="$(curl --fail --silent --show-error --header "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$GITEA_REPOSITORY/actions/jobs/$job/logs" |
|
||||
grep -oE 'Recovery (attested|restore-verified): reference=[^ ]+ created_at=[^ ]+' | tail -1)"
|
||||
reference="$(sed -E 's/.*reference=([^ ]+).*/\1/' <<<"$line")"
|
||||
created_at="$(sed -E 's/.*created_at=([^ ]+).*/\1/' <<<"$line")"
|
||||
[ -n "$reference" ] && [ -n "$created_at" ] || { echo "recovery run $run did not report its reference" >&2; exit 1; }
|
||||
run="$(bash "$flow" dispatch migrate-production-database.yml refs/heads/main "$(jq -cn --arg s "$sha" --arg r "$reference" --arg c "$created_at" \
|
||||
'{deploy_sha:$s,recovery_reference:$r,recovery_created_at:$c,restore_verified:"true"}')")"
|
||||
echo "production migration run $run"
|
||||
bash "$flow" wait-run "$run" 45
|
||||
else
|
||||
echo "no migration changes since $main_before; skipping recovery point and migration"
|
||||
fi
|
||||
|
||||
run="$(bash "$flow" dispatch deploy-production.yml refs/heads/main "$(jq -cn --arg s "$sha" \
|
||||
'{deploy_sha:$s,allow_rollback:"false",verification_mode:"public"}')")"
|
||||
echo "production deploy run $run"
|
||||
bash "$flow" wait-run "$run" 45
|
||||
echo "shipped v$VERSION ($sha)"
|
||||
|
||||
git checkout -q -B next refs/remotes/origin/next
|
||||
if git merge-base --is-ancestor "$sha" HEAD; then
|
||||
echo "next already contains v$VERSION"
|
||||
elif git merge -q --no-edit -m "Merge v$VERSION (main) into next" "$sha"; then
|
||||
git push origin HEAD:refs/heads/next
|
||||
echo "merged main into next"
|
||||
else
|
||||
git merge --abort || true
|
||||
echo "::warning::main could not be merged into next automatically (conflict); merge it by hand"
|
||||
fi
|
||||
@@ -36,19 +36,19 @@
|
||||
1. 打包前 `git status --short --branch`;不得覆盖无关的脏文件。
|
||||
2. 部署后验证 `/login`、未登录 `/api/account` = `401`、内部 `/api/health` = `200` 且 `swisseph_available = true`;`deployment.gitCommit` 必须等于预期 SHA。
|
||||
3. 不得暴露端口 `5200`、模型 key、数据库口令、用户 JWT、SSH 私钥。
|
||||
4. 生产部署只走 Gitea 手动流程(先 `release-quality-gate`,再 dispatch `deploy-production`),复用 staging 已验收的镜像 digest;不改 DNS、不导入生产数据。
|
||||
4. 生产部署只走 Gitea 手动「发版 Ship release」工作流(BUG-2415):它检查完整发布检查已通过,把 `main` 快进到 `release/x.y`(或 `hotfix/x.y.z`)的头,按需跑恢复点与迁移,再 dispatch `deploy-production`;复用 staging 已验收的同 SHA 镜像 digest;不改 DNS、不导入生产数据。
|
||||
|
||||
## 2. 分支与交付
|
||||
|
||||
分支模型:`staging` 是测试环境,`main` 是生产控制分支。所有改动先经 `staging` 验收,再提升到 `main`;不存在直接改 `main` 的路径。
|
||||
分支模型(BUG-2415,2026-11-26 负责人批准,见 `docs/operations/branch-flow.md`):`next` 是下一版本的集成分支(只跑检查、不部署);`release/x.y` 是封板候选,推送后由 CI 把 `staging`(测试环境指针)移到它并部署;`hotfix/x.y.z` 从 `main` 拉;`main` 是生产控制分支,只由「发版」工作流快进。负责人只决定「封板」和「发版」。不存在直接改 `main` 的路径。
|
||||
|
||||
1. 动手前 `git fetch origin --prune`,以远端 **`origin/staging`** 为基线。本地 `staging` / `main` 经常落后远端上百个提交,不得作为基线。
|
||||
1. 动手前 `git fetch origin --prune`,新功能以远端 **`origin/next`** 为基线;封板期修复以 **`origin/release/x.y`** 为基线。本地分支经常落后远端上百个提交,不得作为基线。
|
||||
2. 在独立 worktree 开发:路径 `.worktrees/<主题>-<日期>`,分支 `codex/<主题>-<日期>`(见 §3)。
|
||||
3. 交付到 staging 用快进推送 `git push origin HEAD:staging`。这会触发 Gitea `backend-quality-gate`;它的 `paths:` 过滤与 `deploy/gated-paths.txt` 逐行一致。改动**全部**落在清单之外的纯文档推送(`docs/**`、根目录 `BLOCKED.md` / `CHANGELOG*.md` / `CONTEXT.md` / `AGENTS.md` / `CLAUDE.md` / `README.md` 等)不触发门禁、不发布镜像、不部署。鼓励把文档与同批代码合并一次推送,避免 staging head 与已部署 SHA 分离。
|
||||
3. 日常交付用快进推送 `git push origin HEAD:next`(只跑门禁检查,不部署);封板期的修复推 `release/x.y`,提交信息必须带 `BUG-NNNN`,CI 会把 `staging` 移过去并部署、再合回 `next`。直接 `git push origin HEAD:staging` 是过渡期旧做法,已弃用。推送 `staging` 会触发 Gitea `backend-quality-gate`;它的 `paths:` 过滤与 `deploy/gated-paths.txt` 逐行一致。改动**全部**落在清单之外的纯文档推送(`docs/**`、根目录 `BLOCKED.md` / `CHANGELOG*.md` / `CONTEXT.md` / `AGENTS.md` / `CLAUDE.md` / `README.md` 等)不触发门禁、不发布镜像、不部署。鼓励把文档与同批代码合并一次推送,避免 staging head 与已部署 SHA 分离。
|
||||
4. 门禁构建 digest 固定镜像并 dispatch `deploy-staging`;随后在 staging 完成与风险相称的验收。`GET /api/health` 的 `.deployment.gitCommit` 必须等于**最近一次含门禁路径改动的 staging 提交**。记这个提交为发布修订 `R`,记当前 staging head 为 `H`。其后若只有纯文档提交,`deploy/is-docs-only-range.sh R H` 必须退出 0,否则视为未部署。生产四个手动工作流发布的是 `R`,不是纯文档的 `H`;公网 health 的 gitCommit 仍必须等于 `R`。该脚本退出 1 或 2 都拒绝发布。
|
||||
5. 提升到 `main` **必须快进到 `H`,不得 merge**。`main` 与 `staging` 必须是同一 SHA。生产镜像和控制器产物取 `R` 的门禁结果,不取纯文档的 `H`。merge commit 会让生产部署失败。
|
||||
5. 提升到 `main` 只由「发版」工作流做,**必须快进到 `H`,不得 merge**。`main` 与 `staging` 必须是同一 SHA。生产镜像和控制器产物取 `R` 的门禁结果,不取纯文档的 `H`。merge commit 会让生产部署失败。
|
||||
6. 推送后必须核对远端 SHA;远端验证失败时不得声称已交付。
|
||||
7. 不得自行提升 `main`、不动 DNS——这两件事只由产品负责人触发。不改 `.gitea/workflows/**`,除非任务书的决策记录点名了具体文件。2026-10-14 的授权只覆盖 `deploy-production.yml`、`create-production-recovery.yml`、`migrate-production-database.yml`、`release-quality-gate.yml` 的发布修订规则(`R` 加其后纯文档)。不改 staging 工作流,不改 `deploy/gated-paths.txt`。
|
||||
7. 不得自行提升 `main`、不得自行封板、不动 DNS——封板、发版只由产品负责人决定(Gitea 手动工作流)。不改 `.gitea/workflows/**`,除非任务书的决策记录点名了具体文件。2026-10-14 的授权只覆盖 `deploy-production.yml`、`create-production-recovery.yml`、`migrate-production-database.yml`、`release-quality-gate.yml` 的发布修订规则(`R` 加其后纯文档)。不改 staging 工作流,不改 `deploy/gated-paths.txt`。2026-11-26 负责人授权 BUG-2415:`backend-quality-gate.yml` 的 push 分支加 `next`(只检查),新增 `freeze-release.yml`、`release-to-staging.yml`、`ship-release.yml` 与 `deploy/branch-flow.sh`。
|
||||
|
||||
## 3. 工作树与多会话
|
||||
|
||||
|
||||
@@ -144,6 +144,10 @@ It fails while `frontend/src/lib/legal-entity.ts` still holds placeholder operat
|
||||
|
||||
## Manual production deployment with Gitea Actions
|
||||
|
||||
### Branch release flow (BUG-2415, owner 2026-11-26)
|
||||
|
||||
From 1.6 on, releases follow `docs/operations/branch-flow.md`: windows push to `next` (checks only, no deploy); the owner's **封板 Freeze release** workflow cuts `release/x.y` from `next`; a push to `release/*` or `hotfix/*` runs **Release branch to staging**, which requires `BUG-NNNN` on every new commit, moves `staging` to that head with `RELEASE_PUSH_TOKEN` (so the unchanged staging gate → migration → deploy → full release checks run for that exact SHA) and merges a release branch back into `next`. The owner's **发版 Ship release** workflow then fast-forwards `main` to that head only when staging is live on it, `APP_VERSION` equals the version and the full release checks passed for that SHA; it runs **Create Production Recovery Point** and **Migrate Production Database** only when `frontend/supabase/migrations/` changed since the previous `main` (the recovery run's restore verification is the attestation, and the owner's 「发版」 click is the human approval that the manual migrate step used to represent), then **Deploy Production** (which tags `v<APP_VERSION>`), and merges `main` back into `next`. The production workflows below keep every check they make; the ship workflow only runs them in order. Pushing directly to `staging` still deploys during the transition but is deprecated.
|
||||
|
||||
GitHub production deployment is retired. Production changes are released only by manually dispatching `.gitea/workflows/deploy-production.yml`. `main` must be a fast-forward to the current staging head `H`. The deployed SHA is `R`, the latest successful staging push of `backend-quality-gate`, and `deploy/is-docs-only-range.sh R H` must exit 0 (exit 1 or 2 both refuse). Controller artifacts and image digests come from `R`. Public staging health must report `R`. The full release gate (`release-quality-gate.yml`) must have succeeded for `R` or `H`. Since BUG-2390 (owner 2026-11-25) Deploy staging queues it automatically on `refs/heads/staging` after every successful staging deploy, so it normally exists before the owner approves a release and is not rerun from `main`; a newer staging deploy cancels an older queued run. If that run was cancelled or failed for an environment reason, dispatch the workflow manually from `main` (it may record `H` when `H` is docs-only ahead of `R`). Rollback still requires an explicit confirmation, a gate run, and ancestry inside reviewed `main` history. The workflow deploys immutable registry digests and never builds application images on the production host.
|
||||
|
||||
The `internal` verification mode is for pre-DNS checks on the new host. The `public` mode is for the same SHA after authoritative DNS and Caddy TLS converge. Neither mode imports data, applies pending migrations, or changes DNS.
|
||||
|
||||
Executable
+166
@@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env bash
|
||||
# BUG-2415: helpers for the branch release flow (next / release/x.y / hotfix/x.y.z / main).
|
||||
#
|
||||
# branch-flow.sh validate-version <x.y|x.y.z> exit 1 unless the value is a version
|
||||
# branch-flow.sh bug-ids-ok stdin: commit messages separated by NUL;
|
||||
# exit 1 naming each message without BUG-NNNN
|
||||
# (merge commits and [release-bump] are exempt)
|
||||
# branch-flow.sh commit-messages <base> <head> NUL-separated messages of base..head (Gitea compare API)
|
||||
# branch-flow.sh ref-sha <branch> the branch head SHA, or empty when it does not exist
|
||||
# branch-flow.sh tag-sha <tag> the tagged commit SHA, or empty when the tag does not exist
|
||||
# branch-flow.sh prepare-git init a work tree whose origin pushes with RELEASE_PUSH_TOKEN
|
||||
# branch-flow.sh fetch <ref>... fetch refs (runner mirror first, then origin)
|
||||
# branch-flow.sh dispatch <workflow> <ref> <json-inputs> prints the new run id
|
||||
# branch-flow.sh wait-run <run-id> <minutes> exit 0 on success, 1 on failure/timeout
|
||||
# branch-flow.sh release-gate-passed <sha> exit 0 when a release-quality-gate run for sha succeeded
|
||||
# branch-flow.sh migrations-changed <base> <head> exit 0 when base..head touches frontend/supabase/migrations/
|
||||
#
|
||||
# Network calls use GITEA_API_URL / GITEA_REPOSITORY / GITEA_TOKEN. Pushes use
|
||||
# RELEASE_PUSH_TOKEN (a personal access token), because pushes made with the
|
||||
# workflow's own token do not start other workflows.
|
||||
set -euo pipefail
|
||||
|
||||
api_url="${GITEA_API_URL:-https://git.copse.top/api/v1}"
|
||||
repository="${GITEA_REPOSITORY:-root/Jyotisha}"
|
||||
clone_url="${GITEA_CLONE_URL:-https://git.copse.top/root/Jyotisha.git}"
|
||||
mirror="${JYOTISHA_MIRROR:-/root/.cache/jyotisha-mirror.git}"
|
||||
|
||||
api() {
|
||||
curl --fail --silent --show-error --connect-timeout 15 --max-time 60 --retry 3 --retry-all-errors \
|
||||
--header "Authorization: token ${GITEA_TOKEN:?GITEA_TOKEN is required}" "$@"
|
||||
}
|
||||
|
||||
validate_version() {
|
||||
[[ "${1:-}" =~ ^[1-9][0-9]*\.[0-9]+(\.[0-9]+)?$ ]] || { echo "not a version: ${1:-}" >&2; return 1; }
|
||||
}
|
||||
|
||||
bug_ids_ok() {
|
||||
local bad=0 message first
|
||||
while IFS= read -r -d '' message || [ -n "$message" ]; do
|
||||
[ -n "$message" ] || continue
|
||||
first="${message%%$'\n'*}"
|
||||
case "$first" in
|
||||
"Merge "*) continue ;;
|
||||
esac
|
||||
if [[ "$message" == *"[release-bump]"* ]]; then continue; fi
|
||||
if ! grep -Eq 'BUG-[0-9]{3,5}' <<<"$message"; then
|
||||
echo "missing BUG number: $first" >&2
|
||||
bad=1
|
||||
fi
|
||||
done
|
||||
return "$bad"
|
||||
}
|
||||
|
||||
commit_messages() {
|
||||
local base="$1" head="$2"
|
||||
local response
|
||||
response="$(api "$api_url/repos/$repository/compare/$base...$head")"
|
||||
jq -e '(.total_commits // 0) == ((.commits // []) | length)' <<<"$response" >/dev/null || {
|
||||
echo "compare $base...$head returned a partial commit list; cannot check BUG numbers" >&2
|
||||
return 2
|
||||
}
|
||||
jq -j '.commits[]? | .commit.message + "\u0000"' <<<"$response"
|
||||
}
|
||||
|
||||
ref_sha() {
|
||||
local branch="$1" out
|
||||
out="$(curl --silent --connect-timeout 15 --max-time 60 --retry 3 \
|
||||
--header "Authorization: token ${GITEA_TOKEN:?}" \
|
||||
--write-out '\n%{http_code}' "$api_url/repos/$repository/branches/$branch")"
|
||||
case "${out##*$'\n'}" in
|
||||
200) jq -r '.commit.id' <<<"${out%$'\n'*}" ;;
|
||||
404) printf '' ;;
|
||||
*) echo "could not read branch $branch" >&2; return 2 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
tag_sha() {
|
||||
local tag="$1" out
|
||||
out="$(curl --silent --connect-timeout 15 --max-time 60 --retry 3 \
|
||||
--header "Authorization: token ${GITEA_TOKEN:?}" \
|
||||
--write-out '\n%{http_code}' "$api_url/repos/$repository/tags/$tag")"
|
||||
case "${out##*$'\n'}" in
|
||||
200) jq -r '.commit.sha' <<<"${out%$'\n'*}" ;;
|
||||
404) printf '' ;;
|
||||
*) echo "could not read tag $tag" >&2; return 2 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
prepare_git() {
|
||||
: "${RELEASE_PUSH_TOKEN:?RELEASE_PUSH_TOKEN secret is missing: see docs/operations/branch-flow.md}"
|
||||
git init -q .
|
||||
git remote remove origin 2>/dev/null || true
|
||||
git remote add origin "$clone_url"
|
||||
git config user.name "Jyotisha release bot"
|
||||
git config user.email "release-bot@jyotisha.invalid"
|
||||
git config http.extraHeader "Authorization: Basic $(printf 'release-bot:%s' "$RELEASE_PUSH_TOKEN" | base64 -w0)"
|
||||
}
|
||||
|
||||
fetch_refs() {
|
||||
local ref
|
||||
if [ -d "$mirror" ]; then
|
||||
timeout 300 git fetch -q --no-tags "$mirror" '+refs/heads/*:refs/remotes/mirror/*' || true
|
||||
fi
|
||||
for ref in "$@"; do
|
||||
timeout 300 git fetch -q --no-tags origin "+refs/heads/$ref:refs/remotes/origin/$ref"
|
||||
done
|
||||
}
|
||||
|
||||
dispatch() {
|
||||
local workflow="$1" ref="$2" inputs="$3" response run_id
|
||||
response="$(api --request POST --header "Content-Type: application/json" \
|
||||
--data "$(jq -cn --arg ref "$ref" --argjson inputs "$inputs" '{ref:$ref,inputs:$inputs}')" \
|
||||
"$api_url/repos/$repository/actions/workflows/$workflow/dispatches?return_run_details=true")"
|
||||
run_id="$(jq -er '.workflow_run_id | select(type == "number" and . > 0)' <<<"$response")"
|
||||
printf '%s\n' "$run_id"
|
||||
}
|
||||
|
||||
wait_run() {
|
||||
local run_id="$1" minutes="$2" deadline state
|
||||
deadline=$(( $(date +%s) + minutes * 60 ))
|
||||
while [ "$(date +%s)" -lt "$deadline" ]; do
|
||||
state="$(api "$api_url/repos/$repository/actions/runs/$run_id" | jq -r '[.status, (.conclusion // "")] | join(" ")')"
|
||||
case "$state" in
|
||||
"completed success") return 0 ;;
|
||||
completed*) echo "run $run_id ended: $state" >&2; return 1 ;;
|
||||
esac
|
||||
sleep 30
|
||||
done
|
||||
echo "run $run_id did not finish within $minutes minutes" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
release_gate_passed() {
|
||||
local sha="$1"
|
||||
api "$api_url/repos/$repository/actions/runs?head_sha=$sha&limit=50" |
|
||||
jq -e --arg sha "$sha" '[.workflow_runs[]? | select(.head_sha == $sha)
|
||||
| select((.path | split("@")[0]) | endswith("release-quality-gate.yml"))
|
||||
| select(.status == "completed" and .conclusion == "success")] | length > 0' >/dev/null
|
||||
}
|
||||
|
||||
migrations_changed() {
|
||||
local base="$1" head="$2"
|
||||
# Gitea lists changed files per commit; a truncated listing counts as "changed" so the
|
||||
# release never skips a migration it could not see.
|
||||
api "$api_url/repos/$repository/compare/$base...$head" |
|
||||
jq -e '((.total_commits // 0) != ((.commits // []) | length))
|
||||
or any(.commits[]?; (.files == null)
|
||||
or any(.files[]?; ((.filename // "") + " " + (.previous_filename // "")) | test("frontend/supabase/migrations/")))' >/dev/null
|
||||
}
|
||||
|
||||
command="${1:-}"
|
||||
shift || true
|
||||
case "$command" in
|
||||
validate-version) validate_version "$@" ;;
|
||||
bug-ids-ok) bug_ids_ok ;;
|
||||
commit-messages) commit_messages "$@" ;;
|
||||
ref-sha) ref_sha "$@" ;;
|
||||
tag-sha) tag_sha "$@" ;;
|
||||
prepare-git) prepare_git ;;
|
||||
fetch) fetch_refs "$@" ;;
|
||||
dispatch) dispatch "$@" ;;
|
||||
wait-run) wait_run "$@" ;;
|
||||
release-gate-passed) release_gate_passed "$@" ;;
|
||||
migrations-changed) migrations_changed "$@" ;;
|
||||
*) echo "usage: branch-flow.sh <command> …" >&2; exit 2 ;;
|
||||
esac
|
||||
@@ -32879,3 +32879,18 @@
|
||||
- **关联记录**:BUG-2392(王者格局结构满足即成立)、BUG-2412(成立的规则格局进星盘页)、BUG-2226(读者条件句)。
|
||||
- **未处理**:报告附录的格局表仍用 `CUSTOM_CONDITION_UNLISTED_ZH`(报告窗口负责),这条规则现在有句子,不会再落到那里。
|
||||
- **修复版本**:1.5。
|
||||
|
||||
## BUG-2415 | 发版流程改成分支:next / release/x.y / hotfix/x.y.z / main,由 CI 把关
|
||||
|
||||
- **状态**:resolved(代码已提交;需负责人在 Gitea 建 `RELEASE_PUSH_TOKEN`、`next` 分支并加分支保护后启用)
|
||||
- **现象**:所有窗口都推 `staging`,`staging` 整体发正式。封板测试期间新功能无处可推;版本顺序靠协调窗口记忆,窗口重启后容易乱(2026-11-24~26 多次出现推送互相顶掉门禁、发版前等待)。
|
||||
- **根因**:只有一条测试线 `staging` 同时承担「集成」「候选版本」「测试环境指针」三种角色,没有冻结分支,也没有机器检查的发版规则。
|
||||
- **修复**:
|
||||
- `backend-quality-gate.yml` 的 push 分支加 `next`(只跑检查;publish 仍只认 `refs/heads/staging`)。
|
||||
- 新增 `freeze-release.yml`(封板:从 `next` 切 `release/x.y`,拒绝已发版本号和已存在分支,改 `APP_VERSION`)、`release-to-staging.yml`(`release/**`、`hotfix/**` 推送:新提交必须带 `BUG-NNNN`,用 `RELEASE_PUSH_TOKEN` 把 `staging` 快进到该头——仅在 `staging` 停在已发版本或热修时允许带租约重置——触发原有 staging 流水线,并把 release 合回 `next`)、`ship-release.yml`(发版:要求测试环境正在跑该 SHA、完整发布检查已通过、版本号一致,`main` 只快进;迁移有变化时才跑恢复点与生产迁移;再跑生产部署(自动打标签);最后 `main` 合回 `next`)。
|
||||
- `deploy/branch-flow.sh` 放共用的检查与 API 调用;`docs/operations/branch-flow.md` 写日常流程和负责人要点的 Gitea 设置;`AGENTS.md` §1/§2、`deploy/README.md` 同步。
|
||||
- 用 `RELEASE_PUSH_TOKEN`(个人令牌)推送的原因:CI 自带令牌的推送不会触发后续工作流。
|
||||
- **验证**:新测试 `frontend/tests/branch-flow-2415.test.ts`(7 条:触发条件、BUG 号检查、只快进、迁移有变才跑、队列不占 production-mutation、版本号格式、文档里的设置);`staging-backend-workflows`、`health-deployment` 中钉 `branches: [staging]` 的三处按原值/新值/原因更新,其余失败与改动前相同(本机缺 yaml / rsync / docker);`test_resolve_release_revision`、`test_quality_gate_fragment_audit_once`、`test_beta_safety_net` 通过;三个新工作流 YAML 可解析。
|
||||
- **防复发**:发版规则写在工作流里由 CI 执行;`release/*` 无 BUG 号的提交不会部署;生产只从快进后的 `main` 发。
|
||||
- **关联记录**:BUG-2390/2391(完整检查只跑一次、正式部署加速)、BUG-2407(版本号与自动打标签)。
|
||||
- **修复版本**:1.6 起生效(1.5 按旧流程发布)。
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# 分支发版流程(BUG-2415,2026-11-26 负责人批准)
|
||||
|
||||
1.5 之后不再「所有窗口都推 staging、staging 整体发正式」。规则交给 CI,负责人只做两个决定:**封板**和**发版**。
|
||||
|
||||
## 分支
|
||||
|
||||
| 分支 | 放什么 | 谁推 | 推了以后 |
|
||||
|---|---|---|---|
|
||||
| `next` | 下一个版本的新功能和修复 | 各窗口随时推 | 只跑检查(backend-quality-gate 的 validate),不部署 |
|
||||
| `release/x.y` | 封板的候选版本 | 「封板」工作流创建;之后只推你测出来的问题的修复,提交信息必须带 `BUG-NNNN` | 「Release branch to staging」把 `staging` 移到这个头 → 原有 staging 流水线(检查→迁移→部署→完整发布检查);修复自动合回 `next` |
|
||||
| `hotfix/x.y.z` | 线上急修,从 `main` 拉 | 需要时手动建;提交带 `BUG-NNNN` | 同上,部署到测试环境(会暂时顶掉正在测的 release) |
|
||||
| `main` | 正式环境当前版本 | 只有「发版」工作流快进 | 生产恢复点/迁移(有迁移时)→ 生产部署 → 自动打 `v<版本>` 标签 → 合回 `next` |
|
||||
| `staging` | 测试环境指针(过渡期保留) | 只由 CI 移动;旧做法直接推 staging 仍可用,但已弃用 | 原有 staging 流水线 |
|
||||
|
||||
## 日常怎么做
|
||||
|
||||
1. 窗口开发:功能分支 → 本地检查 → 推 `next`(不再推 `staging`)。
|
||||
2. 负责人说「封板 1.6」:Gitea → Actions →「封板 Freeze release」→ Run,`version` 填 `1.6`。它从 `next` 切出 `release/1.6`、把设置页版本改成 1.6,并部署到测试环境。
|
||||
3. 测试中发现问题:修复提交(带 `BUG-NNNN`)推到 `release/1.6`;会重新部署测试环境,并自动合回 `next`。新功能照常推 `next`,不影响测试环境。
|
||||
4. 负责人说「发 1.6」:Gitea → Actions →「发版 Ship release」→ Run,`version` 填 `1.6`。前提:测试环境正在跑 `release/1.6` 的最新提交,且这个提交的完整发布检查已经通过(每次测试环境部署后自动跑)。
|
||||
5. 线上急修:从 `main` 建 `hotfix/1.6.1`,推修复 → 测试环境验证 → 「发版」填 `1.6.1`。若同时有未发的 `release/x.y`,发完后把 `main` 合进那个 release 分支。
|
||||
|
||||
## CI 自动把关
|
||||
|
||||
- 正式环境只从 `main` 部署;`main` 只能被「发版」快进到 `release/*` 或 `hotfix/*` 的头(必须是快进,不合并、不改写)。
|
||||
- 发版前检查:版本号文件(`frontend/src/lib/app-version.ts`)= 输入的版本;`v<版本>` 标签不存在;测试环境正在跑这个 SHA;这个 SHA 的完整发布检查通过。
|
||||
- `release/*`、`hotfix/*` 上每个新提交都要带 `BUG-NNNN`(合并提交和封板的版本号提交除外),否则不部署。
|
||||
- 已有的生产保护全部保留:生产只用 staging 检查产出的同 SHA 镜像,`main` 与测试环境同一提交,迁移前必须有验证过的恢复点。
|
||||
|
||||
## 负责人需要在 Gitea 里点的设置(一次性)
|
||||
|
||||
1. **建一个发版用的令牌**:用有仓库写权限的账号(建议单独建一个 `release-bot` 账号并给仓库「写」权限),设置 → 应用 → 生成新令牌,勾选 `write:repository`。复制令牌。
|
||||
2. **存成仓库密钥**:仓库 → 设置 → Actions → 密钥 → 添加,名字 `RELEASE_PUSH_TOKEN`,值是上一步的令牌。(用 CI 自带令牌推送不会触发后续流程,所以需要这个。)
|
||||
3. **建 `next` 分支**:从当前 `main`(= v1.5)建 `next`(仓库 → 分支 → 新建分支,或让协调窗口推一次)。
|
||||
4. **保护 `main`**:仓库 → 设置 → 分支 → 添加保护规则,分支名 `main`:
|
||||
- 启用推送:只允许白名单用户 → 只勾 `release-bot`(第 1 步的账号)。
|
||||
- 禁止强制推送。
|
||||
- 不要求审批(发版由「发版」工作流把关)。
|
||||
5. **保护 `release/*` 和 `hotfix/*`**:再加两条规则,分支名分别填 `release/*`、`hotfix/*`:禁止强制推送;允许推送(各窗口要推修复)。
|
||||
6. **保护 `staging`**(可选,过渡期结束后):只允许 `release-bot` 推送,彻底禁止各窗口直推。
|
||||
|
||||
## 过渡
|
||||
|
||||
- 1.5 已按旧流程发布(main = staging = 87677ca96,标签 v1.5)。
|
||||
- `staging` 分支直推仍然能部署(兼容旧窗口),但从现在起各窗口应推 `next`。第 6 步打开后直推会被拒绝。
|
||||
@@ -0,0 +1,84 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { test } from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
// BUG-2415 (owner 2026-11-26): next / release/x.y / hotfix/x.y.z / main, CI-enforced.
|
||||
const root = new URL("../../", import.meta.url);
|
||||
const read = (path: string) => readFileSync(new URL(path, root), "utf8");
|
||||
const flowScript = fileURLToPath(new URL("deploy/branch-flow.sh", root));
|
||||
const flow = (args: string[], input = "") =>
|
||||
spawnSync("bash", [flowScript, ...args], { input, encoding: "utf8" });
|
||||
|
||||
test("next only runs the checks; only staging publishes and deploys", () => {
|
||||
const gate = read(".gitea/workflows/backend-quality-gate.yml");
|
||||
assert.match(gate, /push:\n(?:\s+#[^\n]*\n)*\s+branches: \[staging, next\]/);
|
||||
assert.match(gate, /if: gitea\.event_name == 'push' && gitea\.ref == 'refs\/heads\/staging'/);
|
||||
});
|
||||
|
||||
test("封板 cuts release/x.y from next, refuses a shipped version or an existing branch, and bumps the app version", () => {
|
||||
const wf = read(".gitea/workflows/freeze-release.yml");
|
||||
assert.match(wf, /^on:\n\s+workflow_dispatch:/m);
|
||||
assert.doesNotMatch(wf, /^\s+push:/m);
|
||||
assert.match(wf, /tag-sha "v\$VERSION"/);
|
||||
assert.match(wf, /ref-sha "\$branch"/);
|
||||
assert.match(wf, /ref-sha next/);
|
||||
assert.match(wf, /APP_VERSION = \\"\$VERSION\\";/);
|
||||
assert.match(wf, /\[release-bump\]/);
|
||||
assert.match(wf, /RELEASE_PUSH_TOKEN: \$\{\{ secrets\.RELEASE_PUSH_TOKEN \}\}/);
|
||||
assert.match(wf, /git push origin "HEAD:refs\/heads\/\$branch"/);
|
||||
});
|
||||
|
||||
test("a release or hotfix push needs BUG numbers, moves staging only forward (or from the shipped head / for a hotfix) and merges back into next", () => {
|
||||
const wf = read(".gitea/workflows/release-to-staging.yml");
|
||||
assert.match(wf, /branches:\n\s+- 'release\/\*\*'\n\s+- 'hotfix\/\*\*'/);
|
||||
assert.match(wf, /commit-messages "\$base" "\$HEAD_SHA" \| bash "\$flow" bug-ids-ok/);
|
||||
assert.match(wf, /merge-base --is-ancestor "\$staging_sha" "\$HEAD_SHA"/);
|
||||
assert.match(wf, /--force-with-lease="refs\/heads\/staging:\$staging_sha"/);
|
||||
assert.match(wf, /holds another unshipped release/);
|
||||
assert.match(wf, /Merge \$branch into next/);
|
||||
assert.doesNotMatch(wf, /git push --force(?!-with-lease)/);
|
||||
});
|
||||
|
||||
test("发版 ships only a tested head: staging live on it, release checks passed, version matches, main fast-forwards", () => {
|
||||
const wf = read(".gitea/workflows/ship-release.yml");
|
||||
assert.match(wf, /^on:\n\s+workflow_dispatch:/m);
|
||||
assert.match(wf, /\[ "\$staging_sha" = "\$sha" \]/);
|
||||
assert.match(wf, /\.deployment\.gitCommit/);
|
||||
assert.match(wf, /release-gate-passed "\$sha"/);
|
||||
assert.match(wf, /APP_VERSION \$version_now, not \$VERSION/);
|
||||
assert.match(wf, /merge-base --is-ancestor "\$main_before" "\$sha"/);
|
||||
assert.match(wf, /git push origin "\$sha:refs\/heads\/main"/);
|
||||
assert.doesNotMatch(wf, /--force/);
|
||||
// Recovery and migration only when migrations changed; the deploy always runs after them.
|
||||
const recovery = wf.indexOf("create-production-recovery.yml");
|
||||
const migrate = wf.indexOf("migrate-production-database.yml");
|
||||
const deploy = wf.indexOf("deploy-production.yml");
|
||||
assert.ok(recovery > 0 && recovery < migrate && migrate < deploy);
|
||||
assert.match(wf, /if bash "\$flow" migrations-changed "\$main_before" "\$sha"; then/);
|
||||
// Its own queue: the production workflows it starts hold production-mutation themselves.
|
||||
assert.match(wf, /group: release-flow/);
|
||||
assert.doesNotMatch(wf, /group: production-mutation/);
|
||||
assert.match(wf, /Merge v\$VERSION \(main\) into next/);
|
||||
});
|
||||
|
||||
test("branch-flow.sh accepts BUG-numbered, merge and release-bump commits and names the rest", () => {
|
||||
const ok = flow(["bug-ids-ok"], "fix(chart): a (BUG-2415)\0Merge branch 'x' into next\0chore(release): freeze 1.6 [release-bump]\0");
|
||||
assert.equal(ok.status, 0, ok.stderr);
|
||||
const bad = flow(["bug-ids-ok"], "fix(chart): a (BUG-2415)\0fix: no number here\0");
|
||||
assert.equal(bad.status, 1);
|
||||
assert.match(bad.stderr, /missing BUG number: fix: no number here/);
|
||||
});
|
||||
|
||||
test("branch-flow.sh only takes x.y or x.y.z versions", () => {
|
||||
for (const good of ["1.6", "1.6.1", "2.0"]) assert.equal(flow(["validate-version", good]).status, 0, good);
|
||||
for (const bad of ["v1.6", "1", "1.6-rc", "../x", ""]) assert.notEqual(flow(["validate-version", bad]).status, 0, bad);
|
||||
});
|
||||
|
||||
test("the owner's one-time Gitea settings are documented", () => {
|
||||
const doc = read("docs/operations/branch-flow.md");
|
||||
for (const item of ["RELEASE_PUSH_TOKEN", "write:repository", "保护 `main`", "release/*", "hotfix/*", "禁止强制推送"]) {
|
||||
assert.ok(doc.includes(item), item);
|
||||
}
|
||||
});
|
||||
@@ -193,7 +193,8 @@ test("staging deploy consumes only the isolated staging environment and tested r
|
||||
"utf8",
|
||||
);
|
||||
|
||||
assert.match(qualityGate, /push:\s*\n\s*branches: \[staging\]/);
|
||||
// 原值:/push:\s*\n\s*branches: \[staging\]/ 新值:[staging, next] 原因:BUG-2415 next 只跑检查,部署仍只从 staging
|
||||
assert.match(qualityGate, /push:\s*\n(?:\s*#[^\n]*\n)*\s*branches: \[staging, next\]/);
|
||||
// 原值:/actions: read/ 新值:/actions: write/ 原因:BUG-2390 跟进,deploy-staging 要排队完整发布检查(dispatch 需要写权限)
|
||||
assert.match(workflow, /actions: write/);
|
||||
assert.match(workflow, /deploy_sha:/);
|
||||
|
||||
@@ -214,7 +214,9 @@ test("Gitea quality gate validates before publishing an immutable ACR manifest",
|
||||
const workflow = read(giteaQualityWorkflow);
|
||||
|
||||
assert.match(workflow, /pull_request:\n\s+paths:/);
|
||||
assert.match(workflow, /push:\n\s+branches: \[staging\]/);
|
||||
// 原值:/push:\n\s+branches: \[staging\]/ 新值:push 分支是 [staging, next],publish 仍只认 staging 原因:BUG-2415 分支发版流程,next 只跑检查不部署
|
||||
assert.match(workflow, /push:\n(?:\s+#[^\n]*\n)*\s+branches: \[staging, next\]/);
|
||||
assert.match(workflow, /if: gitea\.event_name == 'push' && gitea\.ref == 'refs\/heads\/staging'/);
|
||||
assert.match(workflow, /workflow_dispatch:/);
|
||||
// 原值 → 新值见各行;原因:CI 提速,validate 拆成 validate-python 与 validate-frontend 两个并行 job(各自 checkout),venv 改为 deploy/ci-python-venv.sh 的主机缓存,npm 下载缓存持久化。
|
||||
// 原值 2 个 runs-on;新值 3 个(两个 validate job + publish)。
|
||||
@@ -1522,7 +1524,8 @@ function gatedGlobs(): string[] {
|
||||
}
|
||||
|
||||
function triggerPaths(workflow: string, trigger: "pull_request" | "push"): string[] {
|
||||
const block = workflow.match(new RegExp(`\\n ${trigger}:\\n(?: branches: \\[staging\\]\\n)? paths:\\n((?: - '[^'\\n]+'\\n)+)`));
|
||||
// 原值:只认 `branches: [staging]` 新值:也认 `branches: [staging, next]` 原因:BUG-2415 next 只跑检查
|
||||
const block = workflow.match(new RegExp(`\\n ${trigger}:\\n(?: branches: \\[staging(?:, next)?\\]\\n)? paths:\\n((?: - '[^'\\n]+'\\n)+)`));
|
||||
assert.ok(block, `${trigger} trigger has no paths list`);
|
||||
return [...block[1].matchAll(/ - '([^'\n]+)'\n/g)].map((match) => match[1]);
|
||||
}
|
||||
@@ -1560,7 +1563,8 @@ test("gated paths are one list shared by both quality-gate triggers", () => {
|
||||
assert.ok(globs.length > 0, "deploy/gated-paths.txt must not be empty");
|
||||
assert.deepEqual(triggerPaths(workflow, "pull_request"), globs);
|
||||
assert.deepEqual(triggerPaths(workflow, "push"), globs);
|
||||
assert.match(workflow, /push:\n\s+branches: \[staging\]\n\s+paths:\n/);
|
||||
// 原值:/push:\n\s+branches: \[staging\]\n\s+paths:\n/ 新值:[staging, next] 原因:BUG-2415
|
||||
assert.match(workflow, /push:\n(?:\s+#[^\n]*\n)*\s+branches: \[staging, next\]\n\s+paths:\n/);
|
||||
assert.deepEqual(new Set(globs).size, globs.length, "gated globs must be unique");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user