1name: Run Benchmarks
3# Add concurrency to cancel in-progress jobs
4concurrency:
5 group: ${{ github.workflow }}-${{ github.ref }}
6 cancel-in-progress: true
8on:
9 workflow_dispatch: # Manual trigger
10 push:
11 branches: [ main ] # Run on main branch pushes
12 paths:
13 - 'python/**' # Run only if benchmarks are updated
15permissions:
16 contents: write
18jobs:
19 benchmark:
20 name: Run Benchmarks
21 runs-on: ubuntu-latest
23 steps:
24 - uses: actions/checkout@v4
26 - name: Set up Python
27 uses: actions/setup-python@v4
28 with:
29 python-version: '3.12'
31 - name: Install package and dependencies
32 run: |
33 cd python
34 pip install -e .
36 - name: Run benchmarks
37 env:
38 MEMOBIN_API_KEY: ${{ secrets.MEMOBIN_API_KEY }}
39 UPLOAD_TO_MEMOBIN: '1'
40 run: |
41 python scripts/run_benchmarks.py
43 - name: Upload benchmark results as artifacts
44 uses: actions/upload-artifact@v4
45 with:
46 name: benchmark-results
47 path: |
48 python/benchmark_results/results.json
50 - name: Configure Git
51 if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
52 run: |
53 git config user.name "GitHub Actions Bot"
54 git config user.email "actions@github.com"
56 - name: Create fresh results branch
57 if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
58 run: |
59 git checkout --orphan benchmark-results
61 - name: Commit benchmark results
62 if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
63 env:
64 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65 run: |
66 # need to force add because it's in the .gitignore
67 git add -f benchmark_results/
68 git commit -m "Update benchmark results from $(date +'%Y-%m-%d %H:%M:%S') [skip ci]"
69 git push -f https://${GITHUB_TOKEN}@github.com/${{ github.repository }} benchmark-results