fix(guards): design 零依赖门禁覆盖 dev/build 依赖表(M89 复审 p2-2)
cargo tree --edges normal 看不到 dev-dependencies / build-dependencies,而 design 对外承诺的是「零第三方依赖」,不分 normal/dev/build。新增一步「依赖表必须为空」: 按表头切出 dependencies / dev-dependencies / build-dependencies / target.*.dependencies (含 [dependencies.serde] 子表写法,表头携带包名),有任何一个键即失败;原「依赖树只允许 出现自身」那步保留,两道互补。 实测:基线绿;[dev-dependencies] serde 红(同一时刻 tree step 仍绿,正是原来的盲区); [build-dependencies] digest 红。老 job(core-no-ui / file-size / licenses)解析后仍与 main 相等。
This commit is contained in:
1 parent
48061c3f31
commit
e9034a40c8
1 file changed
+24
-1
@@ -3,7 +3,7 @@ name: Guards
|
|||||||
# 架构与合规守门(与 fmt/clippy 同级,不允许 continue-on-error):
|
# 架构与合规守门(与 fmt/clippy 同级,不允许 continue-on-error):
|
||||||
# 1. core-no-ui —— crates/core 零 UI 依赖(D3 铁律),依赖表 + cargo tree 双查
|
# 1. core-no-ui —— crates/core 零 UI 依赖(D3 铁律),依赖表 + cargo tree 双查
|
||||||
# 2. presenter-no-ui —— crates/presenter 零 UI 依赖(D26 / M85):Slint 版与 iced 版共用的宿主层
|
# 2. presenter-no-ui —— crates/presenter 零 UI 依赖(D26 / M85):Slint 版与 iced 版共用的宿主层
|
||||||
# 3. design-zero-dep —— crates/design 零第三方依赖(M61 / M87):依赖树只允许出现自身
|
# 3. design-zero-dep —— crates/design 零第三方依赖(M61 / M87):依赖表(含 dev/build)必须为空 + 依赖树只允许出现自身
|
||||||
# 4. file-size —— 全仓代码/文档单文件 ≤400 行(用户硬约束)
|
# 4. file-size —— 全仓代码/文档单文件 ≤400 行(用户硬约束)
|
||||||
# 5. licenses —— cargo-deny:许可证白名单 + GPL 依赖拦截 + 供应链来源校验
|
# 5. licenses —— cargo-deny:许可证白名单 + GPL 依赖拦截 + 供应链来源校验
|
||||||
|
|
||||||
@@ -100,12 +100,35 @@ jobs:
|
|||||||
|
|
||||||
# unlucky-design 是「纯数据 + 纯函数、零第三方依赖」的设计令牌层,这是 README 明写的卖点
|
# unlucky-design 是「纯数据 + 纯函数、零第三方依赖」的设计令牌层,这是 README 明写的卖点
|
||||||
# (连 serde 都不加),但目前只靠人肉守。零依赖的判据比 UI 名单更硬:依赖树只允许有自己一行。
|
# (连 serde 都不加),但目前只靠人肉守。零依赖的判据比 UI 名单更硬:依赖树只允许有自己一行。
|
||||||
|
# 注意 `cargo tree --edges normal` 看不到 dev/build 依赖,所以另设一步按表头切依赖表逐个查空。
|
||||||
design-zero-dep:
|
design-zero-dep:
|
||||||
name: design 零第三方依赖守门
|
name: design 零第三方依赖守门
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- name: 依赖表必须为空(dependencies / dev / build 表一律不许有键,含子表写法)
|
||||||
|
run: |
|
||||||
|
set -uo pipefail
|
||||||
|
# design 承诺的是「零第三方依赖」,不分 normal / dev / build —— 而 cargo tree
|
||||||
|
# --edges normal 对 dev/build 是瞎的。所以先按表头切出全部依赖表(含
|
||||||
|
# `[dependencies.serde]` 这类子表写法,表头本身携带包名),再看是否为空。
|
||||||
|
awk '
|
||||||
|
/^[[:space:]]*\[/ {
|
||||||
|
in_deps = ($0 ~ /^[[:space:]]*\[(target\..*\.)?(dependencies|dev-dependencies|build-dependencies)(\.[^]]*)?\][[:space:]]*$/)
|
||||||
|
if (in_deps && $0 ~ /\.[^]]*\]/) printf "%d:%s\n", NR, $0
|
||||||
|
next
|
||||||
|
}
|
||||||
|
in_deps && !/^[[:space:]]*#/ && !/^[[:space:]]*$/ { printf "%d:%s\n", NR, $0 }
|
||||||
|
' crates/design/Cargo.toml > /tmp/design-deps.txt
|
||||||
|
if [ -s /tmp/design-deps.txt ]; then
|
||||||
|
cat /tmp/design-deps.txt
|
||||||
|
echo "::error file=crates/design/Cargo.toml::unlucky-design 的依赖表必须为空(normal / dev / build 都算),本次命中:"
|
||||||
|
sed 's/^/ - /' /tmp/design-deps.txt
|
||||||
|
echo "::error::design 是纯数据 + 纯函数的设计令牌,README 对外承诺零第三方依赖(连 serde 都不加):色彩 / 排版 / 形状 / 高程 / 动效请不要引入任何 crate,测试与构建辅助依赖同样不许加。序列化与运行时能力放到消费方(app / app-iced / presenter)。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "OK: crates/design/Cargo.toml 依赖表全空(含 dev / build)"
|
||||||
- name: 依赖树只允许出现自身(cargo tree -p unlucky-design --edges normal)
|
- name: 依赖树只允许出现自身(cargo tree -p unlucky-design --edges normal)
|
||||||
run: |
|
run: |
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
|
|||||||
Reference in new issue
Block a user