|
| 1 | +name: Benchmarks |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + update-baseline: |
| 6 | + description: 'Update baseline with current results instead of comparing' |
| 7 | + type: boolean |
| 8 | + default: false |
| 9 | + pull_request: |
| 10 | + branches: [main, 'release/v*'] |
| 11 | + |
| 12 | +jobs: |
| 13 | + benchmark: |
| 14 | + name: Performance Benchmarks (${{ matrix.os }}) |
| 15 | + timeout-minutes: 60 |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + os: [ubuntu-24.04, macos-latest, windows-latest] |
| 21 | + include: |
| 22 | + - os: ubuntu-24.04 |
| 23 | + os-name: ubuntu |
| 24 | + - os: macos-latest |
| 25 | + os-name: macos |
| 26 | + - os: windows-latest |
| 27 | + os-name: windows |
| 28 | + permissions: |
| 29 | + contents: write |
| 30 | + pull-requests: write |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v6 |
| 33 | + |
| 34 | + - name: Install System Dependencies (Ubuntu) |
| 35 | + if: matrix.os-name == 'ubuntu' |
| 36 | + run: | |
| 37 | + sudo apt-get update |
| 38 | + sudo apt-get --no-install-recommends install -y \ |
| 39 | + libglib2.0-0 libnss3 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgtk-3-0 libasound2t64 \ |
| 40 | + xvfb |
| 41 | +
|
| 42 | + - name: Setup Node Dependencies |
| 43 | + uses: ./.github/actions/common/setup-node-deps |
| 44 | + |
| 45 | + - name: Configure Chrome Sandbox |
| 46 | + if: matrix.os-name == 'ubuntu' |
| 47 | + run: | |
| 48 | + sudo chown root node_modules/electron/dist/chrome-sandbox |
| 49 | + sudo chmod 4755 node_modules/electron/dist/chrome-sandbox |
| 50 | +
|
| 51 | + - name: Run Benchmark Tests |
| 52 | + uses: ./.github/actions/tests/run-benchmark-tests |
| 53 | + with: |
| 54 | + os: ${{ matrix.os-name }} |
| 55 | + update-baseline: ${{ github.event.inputs.update-baseline || 'false' }} |
| 56 | + |
| 57 | + - name: Upload Benchmark Results |
| 58 | + uses: actions/upload-artifact@v6 |
| 59 | + if: ${{ !cancelled() }} |
| 60 | + with: |
| 61 | + name: benchmark-results-${{ matrix.os-name }} |
| 62 | + path: | |
| 63 | + tests/benchmarks/results/ |
| 64 | + benchmark-report/ |
| 65 | + retention-days: 30 |
| 66 | + |
| 67 | + - name: Commit Updated Baseline |
| 68 | + if: github.event.inputs.update-baseline == 'true' |
| 69 | + run: | |
| 70 | + git config user.name "github-actions[bot]" |
| 71 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 72 | + git add tests/benchmarks/mounting/baseline.${{ matrix.os-name }}.json |
| 73 | + git diff --staged --quiet || git commit -m "chore: update ${{ matrix.os-name }} benchmark baseline" && git push |
| 74 | +
|
| 75 | + - name: Comment Benchmark Results on PR |
| 76 | + if: github.event_name == 'pull_request' && !cancelled() |
| 77 | + continue-on-error: true |
| 78 | + uses: actions/github-script@v7 |
| 79 | + with: |
| 80 | + script: | |
| 81 | + const run = require('./tests/benchmarks/utils/pr-comment.js'); |
| 82 | + await run({ |
| 83 | + github, |
| 84 | + context, |
| 85 | + resultsPath: 'tests/benchmarks/results/mounting.json', |
| 86 | + baselinePath: 'tests/benchmarks/mounting/baseline.${{ matrix.os-name }}.json', |
| 87 | + title: 'Benchmark Results — Collection Mount (${{ matrix.os-name }})' |
| 88 | + }); |
0 commit comments