feat: 彻底移除 xmake,改用 mcpp Provider 驱动练习 #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate exercises and reference solutions | |
| # 断言两件事,缺一不可: | |
| # 1. 每个练习「未完成时」不通过 —— 否则学习者会被直接跳过,练习形同虚设 | |
| # 2. 每个参考答案「放进去后」通过 —— 否则参考答案本身是错的 | |
| # | |
| # 练习即测试:e2e 走 `mcpp test`,与 `d2x checker` 内部的 Provider 是同一条 | |
| # 链路,所以 CI 绿灯等价于学习者本地能跑通,而不是另一条平行的构建路径。 | |
| # | |
| # 依赖 mcpp >= 0.0.104(测试能力批次:逐测试隔离 / 过滤 / --list / --timeout / | |
| # --message-format json / tests 吃 [build].flags)。pin 见 .xlings.json。 | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - "src/**" | |
| - "solutions/**" | |
| - "d2x/**" | |
| - "mcpp.toml" | |
| - ".d2x.json" | |
| - ".github/workflows/dslings-ref-ci.yml" | |
| pull_request: | |
| paths: | |
| - "src/**" | |
| - "solutions/**" | |
| - "d2x/**" | |
| - "mcpp.toml" | |
| - ".d2x.json" | |
| - ".github/workflows/dslings-ref-ci.yml" | |
| workflow_dispatch: | |
| jobs: | |
| validate-exercises: | |
| runs-on: ubuntu-latest | |
| env: | |
| XLINGS_VERSION: "0.4.51" | |
| XLINGS_NON_INTERACTIVE: "1" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # 官方一键安装脚本自带镜像回退。手动 curl GitHub release 包会被 | |
| # release CDN 的间歇性 504 打断。 | |
| - name: Install xlings ${{ env.XLINGS_VERSION }} | |
| run: | | |
| set -eu | |
| curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh \ | |
| | bash -s "v${XLINGS_VERSION}" | |
| echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" | |
| # 按 .xlings.json 安装 mcpp。mcpp 自带工具链沙箱,无需另装 gcc。 | |
| - name: Install mcpp | |
| run: | | |
| set -eu | |
| xlings update | |
| xlings install -y | |
| - name: Build d2x Provider | |
| run: mcpp build -p d2x/buildtools | |
| - name: Validate exercises and solutions (zh + en) | |
| run: bash d2x/buildtools/tests/e2e.sh all | |
| - name: Verify exercises ↔ solutions filename parity | |
| run: | | |
| set -eu | |
| # en/ 镜像跳过 —— 参考答案与语言无关,两边共用同一份 | |
| missing=0 | |
| for f in $(find intro/tests cpp*/tests -name '*.cpp'); do | |
| std="${f%%/*}" | |
| rel="${f#*/tests/}" | |
| if [ ! -f "solutions/$std/$rel" ]; then | |
| echo "::warning::missing solutions/$std/$rel (paired with $f)" | |
| missing=$((missing+1)) | |
| fi | |
| done | |
| if [ "$missing" -gt 0 ]; then | |
| echo "::warning::$missing 个练习尚无参考答案。铺开阶段仅作提示;覆盖完整后收紧为错误。" | |
| fi |