performance.yml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. name: Performance
  2. on:
  3. pull_request:
  4. types: [opened, synchronize, reopened, labeled, unlabeled]
  5. workflow_dispatch:
  6. inputs:
  7. base:
  8. description: Baseline commit or branch
  9. required: true
  10. default: main
  11. type: string
  12. suite:
  13. description: Performance suite (full includes startup and long history)
  14. required: true
  15. default: full
  16. type: choice
  17. options: [full, basic]
  18. permissions:
  19. contents: read
  20. jobs:
  21. performance:
  22. # Unrelated label events must not replace the actual performance check.
  23. name: ${{ contains(fromJSON('["labeled","unlabeled"]'), github.event.action) && github.event.label.name != 'perf:full' && 'performance (label ignored)' || 'performance' }}
  24. if: ${{ !contains(fromJSON('["labeled","unlabeled"]'), github.event.action) || github.event.label.name == 'perf:full' }}
  25. strategy:
  26. matrix:
  27. suite: ${{ fromJSON((inputs.suite == 'full' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'perf:full'))) && '["full"]' || '["basic"]') }}
  28. concurrency:
  29. group: performance-${{ github.event_name }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && matrix.suite || 'auto' }}
  30. cancel-in-progress: true
  31. runs-on: macos-15
  32. timeout-minutes: ${{ matrix.suite == 'full' && 45 || 15 }}
  33. steps:
  34. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  35. with:
  36. path: candidate
  37. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  38. persist-credentials: false
  39. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  40. with:
  41. path: baseline
  42. ref: ${{ github.event.pull_request.base.sha || inputs.base }}
  43. persist-credentials: false
  44. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  45. with:
  46. repository: KonghaYao/harness-perf-benchmark
  47. ref: 8ad1e09f7653d7e97b83b4f5b4d347ca2fa129c7
  48. path: benchmark
  49. persist-credentials: false
  50. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  51. with:
  52. version: 9.12.0
  53. package_json_file: candidate/package.json
  54. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  55. with:
  56. node-version: 22.23.2
  57. package-manager-cache: false
  58. - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
  59. with:
  60. bun-version: 1.4.2
  61. - name: Build baseline
  62. working-directory: baseline
  63. run: |
  64. pnpm install --frozen-lockfile
  65. pnpm build
  66. - name: Build candidate
  67. working-directory: candidate
  68. run: |
  69. pnpm install --frozen-lockfile
  70. pnpm build
  71. - name: Install pinned benchmark
  72. working-directory: benchmark
  73. run: bun install --frozen-lockfile
  74. - name: Compare on this runner
  75. env:
  76. PERF_SUITE: ${{ matrix.suite }}
  77. run: node candidate/scripts/perf/run.mjs --base baseline --head candidate --benchmark benchmark --suite "$PERF_SUITE" --out "$RUNNER_TEMP/performance"
  78. - name: Upload performance evidence
  79. if: ${{ always() }}
  80. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  81. with:
  82. name: performance-${{ matrix.suite }}-${{ github.run_attempt }}
  83. path: ${{ runner.temp }}/performance/
  84. include-hidden-files: true
  85. retention-days: 14
  86. if-no-files-found: warn