feat: implement scoop variations (P2) #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Performance Benchmarks | |
| on: | |
| push: | |
| branches: [releases, main] | |
| paths: | |
| - 'microfinity/**/*.py' | |
| - 'meshcutter/**/*.py' | |
| - 'tests/benchmarks/**' | |
| pull_request: | |
| branches: [releases, main] | |
| paths: | |
| - 'microfinity/**/*.py' | |
| - 'meshcutter/**/*.py' | |
| workflow_dispatch: | |
| jobs: | |
| benchmark: | |
| name: Run Performance Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install -e ".[dev]" | |
| pip install pytest-benchmark | |
| - name: Run benchmarks | |
| run: | | |
| pytest tests/benchmarks/ --benchmark-only -v --benchmark-json=benchmark-results.json | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: benchmark-results.json | |
| - name: Compare with main branch | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "## Performance Comparison" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Benchmark results saved to artifacts." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "To compare manually:" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "pytest tests/benchmarks/ --benchmark-compare --benchmark-compare-fail=median:10%" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| benchmark-store: | |
| name: Store Baseline Benchmarks | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install -e ".[dev]" | |
| pip install pytest-benchmark | |
| - name: Run and store benchmarks | |
| run: | | |
| pytest tests/benchmarks/ --benchmark-only --benchmark-json=benchmark-main.json | |
| - name: Store benchmark result | |
| uses: benchmark-action/github-action-benchmark@v1 | |
| with: | |
| tool: 'pytest' | |
| output-file-path: benchmark-main.json | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| auto-push: true | |
| # Show alert if performance degrades by more than 150% | |
| alert-threshold: '150%' | |
| comment-on-alert: true | |
| fail-on-alert: true | |
| alert-comment-cc-users: '@nullstack65' |