Skip to content

Commit 5b836b0

Browse files
authored
Simplify setup docs and run first-use CI from README (#92)
* docs: simplify README quick start around xlings and d2x * docs: condense environment setup and recovery guide * ci: exercise the documented first-use flow against the candidate commit * ci: share the README runner with published installs and use native PowerShell * docs: split and simplify Chinese and English environment guides
1 parent 2592845 commit 5b836b0

11 files changed

Lines changed: 290 additions & 271 deletions

File tree

‎.github/workflows/fresh-install.yml‎

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,44 +76,41 @@ jobs:
7676
if: matrix.mask_msvc
7777
shell: powershell
7878
run: ./scripts/ci/mask-msvc.ps1
79-
- name: README preparation (Unix)
79+
- name: Follow the README install and practice commands (Unix)
8080
if: runner.os != 'Windows' && matrix.route == 'readme'
81-
run: bash scripts/setup.sh
82-
- name: README preparation (PowerShell 5.1)
81+
run: python3 scripts/ci/readme.py
82+
- name: Follow the README install and practice commands (PowerShell 5.1)
8383
if: runner.os == 'Windows' && matrix.route == 'readme'
8484
shell: powershell
85-
run: ./scripts/setup.ps1
85+
run: python scripts/ci/readme.py
8686
- name: Cold install only (Unix)
8787
if: runner.os != 'Windows' && matrix.route == 'cold'
8888
run: bash scripts/setup.sh --install-only
8989
- name: Cold install only (PowerShell 5.1)
9090
if: runner.os == 'Windows' && matrix.route == 'cold'
9191
shell: powershell
9292
run: ./scripts/setup.ps1 -InstallOnly
93-
- name: README environment verification
94-
if: matrix.route == 'readme'
95-
run: python scripts/ci/solutions.py
9693
- name: First check, save, advance and resume
94+
if: matrix.route == 'cold'
9795
shell: bash
98-
env:
99-
ROUTE: ${{ matrix.route }}
100-
run: |
101-
args=()
102-
if [[ "$ROUTE" == cold ]]; then args+=(--cold); fi
103-
python scripts/ci/first-run.py --allow-source-edit "${args[@]}"
96+
run: python scripts/ci/first-run.py --allow-source-edit --cold
10497
- name: Cold route also verifies all reference answers
10598
if: matrix.route == 'cold'
10699
run: python scripts/ci/solutions.py
107100
- name: Assert GNU target without MSVC
108101
if: matrix.mask_msvc
109102
shell: bash
103+
env:
104+
ROUTE: ${{ matrix.route }}
110105
run: |
106+
logs="$(pwd)/.d2x/ci-logs"
107+
if [[ "$ROUTE" == readme ]]; then cd .d2x/ci-work/download/d2mcpp; fi
111108
# doctor returns nonzero for warnings too (missing MSVC is expected).
112-
mcpp self doctor > .d2x/ci-logs/doctor.txt 2>&1 || true
113-
cat .d2x/ci-logs/doctor.txt
114-
grep -q 'gcc.*what a build here uses' .d2x/ci-logs/doctor.txt
115-
grep -q 'payload mingw-gcc' .d2x/ci-logs/doctor.txt
116-
grep -q 'x86_64.*windows-gnu' .d2x/ci-logs/doctor.txt
109+
mcpp self doctor > "$logs/doctor.txt" 2>&1 || true
110+
cat "$logs/doctor.txt"
111+
grep -q 'gcc.*what a build here uses' "$logs/doctor.txt"
112+
grep -q 'payload mingw-gcc' "$logs/doctor.txt"
113+
grep -q 'x86_64.*windows-gnu' "$logs/doctor.txt"
117114
ls -d target/*windows-gnu
118115
- uses: actions/upload-artifact@v4
119116
if: always()
@@ -165,9 +162,7 @@ jobs:
165162
runuser -u learner -- env MCPP_HOME=/home/learner/.mcpp PATH="/home/learner/.xlings/subos/current/bin:$PATH" python3 scripts/ci/first-run.py --allow-source-edit --cold
166163
runuser -u learner -- env PATH="/home/learner/.xlings/subos/current/bin:$PATH" python3 scripts/ci/solutions.py
167164
else
168-
runuser -u learner -- bash scripts/setup.sh
169-
runuser -u learner -- env PATH="/home/learner/.xlings/subos/current/bin:$PATH" python3 scripts/ci/solutions.py
170-
runuser -u learner -- env PATH="/home/learner/.xlings/subos/current/bin:$PATH" python3 scripts/ci/first-run.py --allow-source-edit
165+
runuser -u learner -- python3 scripts/ci/readme.py
171166
fi
172167
- uses: actions/upload-artifact@v4
173168
if: always()
@@ -184,23 +179,12 @@ jobs:
184179
timeout-minutes: 60
185180
steps:
186181
- uses: actions/checkout@v4
187-
- name: Install xlings baseline
188-
run: bash scripts/install-xlings.sh
189-
- name: Follow the actual d2x download route
190-
run: |
191-
mkdir -p "$RUNNER_TEMP/course-download"
192-
cd "$RUNNER_TEMP/course-download"
193-
xlings install d2x@2026.08.02.2 -y
194-
d2x install d2mcpp
195-
cd d2mcpp
196-
python3 -c 'import json; assert json.load(open(".xlings.json"))["workspace"]["mcpp"] == "2026.10.17.1", "Published course snapshot is stale"'
197-
bash scripts/setup.sh
198-
python3 scripts/ci/solutions.py
199-
python3 scripts/ci/first-run.py --allow-source-edit
182+
- name: Follow the README using the public course download
183+
run: python3 scripts/ci/readme.py --published
200184
- uses: actions/upload-artifact@v4
201185
if: always()
202186
with:
203187
name: published-course-first-use
204-
path: ${{ runner.temp }}/course-download/d2mcpp/.d2x/ci-logs/
188+
path: .d2x/ci-logs/
205189
if-no-files-found: ignore
206190
include-hidden-files: true

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ media
5050
.d2x/result.ndjson
5151
.d2x/environment-ready
5252
.d2x/ci-logs/
53+
.d2x/ci-work/
5354
.d2x/checker.lock
5455
.d2x/last-output.log
5556

‎README.md‎

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,77 +39,35 @@
3939

4040
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=mcpp-community/d2mcpp)
4141

42-
Wait for environment preparation to finish (the first launch downloads a toolchain and verifies the reference answers). Then open a terminal and run `d2x checker`, or choose **Tasks: Run Task → d2mcpp: practice**. Reconnecting does not start another checker. If preparation fails, see [environment troubleshooting](docs/environment.md).
42+
Wait for the environment to be ready, then run `d2x checker` in the terminal.
4343

4444
### Practice locally
4545

46-
Supported release targets: Linux x86_64, macOS 14+ Apple Silicon, and Windows x86_64 with Windows PowerShell 5.1+. mcpp manages the C++ toolchain; Visual Studio is optional. Linux ARM64 is not yet covered by this course's d2x release. Use your preferred editor; it is not installed as a course dependency.
46+
**1. Install the tools**
4747

48-
**1. Get the course** (fork first if you want to save progress with git):
48+
Install [xlings](docs/environment.md#install-xlings), reopen your terminal, then run:
4949

5050
```bash
51-
git clone https://github.com/mcpp-community/d2mcpp.git
52-
cd d2mcpp
51+
xlings install d2x mcpp -y
5352
```
5453

55-
**2. Prepare the environment.** These scripts install xlings **2026.10.18.1**, the versions in `.xlings.json` (mcpp **2026.10.17.1**, d2x **2026.08.02.2**, mdBook **0.4.43**), and build and check the Provider. The first build may take several minutes.
56-
57-
Linux / macOS:
54+
**2. Get the course**
5855

5956
```bash
60-
bash scripts/setup.sh
61-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
62-
```
63-
64-
Windows PowerShell:
65-
66-
```powershell
67-
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\setup.ps1
68-
$env:Path = "$env:USERPROFILE\.xlings\subos\current\bin;$env:Path"
69-
```
70-
71-
The PATH command makes the installed tools available in this terminal. For future sessions, reopen your terminal after installation. Preparation can be repeated and preserves your exercise files and progress.
72-
73-
<details>
74-
<summary>Alternative: download with d2x install</summary>
75-
76-
Install [xlings](https://github.com/openxlings/xlings) first:
77-
78-
```bash
79-
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/v2026.10.18.1/tools/other/quick_install.sh | bash -s v2026.10.18.1
80-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
81-
```
82-
83-
Or on Windows PowerShell:
84-
85-
```powershell
86-
irm https://raw.githubusercontent.com/mcpp-community/d2mcpp/main/scripts/install-xlings.ps1 | iex
87-
$env:Path = "$env:USERPROFILE\.xlings\subos\current\bin;$env:Path"
88-
```
89-
90-
Then, on either system:
91-
92-
```text
93-
xlings install d2x@2026.08.02.2 -y
9457
d2x install d2mcpp
9558
cd d2mcpp
9659
```
9760

98-
Continue with the preparation script for your system in step 2; both download routes use the same verification below.
99-
100-
</details>
101-
102-
**3. Verify, then practice:**
61+
**3. Verify and practice**
10362

10463
```bash
105-
mcpp test -p solutions # all reference answers must pass (currently 52)
64+
mcpp test -p solutions # all reference answers should pass
10665
d2x checker # edit -> save -> auto-check -> advance
107-
d2x status # progress overview
10866
```
10967

110-
The unfinished exercises are expected to fail; the reference answers must pass. `Provider` errors and linker paths containing `/nonexistent/` indicate an environment problem: see [diagnosis and recovery](docs/environment.md). After `git pull`, rerun the preparation script to apply any changed pins.
68+
The first run may take a few minutes. Errors in unfinished exercises are expected.
11169

112-
For native practice, `mcpp test -p src/cpp11` runs one section. See the [English usage guide](https://mcpp-community.github.io/d2mcpp/en/base/chapter_1.html).
70+
[Setup and troubleshooting](docs/environment.md) · [Usage guide](https://mcpp-community.github.io/d2mcpp/en/base/chapter_1.html)
11371

11472

11573
## Community

‎README.zh.hant.md‎

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,77 +39,35 @@
3939

4040
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=mcpp-community/d2mcpp)
4141

42-
等待環境準備完成(首次啟動會下載工具鏈並驗證參考答案),然後在終端執行 `d2x checker`,或使用 **Tasks: Run Task → d2mcpp: practice**。重新連線不會重複啟動 checker。準備失敗時查看[環境疑難排解](docs/environment.md)。
42+
等待環境準備完成,然後在終端執行 `d2x checker`。
4343

4444
### 建立本地練習環境
4545

46-
支援的發行平台:Linux x86_64、macOS 14+ Apple Silicon、Windows x86_64(Windows PowerShell 5.1+)。mcpp 管理 C++ 工具鏈,Visual Studio 為選用項目。目前課程使用的 d2x Release 尚未涵蓋 Linux ARM64。可自行選擇編輯器,課程不會強制安裝。
46+
**第一步:安裝工具**
4747

48-
**第一步:取得課程**(建議先 fork,用 git 儲存自己的練習進度):
48+
安裝 [xlings](docs/environment.zh.md#install-xlings),重新開啟終端後執行:
4949

5050
```bash
51-
git clone https://github.com/mcpp-community/d2mcpp.git
52-
cd d2mcpp
51+
xlings install d2x mcpp -y
5352
```
5453

55-
**第二步:準備環境。** 指令碼安裝 xlings **2026.10.18.1** 及 `.xlings.json` 宣告的版本(mcpp **2026.10.17.1**、d2x **2026.08.02.2**、mdBook **0.4.43**),建置並檢查 Provider。首次建置可能需要幾分鐘。
56-
57-
Linux / macOS:
54+
**第二步:取得課程**
5855

5956
```bash
60-
bash scripts/setup.sh
61-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
62-
```
63-
64-
Windows PowerShell:
65-
66-
```powershell
67-
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\setup.ps1
68-
$env:Path = "$env:USERPROFILE\.xlings\subos\current\bin;$env:Path"
69-
```
70-
71-
PATH 指令讓目前終端立即找到工具;安裝後重新開啟終端即可供後續工作階段使用。準備指令碼可重複執行,不會更動練習檔案或學習進度。
72-
73-
<details>
74-
<summary>選用:透過 d2x install 下載課程</summary>
75-
76-
先安裝 [xlings](https://github.com/openxlings/xlings):
77-
78-
```bash
79-
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/v2026.10.18.1/tools/other/quick_install.sh | bash -s v2026.10.18.1
80-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
81-
```
82-
83-
Windows PowerShell 使用:
84-
85-
```powershell
86-
irm https://raw.githubusercontent.com/mcpp-community/d2mcpp/main/scripts/install-xlings.ps1 | iex
87-
$env:Path = "$env:USERPROFILE\.xlings\subos\current\bin;$env:Path"
88-
```
89-
90-
然後在任一系統執行:
91-
92-
```text
93-
xlings install d2x@2026.08.02.2 -y
9457
d2x install d2mcpp
9558
cd d2mcpp
9659
```
9760

98-
繼續執行第二步中對應系統的準備指令碼;兩種下載方式共用下方驗證步驟。
99-
100-
</details>
101-
102-
**第三步:驗證環境並開始練習:**
61+
**第三步:驗證並開始練習**
10362

10463
```bash
105-
mcpp test -p solutions # 參考答案應全部通過(目前 52 份)
64+
mcpp test -p solutions # 參考答案應全部通過
10665
d2x checker # 編輯 -> 儲存 -> 自動偵測 -> 推進
107-
d2x status # 進度總覽
10866
```
10967

110-
未完成的練習報錯是預期行為,參考答案必須全綠。`Provider` 錯誤或連結路徑含 `/nonexistent/` 屬於環境問題,請查看[診斷與恢復步驟](docs/environment.md)。`git pull` 後重新執行準備指令碼,讓更新後的版本設定生效。
68+
首次執行可能需要幾分鐘。未完成的練習報錯屬於正常現象。
11169

112-
也可使用 `mcpp test -p src/cpp11` 直接練習某一章。更多操作見[使用說明](https://mcpp-community.github.io/d2mcpp/base/chapter_1.html)。
70+
[環境準備與疑難排解](docs/environment.zh.md) · [使用說明](https://mcpp-community.github.io/d2mcpp/base/chapter_1.html)
11371

11472

11573
## 社區

‎README.zh.md‎

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,77 +39,35 @@
3939

4040
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=mcpp-community/d2mcpp)
4141

42-
等待环境准备完成(首次启动会下载工具链并验证参考答案),然后在终端运行 `d2x checker`,或使用 **Tasks: Run Task → d2mcpp: practice**。重连不会重复启动 checker。准备失败时查看[环境排错说明](docs/environment.md)。
42+
等待环境准备完成,然后在终端运行 `d2x checker`。
4343

4444
### 搭建本地练习环境
4545

46-
支持的发布平台:Linux x86_64、macOS 14+ Apple Silicon、Windows x86_64(Windows PowerShell 5.1+)。mcpp 管理 C++ 工具链,Visual Studio 为可选项。当前课程所用 d2x Release 尚未覆盖 Linux ARM64。编辑器可自行选择,课程不会强制安装。
46+
**第一步:安装工具**
4747

48-
**第一步:获取课程**(建议先 fork,用 git 保存自己的练习进度):
48+
安装 [xlings](docs/environment.zh.md#install-xlings),重新打开终端后执行:
4949

5050
```bash
51-
git clone https://github.com/mcpp-community/d2mcpp.git
52-
cd d2mcpp
51+
xlings install d2x mcpp -y
5352
```
5453

55-
**第二步:准备环境。** 脚本安装 xlings **2026.10.18.1** 及 `.xlings.json` 声明的版本(mcpp **2026.10.17.1**、d2x **2026.08.02.2**、mdBook **0.4.43**),构建并检查 Provider。首次构建可能需要几分钟。
56-
57-
Linux / macOS:
54+
**第二步:获取课程**
5855

5956
```bash
60-
bash scripts/setup.sh
61-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
62-
```
63-
64-
Windows PowerShell:
65-
66-
```powershell
67-
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\setup.ps1
68-
$env:Path = "$env:USERPROFILE\.xlings\subos\current\bin;$env:Path"
69-
```
70-
71-
PATH 命令让当前终端立即找到工具;安装后重新打开终端即可供后续会话使用。准备脚本可重复执行,不会改动练习文件或学习进度。
72-
73-
<details>
74-
<summary>可选:通过 d2x install 下载课程</summary>
75-
76-
先安装 [xlings](https://github.com/openxlings/xlings):
77-
78-
```bash
79-
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/v2026.10.18.1/tools/other/quick_install.sh | bash -s v2026.10.18.1
80-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
81-
```
82-
83-
Windows PowerShell 使用:
84-
85-
```powershell
86-
irm https://raw.githubusercontent.com/mcpp-community/d2mcpp/main/scripts/install-xlings.ps1 | iex
87-
$env:Path = "$env:USERPROFILE\.xlings\subos\current\bin;$env:Path"
88-
```
89-
90-
然后在任一系统执行:
91-
92-
```text
93-
xlings install d2x@2026.08.02.2 -y
9457
d2x install d2mcpp
9558
cd d2mcpp
9659
```
9760

98-
继续执行第二步中对应系统的准备脚本;两种下载方式共用下面的验证步骤。
99-
100-
</details>
101-
102-
**第三步:验证环境并开始练习:**
61+
**第三步:验证并开始练习**
10362

10463
```bash
105-
mcpp test -p solutions # 参考答案应全部通过(当前 52 份)
64+
mcpp test -p solutions # 参考答案应全部通过
10665
d2x checker # 编辑 -> 保存 -> 自动检测 -> 推进
107-
d2x status # 进度总览
10866
```
10967

110-
未完成的练习报错是预期行为,参考答案必须全绿。`Provider` 错误或链接路径含 `/nonexistent/` 属于环境问题,请查看[诊断与恢复步骤](docs/environment.md)。`git pull` 后重新运行准备脚本,让更新后的版本配置生效。
68+
首次运行可能需要几分钟。未完成的练习报错属于正常现象。
11169

112-
也可使用 `mcpp test -p src/cpp11` 直接练习某一章。更多操作见[使用说明](https://mcpp-community.github.io/d2mcpp/base/chapter_1.html)。
70+
[环境准备与排错](docs/environment.zh.md) · [使用说明](https://mcpp-community.github.io/d2mcpp/base/chapter_1.html)
11371

11472

11573
## 社区

‎book/src/base/chapter_1.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ d2x checker # 编辑 -> 保存 -> 自动检测 -> 推进
7676
d2x status # 进度总览
7777
```
7878

79-
未完成的练习报错是预期行为,参考答案必须全绿。`Provider` 错误或链接路径含 `/nonexistent/` 属于环境问题,请查看[诊断与恢复步骤](https://github.com/mcpp-community/d2mcpp/blob/main/docs/environment.md)。`git pull` 后重新运行准备脚本,让更新后的版本配置生效。
79+
未完成的练习报错是预期行为,参考答案必须全绿。`Provider` 错误或链接路径含 `/nonexistent/` 属于环境问题,请查看[诊断与恢复步骤](https://github.com/mcpp-community/d2mcpp/blob/main/docs/environment.zh.md)。`git pull` 后重新运行准备脚本,让更新后的版本配置生效。
8080

8181
也可使用 `mcpp test -p src/cpp11` 直接练习某一章。更多操作见[使用说明](https://mcpp-community.github.io/d2mcpp/base/chapter_1.html)。
8282

‎book/src/changelog.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
统一使用 mcpp 2026.10.17.1,增加跨平台准备脚本、全新安装与旧环境恢复验证,更新 Codespaces 入口。
1616

1717
- `Book`: [zh](https://mcpp-community.github.io/d2mcpp/base/chapter_1.html) / [en](https://mcpp-community.github.io/d2mcpp/en/base/chapter_1.html) - 2026/10/19
18-
- `Code`: [setup](https://github.com/mcpp-community/d2mcpp/tree/main/scripts) / [environment recovery](https://github.com/mcpp-community/d2mcpp/blob/main/docs/environment.md) - 2026/10/19
18+
- `Code`: [setup](https://github.com/mcpp-community/d2mcpp/tree/main/scripts) / [environment recovery](https://github.com/mcpp-community/d2mcpp/blob/main/docs/environment.zh.md) - 2026/10/19
1919

2020
## 2025/11
2121

0 commit comments

Comments
 (0)