blueprint-shared-templates 0.5.1 → 0.6.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.
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
| `.github/ISSUE_TEMPLATE/*.yml` | bug、feature、hotfix 三種 Issue |
|
|
9
9
|
| `releases/release-plan.md` | 一版一份的發布規劃範本,複製成主檔的 `releases/release-plan-v{X.Y.Z}.md`。維護型發布規劃由 `scripts/release/plan.sh maintenance` 寫出,不從這份範本複製 |
|
|
10
10
|
| `.github/CODEOWNERS.example` | 複製成 `.github/CODEOWNERS`,列出版號與發布相關檔案的審查者。`scripts/hooks/pre-push` 也讀它,推上 main 的變更碰到這些路徑時擋下,改走 PR |
|
|
11
|
-
| `scripts/hooks/commit-msg`、`scripts/hooks/pre-push` | 訊息格式與 AI
|
|
11
|
+
| `scripts/hooks/commit-msg`、`scripts/hooks/pre-push` | 訊息格式與 AI 平台署名的檢查,推送預設分支前再查一次推送範圍的訊息並跑建置測試。`scripts/setup/git-hooks.sh` 在 `.git/hooks/` 放兩個轉呼叫檔交給它們,不設倉內的 `core.hooksPath`,所以機器的全域 hook 照常跑。它由 `pnpm install` 的 `prepare` 執行,使用者在自己的終端機執行(代理執行會被權限規則擋下) |
|
|
12
12
|
| `.github/workflows/main-commit-check.yml` | 每天核對預設分支前一天的 commit 訊息格式與 AI 平台署名,呼叫 `scripts/ci/check-main-commits.sh` |
|
|
13
13
|
| `.github/workflows/pr-message.yml` | PR 標題與內文的同一組檢查,squash 後標題與內文就是 commit 訊息 |
|
|
14
14
|
| `scripts/setup/github-repo-settings.sh`、`scripts/setup/github-repo-settings.json` | 把倉庫鎖定成只允許 squash 合併、合併後刪分支,並設定 Actions 產物與 log 的保留天數。值寫在旁邊的 JSON。可以一次指定多個倉。`--dry-run` 只印要送的請求,套用前先讀現值,已相同的設定不送 |
|
|
15
15
|
|
|
16
16
|
訊息檢查的腳本在 `scripts/ci/`:`check-pr-title.sh`、`check-commit-body.sh`、`check-main-commits.sh` 與 `ai-attribution-list.txt`。
|
|
17
17
|
|
|
18
|
-
`pre-push` 檢查推上 main 的 commit:訊息格式與 AI 平台署名、每個 commit 只動一個發布單元、不碰 `.github/CODEOWNERS` 列的治理路徑、沒有破壞性變更,通過後跑 `scripts/ci/run-affected.sh` 的 lint、build、test
|
|
18
|
+
`pre-push` 檢查推上 main 的 commit:訊息格式與 AI 平台署名、每個 commit 只動一個發布單元、不碰 `.github/CODEOWNERS` 列的治理路徑、沒有破壞性變更,通過後跑 `scripts/ci/run-affected.sh` 的 lint、build、test。轉呼叫檔交給所在工作樹根的 `scripts/hooks/<name>`,所以在 linked worktree 裡跑的是那個 worktree 自己的 hook。機器設了全域 `core.hooksPath` 時,git 只跑全域那組,那組會轉給 `.git/hooks/<name>` 時,倉的 hook 才會跑。
|
|
19
19
|
|
|
20
20
|
每日核對 workflow 的 runner 讀倉庫變數 `LINUX_RUNNER`,沒設時用 self-hosted 的 `self-hosted-linux`。改用其他 runner 時,只要有 git 與 bash 4 就能跑。倉庫沒有 self-hosted runner 時,把 `LINUX_RUNNER` 設成 `ubuntu-latest`。
|
|
21
21
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// has a path filter: when none of the changed files matches, that workflow did not run and the check
|
|
15
15
|
// counts as skipped. reviewPaths are the CODEOWNERS style paths (blueprint-shared.git-flow.review-paths) that need
|
|
16
16
|
// a review; empty or missing means no pull request needs one here. syncPr is { author, branch }: the
|
|
17
|
-
// pull request that
|
|
17
|
+
// pull request that the repository that holds the templates opens in a demonstration repository to bring it up to date, which needs no review.
|
|
18
18
|
// pr also needs author ({ login, is_bot }) and latestReviews ([{ state }]) from `gh pr view --json`.
|
|
19
19
|
// Output: one JSON line { action, reason, ... }. action is "merge", "merge-release-pr" or "skip". A skip because a
|
|
20
20
|
// required check failed also lists those checks in failed.
|
|
@@ -96,7 +96,7 @@ export function decide({ pr, checkedSha, checks = [], changedFiles = [] }, confi
|
|
|
96
96
|
if (missing.length > 0) return skip(`required check has not run: ${missing.join(", ")}`, { pr: number });
|
|
97
97
|
|
|
98
98
|
const release = pr.headRefName.startsWith(RELEASE_PR_HEAD);
|
|
99
|
-
// A change to a review path needs an approving review, except a sync pull request (
|
|
99
|
+
// A change to a review path needs an approving review, except a sync pull request (the pull request that brings a demonstration repository up to date)
|
|
100
100
|
// and a Release PR, which merge-release-pr.sh merges on a machine. The required checks above still have to pass for all of them.
|
|
101
101
|
if (!release && !isSyncPr(pr, config.syncPr) && touchesReviewPath(changedFiles, config.reviewPaths)) {
|
|
102
102
|
const states = (pr.latestReviews ?? []).map((r) => r.state);
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
2
|
+
# Puts forwarding files for commit-msg and pre-push into the repository's common hooks directory
|
|
3
|
+
# ($(git rev-parse --git-common-dir)/hooks, which linked worktrees share). Each one hands its arguments and
|
|
4
|
+
# stdin to scripts/hooks/<name> of the working tree it runs in, which guard the local lane into main, and
|
|
5
|
+
# exits 0 when that file is missing or not executable. Runs from pnpm's prepare on every install, so a fresh
|
|
6
|
+
# clone is guarded without a separate step.
|
|
7
|
+
#
|
|
8
|
+
# The repository's core.hooksPath stays unset: a value there overrides a hooksPath the machine set globally,
|
|
9
|
+
# and the machine's hooks would stop running. A machine that sets a global hooksPath runs only those hooks;
|
|
10
|
+
# the repository's hooks run when those hand over to .git/hooks/<name>. An older version of this script set
|
|
11
|
+
# core.hooksPath to scripts/hooks in the shared config; that exact value is removed, any other value (or one
|
|
12
|
+
# in a worktree's own config) stays and is reported, since it hides the forwarding files. A file of the same
|
|
13
|
+
# name in the hooks directory that this script did not write (no marker on line 2) is left alone and the
|
|
14
|
+
# script exits non-zero. Outside a working tree (a bare repository, an unpacked tarball) it does nothing.
|
|
15
|
+
#
|
|
16
|
+
# A repository that only takes changes through PRs drops the prepare script from package.json and deletes
|
|
17
|
+
# .git/hooks/commit-msg and .git/hooks/pre-push.
|
|
6
18
|
#
|
|
7
19
|
# Also sets commit.cleanup scissors. Messages use "## " section headings (docs/git-flow.md, commit 與 PR
|
|
8
20
|
# 訊息格式); when a message is written in the editor, git's default cleanup (strip) deletes every line
|
|
@@ -10,7 +22,65 @@
|
|
|
10
22
|
# places below a scissors line. Messages given with -m or -F are not edited and keep "#" lines either way.
|
|
11
23
|
# usage: git-hooks.sh
|
|
12
24
|
set -euo pipefail
|
|
13
|
-
|
|
14
|
-
git
|
|
25
|
+
# A bare repository prints false with status 0, so compare the output.
|
|
26
|
+
[[ "$(git rev-parse --is-inside-work-tree 2>/dev/null || true)" == true ]] || exit 0
|
|
27
|
+
|
|
28
|
+
marker='# managed by scripts/setup/git-hooks.sh'
|
|
29
|
+
names="commit-msg pre-push"
|
|
30
|
+
common="$(git rev-parse --path-format=absolute --git-common-dir)"
|
|
31
|
+
hooks="$common/hooks"
|
|
32
|
+
|
|
33
|
+
foreign=""
|
|
34
|
+
for name in $names; do
|
|
35
|
+
file="$hooks/$name"
|
|
36
|
+
if [[ -e "$file" || -L "$file" ]] && [[ "$(sed -n 2p "$file" 2>/dev/null)" != "$marker"* ]]; then
|
|
37
|
+
foreign="$foreign $file"$'\n'
|
|
38
|
+
fi
|
|
39
|
+
done
|
|
40
|
+
if [[ -n "$foreign" ]]; then
|
|
41
|
+
{
|
|
42
|
+
printf '%s\n' "git-hooks.sh:下列檔不是這支腳本放的,沒有覆寫:"
|
|
43
|
+
printf '%s' "$foreign"
|
|
44
|
+
printf '%s\n' "處理方式:確認它的用途,把要保留的檢查併進 scripts/hooks/ 的同名檔後刪掉它,或改由那支檔呼叫 scripts/hooks/<name>,再跑一次 pnpm install。"
|
|
45
|
+
} >&2
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if [[ "$(git config --file "$common/config" --get core.hooksPath || true)" == scripts/hooks ]]; then
|
|
50
|
+
git config --file "$common/config" --unset core.hooksPath
|
|
51
|
+
printf '%s\n' "git-hooks.sh:移除舊版設的 core.hooksPath=scripts/hooks,改用 ${hooks} 的轉呼叫檔"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
mkdir -p "$hooks"
|
|
55
|
+
for name in $names; do
|
|
56
|
+
tmp="$hooks/.$name.tmp.$$"
|
|
57
|
+
cat >"$tmp" <<EOF
|
|
58
|
+
#!/bin/sh
|
|
59
|
+
$marker: hands over to scripts/hooks/<name> of the working tree
|
|
60
|
+
top="\$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
|
|
61
|
+
hook="\$top/scripts/hooks/\${0##*/}"
|
|
62
|
+
[ -x "\$hook" ] || exit 0
|
|
63
|
+
exec "\$hook" "\$@"
|
|
64
|
+
EOF
|
|
65
|
+
chmod +x "$tmp"
|
|
66
|
+
mv -f "$tmp" "$hooks/$name"
|
|
67
|
+
done
|
|
68
|
+
|
|
15
69
|
git config commit.cleanup scissors
|
|
16
|
-
|
|
70
|
+
|
|
71
|
+
found="$(git config --show-scope --get core.hooksPath || true)"
|
|
72
|
+
if [[ -n "$found" ]]; then
|
|
73
|
+
tab=$'\t'
|
|
74
|
+
scope="${found%%"$tab"*}"
|
|
75
|
+
value="${found#*"$tab"}"
|
|
76
|
+
case "$scope" in
|
|
77
|
+
global | system)
|
|
78
|
+
printf '%s\n' "這台機器的 ${scope} 設定有 core.hooksPath=${value},git 只跑那裡的 hook。那組 hook 會轉給 .git/hooks/<name> 時,倉的 hook 才會跑。"
|
|
79
|
+
;;
|
|
80
|
+
*)
|
|
81
|
+
printf '%s\n' "git-hooks.sh:${scope} 設定有 core.hooksPath=${value},git 只跑那裡的 hook,${hooks} 的轉呼叫檔不會被執行。要讓倉的 hook 跑,移除那筆設定:git config --$scope --unset core.hooksPath" >&2
|
|
82
|
+
exit 0
|
|
83
|
+
;;
|
|
84
|
+
esac
|
|
85
|
+
fi
|
|
86
|
+
printf '%s\n' "git hooks → ${hooks}(commit-msg、pre-push 轉給 scripts/hooks);commit.cleanup → scissors"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# usage: healthz.sh <worker> <env> <worker> is <unit>-<env>, the name wrangler.toml gives the environment
|
|
5
5
|
# reads: ops/urls.json { "<env>": "<base URL of a Worker, with {worker} where its name goes>" }
|
|
6
|
-
# compose writes the file from the URL patterns that the ops unit of the repository publishes (
|
|
6
|
+
# compose writes the file from the URL patterns that the ops unit of the repository publishes (the
|
|
7
7
|
# interface of the unit), so the patterns are not a repository variable.
|
|
8
8
|
set -euo pipefail
|
|
9
9
|
worker="${1:?usage: healthz.sh <worker> <env>}"
|
package/org/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @@repoName@@
|
|
2
2
|
|
|
3
|
-
`@@organization@@` 組織在組織層的 `@@repoName@@`
|
|
3
|
+
`@@organization@@` 組織在組織層的 `@@repoName@@` 倉。它是導入方的組織層倉,放這個組織的組織值與組織層的倉清單,也可以放組織自己的規則,不放持有範本的倉的職責。共用套件、範本與組織層倉範本由管理中樞發布,這個倉只放組織層倉該有的東西。
|
|
4
4
|
|
|
5
5
|
## 放什麼
|
|
6
6
|
|
|
7
|
-
- `facts/` 是 `@@aggregatePackageName
|
|
7
|
+
- `facts/` 是 `@@aggregatePackageName@@`。它至少有兩筆 fact:組織值(`@@repoName@@.org-values`,欄位定義在共用 fact `blueprint-shared.org-values`,fact-kit 依那份 schema 驗證),以及組織層的倉清單(`@@repoName@@.org-layout.repos`)。組織可以另放自己的規則。
|
|
8
8
|
- `docs/` 是 `@@scope@@/@@repoName@@-docs`。它放組織層的文件,並引用上面的 fact 與共用 fact。`docs/@@repoName@@-docs/@@repoName@@/layer-names.doc.ts` 寫出各倉的 facts、docs 套件名怎麼從這一層推出。
|
|
9
9
|
- `scripts/ci/check-org-values.mjs` 逐欄位核對組織值,缺欄位、多欄位或型別不對時印出欄位名。
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -792,7 +792,7 @@ train_gates() { # train_gates <branch> <line> <stage>
|
|
|
792
792
|
# all stop the gate. A repository with no such unit passes without a query. It queries once and never waits; whoever calls it waits for the deploy and runs it again.
|
|
793
793
|
# Whether the repository deploys is decided by its deploy-prerelease.yml. When that file reads
|
|
794
794
|
# vars.DEPLOY_ENABLED outside a comment (the condition the templates keep for the demo repositories), a repository whose variable DEPLOY_ENABLED is not
|
|
795
|
-
# true (
|
|
795
|
+
# true (the demonstration repository's own value first, the organization's only when the repository has none)
|
|
796
796
|
# deploys nothing, so there is no run to look for and its units pass with the reason printed. A variable list that cannot be read stops
|
|
797
797
|
# the gate, because it must not be taken for "not enabled". When the file has no such line, or does not exist, the repository removed the
|
|
798
798
|
# condition and deploys whenever the workflow runs: the variable is not read and the gate checks the run as usual.
|