From 1e3cd6f8dcbe37a351dab8f63181a2ed21738062 Mon Sep 17 00:00:00 2001 From: Zhe Feng Date: Fri, 6 Nov 2026 13:36:43 +0000 Subject: [PATCH 1/2] refactor(tools): move CI-only scripts into tools/ci Move test_template.py, check_mwrap_release.py and template_smoke.sh next to the other CI entry points, adjust their repository-root resolution, and update the workflows, package-source.sh, .gitignore and architecture docs. --- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 4 ++-- .gitignore | 2 +- docs/architecture.md | 4 ++-- docs/architecture.zh.md | 4 ++-- tools/{ => ci}/check_mwrap_release.py | 2 +- tools/{ => ci}/template_smoke.sh | 8 ++++---- tools/{ => ci}/test_template.py | 8 ++++---- tools/package-source.sh | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) rename tools/{ => ci}/check_mwrap_release.py (98%) rename tools/{ => ci}/template_smoke.sh (60%) rename tools/{ => ci}/test_template.py (97%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 466b2dffd..e261860c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: python-version: "3.12" - name: Check tag, upstream version, licence split and entry pages - run: python3 tools/check_mwrap_release.py --tag "$GITHUB_REF_NAME" + run: python3 tools/ci/check_mwrap_release.py --tag "$GITHUB_REF_NAME" - name: Require successful source CI at this exact commit env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c6499a1e6..285eca63a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -344,7 +344,7 @@ jobs: run: | set -euo pipefail PY="$(command -v python3 || command -v python)" - "$PY" tools/test_template.py --toolchain "${{ matrix.toolchain }}" + "$PY" tools/ci/test_template.py --toolchain "${{ matrix.toolchain }}" - name: Check release coordinate and bilingual entry pages if: matrix.name == 'linux-gcc' && matrix.arch == 'x86_64' @@ -352,4 +352,4 @@ jobs: run: | set -euo pipefail PY="$(command -v python3 || command -v python)" - "$PY" tools/check_mwrap_release.py + "$PY" tools/ci/check_mwrap_release.py diff --git a/.gitignore b/.gitignore index 45750d167..3fc5a9dad 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,7 @@ compile_commands.json *.dwo *.d -# Local test scratch (tools/test_template.py keeps its workspace here so the +# Local test scratch (tools/ci/test_template.py keeps its workspace here so the # mcpp shim can resolve the project-pinned toolchain) .tmp/ diff --git a/docs/architecture.md b/docs/architecture.md index 8293f8834..cc3dd7615 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -196,9 +196,9 @@ keeps byte-identical notices. - `tools/ci/verify_generated.py`: import/replay, generation, feature splice and audit on a clean tree, with `git diff`/`git status` as the oracle; a second build on the same configuration records the incremental TU count and mtimes. -- `tools/check_mwrap_release.py`: identity, version scheme, tag, licence split and +- `tools/ci/check_mwrap_release.py`: identity, version scheme, tag, licence split and retained-document bytes. -- `tools/test_template.py`: installs an isolated `MCPP_HOME` fixture, runs a real +- `tools/ci/test_template.py`: installs an isolated `MCPP_HOME` fixture, runs a real `mcpp new`, parses the rendered manifest (complete selector, version, features), then builds and runs the project — no sed rendering. - `tools/package-source.sh`: `boost-m-.tar.gz` from the tracked tree, diff --git a/docs/architecture.zh.md b/docs/architecture.zh.md index b6f0b6eb8..336dbcc3c 100644 --- a/docs/architecture.zh.md +++ b/docs/architecture.zh.md @@ -183,9 +183,9 @@ feature(两种 Boost.Test 形态绝不能链接在一起)。 - `tools/ci/verify_generated.py`:在干净代码树上跑导入/重放、生成、feature 拼接 和审计,以 `git diff`/`git status` 作为判定依据;在同一配置上再做一次构建, 记录增量 TU 数量和 mtime。 -- `tools/check_mwrap_release.py`:校验标识、版本方案、tag、许可证拆分以及保留 +- `tools/ci/check_mwrap_release.py`:校验标识、版本方案、tag、许可证拆分以及保留 文档的字节。 -- `tools/test_template.py`:安装隔离的 `MCPP_HOME` 测试环境,执行真实的 +- `tools/ci/test_template.py`:安装隔离的 `MCPP_HOME` 测试环境,执行真实的 `mcpp new`,解析渲染出的清单(完整选择器、版本、features),然后构建并运行 该项目——不使用 sed 渲染。 - `tools/package-source.sh`:从受版本控制的代码树生成 diff --git a/tools/check_mwrap_release.py b/tools/ci/check_mwrap_release.py similarity index 98% rename from tools/check_mwrap_release.py rename to tools/ci/check_mwrap_release.py index 2b6a15c4f..a13ee8b91 100755 --- a/tools/check_mwrap_release.py +++ b/tools/ci/check_mwrap_release.py @@ -18,7 +18,7 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--tag", help="release tag; omitted during PR checks") args = parser.parse_args() - root = Path(__file__).resolve().parents[1] + root = Path(__file__).resolve().parents[2] manifest = tomllib.loads((root / "mcpp.toml").read_text(encoding="utf-8")) package = manifest["package"] diff --git a/tools/template_smoke.sh b/tools/ci/template_smoke.sh similarity index 60% rename from tools/template_smoke.sh rename to tools/ci/template_smoke.sh index 6370c9deb..e15179adc 100755 --- a/tools/template_smoke.sh +++ b/tools/ci/template_smoke.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash # Render every shipped template through a real `mcpp new`, then build and run it. # -# The work lives in tools/test_template.py: it installs an isolated MCPP_HOME +# The work lives in tools/ci/test_template.py: it installs an isolated MCPP_HOME # fixture for the candidate version, runs mcpp's own renderer, parses the # rendered manifest (complete selector, version, features) with tomllib, and only # then redirects the dependency to the fixture. Hand-substituting placeholders # with sed is explicitly not evidence for a template. # -# Usage: bash tools/template_smoke.sh [--template NAME] [--toolchain SPEC] +# Usage: bash tools/ci/template_smoke.sh [--template NAME] [--toolchain SPEC] set -euo pipefail -ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -exec python3 "$ROOT/tools/test_template.py" "$@" +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +exec python3 "$ROOT/tools/ci/test_template.py" "$@" diff --git a/tools/test_template.py b/tools/ci/test_template.py similarity index 97% rename from tools/test_template.py rename to tools/ci/test_template.py index e24c4ddf4..412aa3dbe 100755 --- a/tools/test_template.py +++ b/tools/ci/test_template.py @@ -13,9 +13,9 @@ dependency is redirected to the fixture with the same parser, features kept. Usage: - python3 tools/test_template.py # default template - python3 tools/test_template.py --template lib # a named template - python3 tools/test_template.py --keep # leave the fixture on disk + python3 tools/ci/test_template.py # default template + python3 tools/ci/test_template.py --template lib # a named template + python3 tools/ci/test_template.py --keep # leave the fixture on disk """ import argparse import json @@ -27,7 +27,7 @@ import tempfile import tomllib -ROOT = Path(__file__).resolve().parents[1] +ROOT = Path(__file__).resolve().parents[2] def package_identity(): diff --git a/tools/package-source.sh b/tools/package-source.sh index 12288033b..e58af862a 100755 --- a/tools/package-source.sh +++ b/tools/package-source.sh @@ -42,7 +42,7 @@ if git rev-parse --git-dir >/dev/null 2>&1; then fi if command -v python3 >/dev/null 2>&1; then - python3 tools/check_mwrap_release.py + python3 tools/ci/check_mwrap_release.py fi NAME="boost-m-$VERSION" From 273d8cefc70993c54fdaedfa69ac16078b1c55f7 Mon Sep 17 00:00:00 2001 From: Zhe Feng Date: Fri, 6 Nov 2026 13:50:13 +0000 Subject: [PATCH 2/2] refactor(tools): drop template_smoke.sh, keep check_mwrap_release.py in tools/ template_smoke.sh only forwarded to test_template.py and had no callers. check_mwrap_release.py is also run by tools/package-source.sh, so it is not CI-only and stays at its original path. --- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- docs/architecture.md | 2 +- docs/architecture.zh.md | 2 +- tools/{ci => }/check_mwrap_release.py | 2 +- tools/ci/template_smoke.sh | 14 -------------- tools/package-source.sh | 2 +- 7 files changed, 6 insertions(+), 20 deletions(-) rename tools/{ci => }/check_mwrap_release.py (98%) delete mode 100755 tools/ci/template_smoke.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e261860c7..466b2dffd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: python-version: "3.12" - name: Check tag, upstream version, licence split and entry pages - run: python3 tools/ci/check_mwrap_release.py --tag "$GITHUB_REF_NAME" + run: python3 tools/check_mwrap_release.py --tag "$GITHUB_REF_NAME" - name: Require successful source CI at this exact commit env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 285eca63a..a76475e75 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -352,4 +352,4 @@ jobs: run: | set -euo pipefail PY="$(command -v python3 || command -v python)" - "$PY" tools/ci/check_mwrap_release.py + "$PY" tools/check_mwrap_release.py diff --git a/docs/architecture.md b/docs/architecture.md index cc3dd7615..32199d018 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -196,7 +196,7 @@ keeps byte-identical notices. - `tools/ci/verify_generated.py`: import/replay, generation, feature splice and audit on a clean tree, with `git diff`/`git status` as the oracle; a second build on the same configuration records the incremental TU count and mtimes. -- `tools/ci/check_mwrap_release.py`: identity, version scheme, tag, licence split and +- `tools/check_mwrap_release.py`: identity, version scheme, tag, licence split and retained-document bytes. - `tools/ci/test_template.py`: installs an isolated `MCPP_HOME` fixture, runs a real `mcpp new`, parses the rendered manifest (complete selector, version, features), diff --git a/docs/architecture.zh.md b/docs/architecture.zh.md index 336dbcc3c..29f7469bc 100644 --- a/docs/architecture.zh.md +++ b/docs/architecture.zh.md @@ -183,7 +183,7 @@ feature(两种 Boost.Test 形态绝不能链接在一起)。 - `tools/ci/verify_generated.py`:在干净代码树上跑导入/重放、生成、feature 拼接 和审计,以 `git diff`/`git status` 作为判定依据;在同一配置上再做一次构建, 记录增量 TU 数量和 mtime。 -- `tools/ci/check_mwrap_release.py`:校验标识、版本方案、tag、许可证拆分以及保留 +- `tools/check_mwrap_release.py`:校验标识、版本方案、tag、许可证拆分以及保留 文档的字节。 - `tools/ci/test_template.py`:安装隔离的 `MCPP_HOME` 测试环境,执行真实的 `mcpp new`,解析渲染出的清单(完整选择器、版本、features),然后构建并运行 diff --git a/tools/ci/check_mwrap_release.py b/tools/check_mwrap_release.py similarity index 98% rename from tools/ci/check_mwrap_release.py rename to tools/check_mwrap_release.py index a13ee8b91..2b6a15c4f 100755 --- a/tools/ci/check_mwrap_release.py +++ b/tools/check_mwrap_release.py @@ -18,7 +18,7 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--tag", help="release tag; omitted during PR checks") args = parser.parse_args() - root = Path(__file__).resolve().parents[2] + root = Path(__file__).resolve().parents[1] manifest = tomllib.loads((root / "mcpp.toml").read_text(encoding="utf-8")) package = manifest["package"] diff --git a/tools/ci/template_smoke.sh b/tools/ci/template_smoke.sh deleted file mode 100755 index e15179adc..000000000 --- a/tools/ci/template_smoke.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# Render every shipped template through a real `mcpp new`, then build and run it. -# -# The work lives in tools/ci/test_template.py: it installs an isolated MCPP_HOME -# fixture for the candidate version, runs mcpp's own renderer, parses the -# rendered manifest (complete selector, version, features) with tomllib, and only -# then redirects the dependency to the fixture. Hand-substituting placeholders -# with sed is explicitly not evidence for a template. -# -# Usage: bash tools/ci/template_smoke.sh [--template NAME] [--toolchain SPEC] -set -euo pipefail - -ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -exec python3 "$ROOT/tools/ci/test_template.py" "$@" diff --git a/tools/package-source.sh b/tools/package-source.sh index e58af862a..12288033b 100755 --- a/tools/package-source.sh +++ b/tools/package-source.sh @@ -42,7 +42,7 @@ if git rev-parse --git-dir >/dev/null 2>&1; then fi if command -v python3 >/dev/null 2>&1; then - python3 tools/ci/check_mwrap_release.py + python3 tools/check_mwrap_release.py fi NAME="boost-m-$VERSION"