e2e.yml 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 (DEEPSEEK_BASE_URL is pinned to it 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. # Note: scheduled triggers are auto-disabled after 60 days of repo inactivity;
  20. # push/pull_request/workflow_dispatch act as backstops.
  21. on:
  22. workflow_dispatch:
  23. push:
  24. branches: [main, master]
  25. pull_request:
  26. schedule:
  27. # 09:17 UTC nightly — off-peak and off the top-of-hour cron stampede.
  28. - cron: '17 9 * * *'
  29. # Cancel a superseded PR run (it is on a stale commit); never cancel a
  30. # push/schedule run — it is already producing the post-merge/nightly signal.
  31. concurrency:
  32. group: ${{ github.workflow }}-${{ github.ref }}
  33. cancel-in-progress: ${{ github.event_name == 'pull_request' }}
  34. # Least privilege: this job only reads the repo to run tests.
  35. permissions:
  36. contents: read
  37. jobs:
  38. e2e:
  39. runs-on: ubuntu-latest
  40. # Run on every trusted event. Skip untrusted PRs (forks + Dependabot) where
  41. # the secret is withheld — they would otherwise hard-fail the preflight.
  42. if: >-
  43. github.event_name != 'pull_request'
  44. || !(github.event.pull_request.head.repo.fork || github.event.pull_request.user.login == 'dependabot[bot]')
  45. # Serial files (fileParallelism: false), 120s/test, retry 2. 45m bounds a
  46. # wedged run while leaving headroom for retry storms against a slow API.
  47. timeout-minutes: 45
  48. steps:
  49. - uses: actions/checkout@v6
  50. - uses: actions/setup-node@v6
  51. with:
  52. node-version: 24
  53. - name: Enable corepack (pnpm)
  54. run: corepack enable
  55. - name: Install (immutable)
  56. run: pnpm install --frozen-lockfile
  57. # Guard against a false green: the e2e suites self-skip when the key is
  58. # absent, so a missing/misconfigured secret would otherwise pass as
  59. # "all skipped". This job only runs on trusted events (the `if:` above
  60. # excludes keyless PRs), so the secret MUST be present — fail loudly if not.
  61. - name: Preflight (require DEEPSEEK_API_KEY)
  62. env:
  63. # Repo secret DEEPSEEK_API_KEY_EXTERNAL holds the external-API key;
  64. # the tests read process.env.DEEPSEEK_API_KEY, so map it across here.
  65. DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
  66. run: |
  67. set -euo pipefail
  68. if [ -z "${DEEPSEEK_API_KEY:-}" ]; then
  69. echo "::error::DEEPSEEK_API_KEY is empty. The e2e suite would self-skip and"
  70. echo "::error::report a false green. Configure the repo secret DEEPSEEK_API_KEY_EXTERNAL."
  71. exit 1
  72. fi
  73. echo "DEEPSEEK_API_KEY present."
  74. # Real-API end-to-end tests only. The keyless gates (lint/typecheck/
  75. # coverage/snapshot/build/etc.) already run in ci.yml on every push/PR;
  76. # no need to repeat them or build first (tests run unbuilt via tsx).
  77. # DEEPSEEK_BASE_URL is pinned to the external API; the secret is scoped to
  78. # this step (and preflight) only — never exposed to checkout/setup/install.
  79. - name: E2E tests (real DeepSeek API)
  80. env:
  81. DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
  82. DEEPSEEK_BASE_URL: https://api.deepseek.com
  83. run: pnpm run test:e2e