ci.yml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. name: CI
  2. on:
  3. pull_request:
  4. permissions:
  5. contents: read
  6. env:
  7. PRIMARY_NODE_VERSION: '24'
  8. # CI runs must never report to the production telemetry endpoint baked
  9. # into apps/cli/cordis.yml (AppCLIEntry disables the row when set).
  10. DSH_TELEMETRY_DISABLED: '1'
  11. # Cancel a superseded pull-request run on a new push so a fresh head does not
  12. # queue a second full 9-job run behind a stale one (paid enterprise runners
  13. # would otherwise stack with no auto-cancellation).
  14. concurrency:
  15. group: ${{ github.workflow }}-${{ github.ref }}
  16. cancel-in-progress: true
  17. jobs:
  18. # Three enterprise jobs isolate coverage, static analysis, and the
  19. # build-backed consumer tail. The consumer job owns the only Linux build so
  20. # all three jobs enter runner allocation independently.
  21. #
  22. # FAILOVER (Linux): each Linux enterprise job resolves its pool through the
  23. # DSH_CI_FAILOVER_LINUX repository variable. Unset (normal), the expressions
  24. # pick the hosted enterprise pools below. Setting the variable to
  25. # 'selfhosted' (repo Settings → Actions → Variables; writer-manageable
  26. # repository state — not PR-editable, no merge required) retargets all
  27. # three onto the in-house
  28. # vm-backup pool and re-running the failed jobs is the entire switch —
  29. # see .agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md. The
  30. # in-house pool's readiness is re-proven on every master push by the
  31. # serial-linux-selfhosted standby lane in ci-master.yml. The Windows failover
  32. # switch is the separate DSH_CI_FAILOVER_WINDOWS variable on the windows-native
  33. # job below.
  34. node-24:
  35. if: github.event_name == 'pull_request'
  36. runs-on: >-
  37. ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
  38. && github.event.pull_request.user.login != 'dependabot[bot]'
  39. && fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
  40. || 'dsh-ubuntu-24-04-16core' }}
  41. name: node 24 / static
  42. env:
  43. DSH_GATE_CONCURRENCY: '8'
  44. steps:
  45. # Fetch complete history so the archive gate can read the trusted PR base from a reused shallow checkout.
  46. - uses: actions/checkout@v6
  47. with:
  48. fetch-depth: 0
  49. persist-credentials: false
  50. - uses: pnpm/action-setup@v4
  51. with:
  52. dest: ${{ runner.temp }}/setup-pnpm
  53. - uses: actions/setup-node@v6
  54. with:
  55. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  56. - name: Configure pnpm store path
  57. id: pnpm-store
  58. run: |
  59. store_root="$HOME/.local/share/pnpm/store"
  60. echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
  61. store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
  62. echo "path=$store_path" >> "$GITHUB_OUTPUT"
  63. # Pull requests consume the default-branch cache but do not put cache
  64. # compression and upload on the paid latency-critical path. Skipped
  65. # under failover — see the coverage lane's identical rationale.
  66. - uses: actions/cache/restore@v4
  67. if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
  68. with:
  69. path: ${{ steps.pnpm-store.outputs.path }}
  70. key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
  71. restore-keys: |
  72. ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
  73. - name: Install (immutable)
  74. run: pnpm install --frozen-lockfile
  75. - name: Run static gates
  76. env:
  77. DSH_ARCHIVE_BASE_REF: ${{ github.event.pull_request.base.sha }}
  78. run: pnpm run check:ci:static
  79. node-24-coverage:
  80. if: github.event_name == 'pull_request'
  81. runs-on: >-
  82. ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
  83. && github.event.pull_request.user.login != 'dependabot[bot]'
  84. && fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
  85. || 'dsh-ubuntu-24-04-16core' }}
  86. name: node 24 / coverage
  87. env:
  88. # Partitioning replaces the instrumented share; this budget gives the
  89. # exempt-heavy gate two workers on both hosted and failover runners.
  90. DSH_COVERAGE_MAX_WORKERS: '6'
  91. DSH_COVERAGE_PARTITIONS: '4'
  92. DSH_GATE_CONCURRENCY: '3'
  93. steps:
  94. - uses: actions/checkout@v6
  95. with:
  96. persist-credentials: false
  97. - uses: pnpm/action-setup@v4
  98. with:
  99. dest: ${{ runner.temp }}/setup-pnpm
  100. - uses: actions/setup-node@v6
  101. with:
  102. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  103. - name: Configure pnpm store path
  104. id: pnpm-store
  105. run: |
  106. store_root="$HOME/.local/share/pnpm/store"
  107. echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
  108. store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
  109. echo "path=$store_path" >> "$GITHUB_OUTPUT"
  110. # Skipped under failover: the self-hosted VM's persistent pnpm store
  111. # already serves warm installs, while restoring the hosted archive
  112. # would spend ~52 s pulling ~180 MB into that populated store.
  113. - uses: actions/cache/restore@v4
  114. if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
  115. with:
  116. path: ${{ steps.pnpm-store.outputs.path }}
  117. key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
  118. restore-keys: |
  119. ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
  120. - name: Install dependencies and prepare bubblewrap
  121. run: |
  122. pnpm install --frozen-lockfile &
  123. install_pid=$!
  124. bash scripts/prepare-ci-bubblewrap.sh &
  125. sandbox_pid=$!
  126. install_status=0
  127. wait "$install_pid" || install_status=$?
  128. sandbox_status=0
  129. wait "$sandbox_pid" || sandbox_status=$?
  130. if (( install_status != 0 )); then exit "$install_status"; fi
  131. exit "$sandbox_status"
  132. - name: Run exhaustive coverage
  133. run: pnpm run check:ci:coverage
  134. node-24-consumers:
  135. if: github.event_name == 'pull_request'
  136. runs-on: >-
  137. ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
  138. && github.event.pull_request.user.login != 'dependabot[bot]'
  139. && fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
  140. || 'dsh-ubuntu-24-04-16core' }}
  141. name: node 24 / snapshots and artifacts
  142. env:
  143. DSH_GATE_CONCURRENCY: '8'
  144. DSH_NODE_COMPAT_SKIP_TYPECHECK: '1'
  145. DSH_OXLINT_THREADS: '8'
  146. DSH_PUBLINT_CONCURRENCY: '8'
  147. DSH_WEB_SNAPSHOT_WORKERS: '6'
  148. # Failover halves snapshot concurrency for the shared 64-core VM.
  149. DSH_SNAPSHOT_MAX_CONCURRENCY: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '12' || '32' }}
  150. steps:
  151. - uses: actions/checkout@v6
  152. with:
  153. persist-credentials: false
  154. - uses: pnpm/action-setup@v4
  155. with:
  156. dest: ${{ runner.temp }}/setup-pnpm
  157. - uses: actions/setup-node@v6
  158. with:
  159. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  160. - name: Configure pnpm store path
  161. id: pnpm-store
  162. run: |
  163. store_root="$HOME/.local/share/pnpm/store"
  164. echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
  165. store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
  166. echo "path=$store_path" >> "$GITHUB_OUTPUT"
  167. # Pull requests restore the pnpm store and Playwright caches without paying
  168. # compression and upload on the required path. No master job saves these
  169. # hosted cache keys, so each restore-keys fallback hits the matching archived
  170. # entry until it evicts, after which the store is cold. Skipped under failover
  171. # — the self-hosted VM's persistent store is already warm.
  172. - uses: actions/cache/restore@v4
  173. if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
  174. with:
  175. path: ${{ steps.pnpm-store.outputs.path }}
  176. key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
  177. restore-keys: |
  178. ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
  179. # Skipped under failover: the VM's persistent browser cache is already warm.
  180. - uses: actions/cache/restore@v4
  181. if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
  182. with:
  183. path: ~/.cache/ms-playwright
  184. key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
  185. restore-keys: |
  186. ${{ runner.os }}-playwright-
  187. - name: Install dependencies and prepare bubblewrap
  188. run: |
  189. pnpm install --frozen-lockfile &
  190. install_pid=$!
  191. bash scripts/prepare-ci-bubblewrap.sh &
  192. sandbox_pid=$!
  193. install_status=0
  194. wait "$install_pid" || install_status=$?
  195. sandbox_status=0
  196. wait "$sandbox_pid" || sandbox_status=$?
  197. if (( install_status != 0 )); then exit "$install_status"; fi
  198. exit "$sandbox_status"
  199. - name: Install Playwright Chromium and hosted dependencies
  200. if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
  201. run: pnpm --filter @deepseek-ai/dsh-web-frontend exec playwright install --with-deps chromium
  202. # The persistent VM image owns Playwright's Linux system packages; do
  203. # not mutate the shared host with apt on every failover run.
  204. - name: Install Playwright Chromium on the failover VM
  205. if: vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]'
  206. run: pnpm --filter @deepseek-ai/dsh-web-frontend exec playwright install chromium
  207. - name: Run compatibility, snapshot, and artifact gates
  208. run: pnpm run check:ci:consumers
  209. node-compat:
  210. if: github.event_name == 'pull_request'
  211. # Each compatibility contract receives an independent standard hosted job.
  212. runs-on: ${{ matrix.runner }}
  213. name: ${{ matrix.name }}
  214. env:
  215. DSH_GATE_CONCURRENCY: ${{ matrix.gate_concurrency }}
  216. DSH_NODE_COMPAT_SKIP_TYPECHECK: '1'
  217. strategy:
  218. fail-fast: false
  219. matrix:
  220. include:
  221. - node: '22.19'
  222. name: node 22.19
  223. runner: ubuntu-latest
  224. gate_concurrency: '1'
  225. - node: 26
  226. name: node 26
  227. runner: ubuntu-latest
  228. gate_concurrency: '1'
  229. steps:
  230. - uses: actions/checkout@v6
  231. - uses: pnpm/action-setup@v4
  232. with:
  233. dest: ${{ runner.temp }}/setup-pnpm
  234. - uses: actions/setup-node@v6
  235. with:
  236. node-version: ${{ matrix.node }}
  237. cache: pnpm
  238. - name: Install (immutable)
  239. run: pnpm install --frozen-lockfile
  240. - name: Run compatibility smokes
  241. env:
  242. DSH_BUILD_CLIENT_PROFILE: official
  243. run: pnpm run check:node-compat
  244. python-sdk:
  245. if: github.event_name == 'pull_request'
  246. runs-on: ubuntu-latest
  247. name: python 3.10 / keyless SDK
  248. steps:
  249. - uses: actions/checkout@v6
  250. - uses: actions/setup-python@v6.3.0
  251. with:
  252. python-version: '3.10'
  253. cache: pip
  254. - name: Install uv
  255. run: python -m pip install uv==0.11.23
  256. - name: Run complete keyless Python suite
  257. run: uv run --python 3.10 --group test --project python/sdk pytest
  258. # The reusable builder owns each published executable, wheel, clean-install,
  259. # keyless black-box, and trusted real-API path. All native release targets are
  260. # required because a platform wheel cannot be validated by another carrier.
  261. python-runtime:
  262. if: github.event_name == 'pull_request'
  263. name: python runtime / release-shaped matrix
  264. uses: ./.github/workflows/build-exe-for-python-sdk.yml
  265. with:
  266. targets: node24-linux-x64,node24-linux-arm64,node24-macos-arm64,node24-win-x64
  267. ci: true
  268. secrets:
  269. DEEPSEEK_API_KEY_EXTERNAL: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
  270. # The required pull-request Windows signal: the two blocking win32 surfaces
  271. # (workspace build, production site) execute with real, checksum-verified
  272. # Windows Node under Wine on standard hosted Linux. The independent
  273. # windows-native job below keeps the complete native-kernel inventory —
  274. # including the observational portability gates this lane does not run —
  275. # on real Windows. This job only provisions runner state (caches,
  276. # apt); scripts/wine-windows-gates.sh owns the gate logic and is the same
  277. # script the optional local gate `pnpm run check:windows-wine` runs.
  278. # Current topology and fidelity limits live in
  279. # .agents/notes/implemented/process/2026-08-08-native-windows-pull-request-ci.md
  280. windows:
  281. if: github.event_name == 'pull_request'
  282. runs-on: ubuntu-latest
  283. name: windows node 24 / wine blocking
  284. timeout-minutes: 15
  285. steps:
  286. - uses: actions/checkout@v6
  287. with:
  288. persist-credentials: false
  289. - uses: pnpm/action-setup@v4
  290. with:
  291. dest: ${{ runner.temp }}/setup-pnpm
  292. - uses: actions/setup-node@v6
  293. with:
  294. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  295. - name: Configure pnpm store path
  296. id: pnpm-store
  297. run: |
  298. store_root="$HOME/.local/share/pnpm/store"
  299. echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
  300. store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
  301. echo "path=$store_path" >> "$GITHUB_OUTPUT"
  302. - uses: actions/cache/restore@v4
  303. with:
  304. path: ${{ steps.pnpm-store.outputs.path }}
  305. key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
  306. restore-keys: |
  307. ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
  308. # Master's wine-apt-cache job in ci-master.yml seeds the default-branch
  309. # scope every pull request can read; a save from this job only reaches
  310. # reruns of the same merge ref.
  311. - name: Compose Wine apt cache key
  312. id: wine-cache-key
  313. run: echo "key=wine-debs-${ImageOS:-linux}-${ImageVersion:-v0}" >> "$GITHUB_OUTPUT"
  314. - uses: actions/cache@v4
  315. with:
  316. path: ~/wine-debs
  317. key: ${{ steps.wine-cache-key.outputs.key }}
  318. # Runner provisioning only — a developer machine installs Wine through
  319. # its own package manager; the gate script assumes a wine binary and
  320. # fails loud without one. Wine from the apt cache when present; else
  321. # download the full dependency closure once and keep it for the next
  322. # run. The `wine` dispatcher package (not bare `wine64`) is what puts a
  323. # binary on PATH.
  324. - name: Install Wine
  325. run: |
  326. if compgen -G "$HOME/wine-debs/*.deb" > /dev/null; then
  327. # The restored archive is the full --download-only closure of
  328. # `wine` for this runner image, so installing the .debs directly
  329. # with dpkg needs no repository access. apt-get would instead
  330. # re-download the same 100+ MB closure from the mirror, which has
  331. # stalled the job past its budget on a degraded runner network.
  332. # If the archive cannot satisfy the closure, fall back to the apt
  333. # network install.
  334. if ! sudo DEBIAN_FRONTEND=noninteractive dpkg -i "$HOME"/wine-debs/*.deb; then
  335. sudo DEBIAN_FRONTEND=noninteractive dpkg --configure -a || true
  336. sudo apt-get install -y --no-install-recommends "$HOME"/wine-debs/*.deb
  337. fi
  338. else
  339. sudo apt-get update
  340. sudo apt-get install -y --no-install-recommends --download-only wine
  341. mkdir -p "$HOME/wine-debs"
  342. cp /var/cache/apt/archives/*.deb "$HOME/wine-debs/" 2>/dev/null || true
  343. sudo apt-get install -y --no-install-recommends wine
  344. fi
  345. - name: Run the Wine Windows gates
  346. run: bash scripts/wine-windows-gates.sh
  347. - name: Shut down wineserver
  348. if: always()
  349. run: wineserver -k 2>/dev/null || true
  350. # Every pull request also gets a real Windows-kernel signal. This job keeps
  351. # its own unmasked conclusion but is deliberately absent from
  352. # all-checks-passed.needs, so it never delays or changes that required
  353. # verdict. Under normal operation it runs on the hosted larger runner; under
  354. # Windows failover (DSH_CI_FAILOVER_WINDOWS=selfhosted) it retargets onto the
  355. # in-house self-hosted Windows pool. Dependabot PRs are excluded from the
  356. # self-hosted pool and stay queued for the hosted runner — see the failover
  357. # runbook. This Windows switch is independent of the Linux
  358. # DSH_CI_FAILOVER_LINUX variable that retargets the three required Linux jobs
  359. # and the all-checks-passed verdict above.
  360. windows-native:
  361. if: github.event_name == 'pull_request'
  362. runs-on: >-
  363. ${{ vars.DSH_CI_FAILOVER_WINDOWS == 'selfhosted'
  364. && github.event.pull_request.user.login != 'dependabot[bot]'
  365. && fromJSON('["self-hosted", "dsh-win-ci", "windows"]')
  366. || 'dsh-windows-2025-16core' }}
  367. name: windows node 24 / native complete
  368. timeout-minutes: 120
  369. env:
  370. DSH_COVERAGE_MAX_WORKERS: '6'
  371. DSH_COVERAGE_PARTITIONS: '8'
  372. # Instrumented process and polling fixtures can exceed Vitest's defaults
  373. # under the complete lane's concurrent gate load.
  374. DSH_COVERAGE_TEST_TIMEOUT_MS: '30000'
  375. DSH_GATE_CONCURRENCY: '4'
  376. DSH_PUBLINT_CONCURRENCY: '8'
  377. steps:
  378. - uses: actions/checkout@v6
  379. with:
  380. persist-credentials: false
  381. - name: Enable Developer Mode (symlink support)
  382. shell: pwsh
  383. run: >-
  384. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
  385. /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
  386. - uses: pnpm/action-setup@v4
  387. with:
  388. dest: ${{ runner.temp }}/setup-pnpm-js
  389. - uses: actions/setup-node@v6
  390. with:
  391. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  392. # Extracting the many-file pnpm store cache is slower than a clean
  393. # install on hosted Windows runners, and saving it adds latency after
  394. # the gates. The self-hosted VM's persistent store makes caching
  395. # redundant.
  396. - name: Install (immutable)
  397. shell: pwsh
  398. run: pnpm install --frozen-lockfile
  399. - name: Run complete native Windows gate inventory
  400. shell: pwsh
  401. run: pnpm run check:ci:windows-complete
  402. # Single stable required check for branch protection: require "all checks
  403. # passed" instead of enumerating matrix legs whose names change as lanes and
  404. # node versions evolve. Every blocking job in THIS workflow must be listed in
  405. # `needs`. The required Wine job is listed as `windows`; `windows-native` is
  406. # deliberately absent so its independent result never delays or changes this
  407. # verdict. (`needs` cannot reach across workflow files; the master-only jobs in
  408. # ci-master.yml are intentionally not part of this PR verdict.)
  409. # `if: always()` is load-bearing: without it a failed dependency
  410. # would SKIP this job, and GitHub counts a skipped required check as passing
  411. # — so this job always runs and fails on any non-success result, including
  412. # 'cancelled' and 'skipped'.
  413. all-checks-passed:
  414. name: all checks passed
  415. # This bookkeeping-only verdict must not depend on custom-pool
  416. # provisioning — and under Linux failover it follows the same selector as
  417. # the worker jobs it aggregates, so a standard-hosted outage cannot strand
  418. # the branch-protection verdict either. It retargets with the Linux switch
  419. # (DSH_CI_FAILOVER_LINUX), not the Windows one, because it aggregates the
  420. # required Linux workers and runs on the vm-backup pool.
  421. runs-on: >-
  422. ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
  423. && github.event.pull_request.user.login != 'dependabot[bot]'
  424. && fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
  425. || 'ubuntu-latest' }}
  426. needs: [node-24, node-24-coverage, node-24-consumers, node-compat, python-sdk, python-runtime, windows]
  427. if: always() && github.event_name == 'pull_request'
  428. steps:
  429. - name: Fail if any needed job did not succeed
  430. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')
  431. run: |
  432. echo "::error::Needed job results: ${{ join(needs.*.result, ', ') }}"
  433. exit 1
  434. - name: All checks passed
  435. run: echo "All needed jobs succeeded (${{ join(needs.*.result, ', ') }})"