feat: 彻底移除 xmake,改用 mcpp Provider 驱动练习 #26
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 dslings exercises and reference solutions | |
| # 断言两件事,缺一不可: | |
| # 1. 每个练习「未完成时」不通过 —— 否则学员会被直接跳过,练习形同虚设 | |
| # 2. 每个参考答案「放进去后」通过 —— 否则参考答案本身是错的 | |
| # | |
| # 走的是 `d2x checker` 内部使用的同一条 Provider 路径(d2x/buildtools/mcpp), | |
| # 所以 CI 绿灯等价于学员本地能跑通,而不是另一条平行的构建路径。 | |
| # | |
| # 旧版本只挑 `-ref` 结尾的 xmake target,而 solutions/ 在 xmake.lua 里被注释掉, | |
| # grep 返回空、循环全跳过、job 退出 0 —— 实际校验零个目标。 | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - "dslings/**" | |
| - "solutions/**" | |
| - "d2x/**" | |
| - "mcpp.toml" | |
| - ".d2x.json" | |
| - ".github/workflows/dslings-ref-ci.yml" | |
| pull_request: | |
| paths: | |
| - "dslings/**" | |
| - "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/mcpp | |
| - name: Validate exercises and solutions | |
| run: bash d2x/buildtools/mcpp/tests/e2e.sh | |
| - name: Verify dslings ↔ solutions filename parity | |
| run: | | |
| set -eu | |
| # en/ 镜像跳过 —— 参考答案与语言无关,两边共用同一份 | |
| missing=0 | |
| while IFS= read -r f; do | |
| rel="${f#dslings/}" | |
| if [ ! -f "solutions/$rel" ]; then | |
| echo "::warning::missing solutions/$rel (paired with dslings/$rel)" | |
| missing=$((missing+1)) | |
| fi | |
| done < <(find dslings -name '*.cpp' -not -path 'dslings/en/*') | |
| if [ "$missing" -gt 0 ]; then | |
| echo "::warning::$missing 个练习尚无参考答案。铺开阶段仅作提示;cpp11 覆盖完整后收紧为错误。" | |
| fi |