# 三平台离线回归 —— 只跑仓库自带的本地套件,不装依赖、不访问外网。 # # windows job : scripts/validate.ps1 → scripts/build-runner.ps1 -Check → tests/run-tests.ps1 # → node --test tests/index.test.mjs # (84 条 runner 断言 + 6 条 provider 单测;runner 套件自己用 powershell.exe 起 tests/serve.ps1 假服务器) # macos/linux job : bash -n scripts/ghdl.sh → PYTHON=python3 bash tests/run-tests-sh.sh # (26 条断言,含 403 / 503 / 429 / 302→404 / 谎报 416 / 小资产 / source manifest 续传) # min-shells job : 装 dash / busybox / ksh,各跑一遍 scripts/ghdl-min.sh # (验证「POSIX sh、无数组」这句宣称,不再只有 bash 覆盖) # # 两个套件都只连 127.0.0.1 上的假服务器,所以这里刻意没有 npm install / pip install 之类的步骤; # 唯一的外部网络请求是 actions/checkout 取代码本身。 # # 两个 job 都在 checkout 之后先跑一次「行尾归一」:Git for Windows 默认 core.autocrlf=true, # 会把仓库里 LF 的 .sh 落成 CRLF;这里按 blob 重新落盘,避免 CI 红在换行上而不是红在代码上。 name: test on: push: branches: [main] pull_request: workflow_dispatch: jobs: # ---------------------------------------------------------------- Windows windows: name: Windows / PowerShell 5.1 离线回归 runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: # 单元素矩阵:以后加 windows-2022 / windows-2025 只改这一行,steps 不用动 os: [windows-latest] steps: - uses: actions/checkout@v4 # 行尾卫生:Git for Windows 默认 core.autocrlf=true 会把 .sh 落成 CRLF(仓库 blob 里是 LF), # 那样 validate.ps1 会报「ghdl.sh 含 CRLF,POSIX 下会报 bad interpreter」。 # 这里把工作区按 blob 重新落盘 —— 只改 CI 里的临时工作区,不动仓库内容; # 如果谁真的把 CRLF 提交进了 blob,这一步救不了,validate.ps1 照样会红。 - name: 行尾归一(core.autocrlf=false 后重新落盘) shell: powershell run: | Write-Host ("core.autocrlf before: [" + (git config --get core.autocrlf) + "]") git config core.autocrlf false git checkout -- . git ls-files --eol -- scripts/ghdl.sh tests/run-tests-sh.sh # 排查用:CI 上到底是哪个 powershell.exe / curl,和本机对不上时先看这里 - name: 环境自述 shell: powershell run: | Write-Host "=== PowerShell ===" Write-Host ("PowerShell " + $PSVersionTable.PSVersion.ToString()) Write-Host ("powershell.exe -> " + (Get-Command powershell.exe).Source) Write-Host "=== curl ===" if (Get-Command curl.exe -ErrorAction SilentlyContinue) { Write-Host (curl.exe --version | Select-Object -First 1) } else { Write-Host "curl.exe not found (tests/run-tests.ps1 needs it)" } Write-Host "=== git ===" git --version # 仓库自检:frontmatter / 参数表 / 代码块语法 / 文档一致性(成功输出 VALIDATE_OK) - name: 仓库自检(validate.ps1) shell: powershell run: powershell -NoProfile -ExecutionPolicy Bypass -File scripts\validate.ps1 # 一次性 runner scripts\ghdl.ps1 必须与 SKILL.md 的代码块同步(成功输出 GENERATE_OK) - name: runner 与 SKILL.md 同步(build-runner -Check) shell: powershell run: powershell -NoProfile -ExecutionPolicy Bypass -File scripts\build-runner.ps1 -Check # 84 条断言:单流 / 幂等 / 强制重下 / 16 段 / 续传(旧+新 manifest)/ 坏分片 / 短包 / 无 Range / 404 / 死代理 / 并发夹取 / 本机目标 / 小资产 / 空格路径 / Parts 门控 / 无 digest exe / 单流首候选 0 字节回退 - name: 离线回归(run-tests.ps1) shell: powershell run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\run-tests.ps1 # 技能 provider 的纯 Node 单元测试(6 条,不装依赖;node --test 自带 runner) - name: 技能 provider 单元测试(tests/index.test.mjs) shell: powershell run: node --test tests/index.test.mjs # 本地确定性基准(不碰外网):同一资产「强制单流」vs「强制 16 段」,各 Runs 遍取中位数。 # 本地回环没有每连接限速,16 段必然更慢——这一步把「不限速时该回退单流」的判据留在 CI 里, # 不再只靠文档声明。脚本只打印 BENCH/BENCH_VERDICT,永远 exit 0。 - name: 本地基准(单流 vs 16 段,确定性) shell: powershell run: | powershell -NoProfile -ExecutionPolicy Bypass -File tests\bench.ps1 -Runs 2 # ------------------------------------------------------------ macOS / Linux posix: name: ${{ matrix.os }} / POSIX 离线回归 runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4 # 行尾卫生:checkout 若按 core.autocrlf=true 落成 CRLF,bash 会把脚本读炸 # (`set -u` 变成 `set -u\r`)。按仓库 blob 里的 LF 重新落盘,只改 CI 临时工作区。 - name: 行尾归一(core.autocrlf=false 后重新落盘) shell: bash run: | echo "core.autocrlf before: [$(git config --get core.autocrlf || true)]" git config core.autocrlf false git checkout -- . git ls-files --eol -- scripts/ghdl.sh tests/run-tests-sh.sh # 排查用:bash 是 3.2(BSD) 还是 5.x(GNU)、curl 链的是 LibreSSL 还是 OpenSSL —— 先看这里 - name: 环境自述(bash / curl / python3 版本) shell: bash run: | echo "=== bash ==="; bash --version echo "=== curl ==="; curl --version echo "=== python3 ==="; python3 --version echo "=== uname ==="; uname -a # runner 是纯 bash 脚本:新机器上最先炸的通常是语法 / 换行(CRLF) - name: 语法检查(bash -n scripts/ghdl.sh) shell: bash run: bash -n scripts/ghdl.sh # 26 条断言:单流 / 8 段 64MB / 续传(旧+source manifest)/ 无 Range / 404 / 截断包 / P2SP 双源 / 死源 / 坏分片 / 幂等 / KEEP_TMP / 冒烟 / RESULT_JSON / 小资产 # + 故障注入(403 / 503 重试 / 429 重试 / 302→404 / 谎报 416) # 套件缺 curl 或 python3 时会打印 SKIP 并 exit 0,所以额外断言 TESTS_SH_OK 真的出现 - name: 离线回归(run-tests-sh.sh) shell: bash run: | PYTHON=python3 bash tests/run-tests-sh.sh | tee "$RUNNER_TEMP/run-tests-sh.log" grep -q 'TESTS_SH_OK:' "$RUNNER_TEMP/run-tests-sh.log" # --------------------------------------------------- 非 bash 的 POSIX shell # ghdl-min.sh 对外宣称「POSIX sh、无数组、无 [[ ]]」,但此前只被 bash 跑过。 # dash 与 busybox 是两套独立的解析器,正好用来验证这句宣称,而不是继续自我声明。 min-shells: name: 自举最小版 / 多 shell 回归(dash / busybox / ksh) runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 - name: 行尾归一(core.autocrlf=false 后重新落盘) shell: bash run: | git config core.autocrlf false git checkout -- . git ls-files --eol -- scripts/ghdl-min.sh tests/run-tests-min-shells.sh - name: 装三个非 bash 的 POSIX shell shell: bash run: | sudo apt-get update -qq sudo apt-get install -y -qq dash busybox-static ksh echo "--- 装到的版本 ---" dash -c 'echo dash ok' busybox sh -c 'echo busybox ok; busybox | head -1' ksh -c 'echo ksh ok' - name: 三个 shell 各跑一遍最小版(单流 3MB + 分段 64MB) shell: bash run: | PYTHON=python3 bash tests/run-tests-min-shells.sh dash busybox ksh | tee "$RUNNER_TEMP/min-shells.log" grep -q 'TESTS_MIN_SHELLS_OK:' "$RUNNER_TEMP/min-shells.log"