e2e.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. name: E2E (real DeepSeek API)
  2. # Real-API end-to-end suite (`pnpm run test:e2e`). Unlike ci.yml this job
  3. # consumes the DEEPSEEK_API_KEY_EXTERNAL secret (mapped to the env var
  4. # DEEPSEEK_API_KEY the tests read) and hits the external API at
  5. # https://api.deepseek.com/anthropic (DEEPSEEK_BASE_URL is pinned explicitly so a
  6. # stray repo-root .env can't redirect the run).
  7. #
  8. # pull_request IS a trigger, but GitHub withholds repo secrets from BOTH forked
  9. # PRs and Dependabot PRs (the latter are same-repo, fork==false, but still
  10. # keyless). The job-level `if:` below skips the whole job for those untrusted
  11. # PRs. The Dependabot test keys on the PR AUTHOR (pull_request.user.login), not
  12. # github.actor (the run trigger) — a maintainer reopening a Dependabot PR would
  13. # make github.actor human while the PR is still keyless. When the job runs, the
  14. # secret is expected, so the preflight hard-fails if it's missing (a missing
  15. # secret would otherwise make the self-skipping suite report a false green). A
  16. # job skipped by a job-level `if:` reports as a SUCCESSFUL check, so this
  17. # workflow is safe to use as a required status check if desired.
  18. #
  19. # SECURITY — NEVER change this trigger to `pull_request_target`. `pull_request`
  20. # checks out and runs the PR's HEAD code WITHOUT secrets for forks, which is what
  21. # keeps an untrusted fork from exfiltrating the key. `pull_request_target` runs
  22. # in the BASE repo's context WITH secrets while still able to check out untrusted
  23. # fork code — a textbook key-leak vector, especially once this repo is public.
  24. # The fork/secret model and its public-repo implications are recorded in
  25. # .agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md.
  26. #
  27. # Note: scheduled triggers are auto-disabled after 60 days of repo inactivity;
  28. # push/pull_request/workflow_dispatch act as backstops.
  29. on:
  30. workflow_dispatch:
  31. push:
  32. branches: [main, master]
  33. pull_request:
  34. schedule:
  35. # 00:17 UTC nightly = 08:17 Asia/Shanghai — off the top-of-hour cron stampede.
  36. - cron: '17 0 * * *'
  37. # Keep only the newest validation in each workflow/ref, including master
  38. # pushes, nightly runs, and manual dispatches.
  39. concurrency:
  40. group: ${{ github.workflow }}-${{ github.ref }}
  41. cancel-in-progress: true
  42. # Least privilege: this job only reads the repo to run tests.
  43. permissions:
  44. contents: read
  45. env:
  46. # CI runs must never report to the production telemetry endpoint baked
  47. # into apps/cli/cordis.yml (AppCLIEntry disables the row when set).
  48. DSH_TELEMETRY_DISABLED: '1'
  49. jobs:
  50. e2e:
  51. runs-on: >-
  52. ${{ vars.DSH_CI_FAILOVER_LINUX == 'blacksmith'
  53. && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
  54. name: e2e
  55. # Run on every trusted event. Skip untrusted PRs (forks + Dependabot) where
  56. # the secret is withheld — they would otherwise hard-fail the preflight.
  57. if: >-
  58. github.event_name != 'pull_request'
  59. || !(github.event.pull_request.head.repo.fork || github.event.pull_request.user.login == 'dependabot[bot]')
  60. # Profile e2e files can each own several complete dsh subprocess trees, so
  61. # four file workers preserve process/PTY headroom. Tests retain 120s/test
  62. # and retry 2; 45m still bounds retry storms against a slow API.
  63. timeout-minutes: 45
  64. steps:
  65. - uses: actions/checkout@v6
  66. - uses: pnpm/action-setup@v4
  67. - uses: actions/setup-node@v6
  68. with:
  69. node-version: 24
  70. cache: pnpm
  71. - name: Install (immutable)
  72. run: pnpm install --frozen-lockfile
  73. # The with-key escalation e2e self-skips without a usable runner. Prepare
  74. # bwrap so trusted CI exercises it; the functional probe remains the
  75. # authority on whether the runner can use the sandbox.
  76. - name: Prepare bubblewrap (unrestrict userns)
  77. run: bash scripts/prepare-ci-bubblewrap.sh
  78. # Guard against a false green: the e2e suites self-skip when the key is
  79. # absent, so a missing/misconfigured secret would otherwise pass as
  80. # "all skipped". This job only runs on trusted events (the `if:` above
  81. # excludes keyless PRs), so the secret MUST be present — fail loudly if not.
  82. - name: Preflight (require DEEPSEEK_API_KEY)
  83. env:
  84. # Repo secret DEEPSEEK_API_KEY_EXTERNAL holds the external-API key;
  85. # the tests read process.env.DEEPSEEK_API_KEY, so map it across here.
  86. DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
  87. run: |
  88. set -euo pipefail
  89. if [ -z "${DEEPSEEK_API_KEY:-}" ]; then
  90. echo "::error::DEEPSEEK_API_KEY is empty. The e2e suite would self-skip and"
  91. echo "::error::report a false green. Configure the repo secret DEEPSEEK_API_KEY_EXTERNAL."
  92. exit 1
  93. fi
  94. echo "DEEPSEEK_API_KEY present."
  95. # The e2e suites boot the example bins in `lib` mode (DSH_EXAMPLE_MODE=lib):
  96. # the built artifact under plain Node, resolving plugins through real package
  97. # exports — the shape a real consumer runs. That requires a prior build.
  98. - name: Build (lib for the e2e example bins)
  99. run: pnpm run build:official
  100. # Real-API end-to-end tests only. The keyless gates (lint/typecheck/
  101. # coverage/snapshot/etc.) already run in ci.yml (pull requests) and
  102. # ci-master.yml (master push standby).
  103. # DEEPSEEK_BASE_URL is pinned to the external API; the secret is scoped to
  104. # this step (and preflight) only — never exposed to checkout/setup/install.
  105. - name: E2E tests (real DeepSeek API)
  106. env:
  107. DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
  108. DEEPSEEK_BASE_URL: https://api.deepseek.com/anthropic
  109. DSH_E2E_MAX_WORKERS: 4
  110. DSH_EXAMPLE_MODE: lib
  111. run: pnpm run test:e2e