|
| 1 | +name: Perform Benchmarks |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + pull_request_target: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - develop |
| 12 | + |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: benchmarks-${{ github.event_name }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | + |
| 19 | +env: |
| 20 | + PYTHONUNBUFFERED: "1" |
| 21 | + FORCE_COLOR: "1" |
| 22 | + BRANCH_NAME: ${{ github.base_ref || github.ref_name }} |
| 23 | + PUSH_TO_BENCHMARKS: false |
| 24 | + COMMENT_ALWAYS: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + benchmark-then-upload: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/create-github-app-token@v2 |
| 31 | + id: cls-python-workflow-token |
| 32 | + with: |
| 33 | + app-id: ${{ secrets.CLS_PYTHON_WORKFLOW_CLIENT_ID }} |
| 34 | + private-key: ${{ secrets.CLS_PYTHON_WORKFLOW_PRIVATE_KEY }} |
| 35 | + repositories: | |
| 36 | + cosy-luigi |
| 37 | + cosy-luigi-benchmarks |
| 38 | +
|
| 39 | + - uses: actions/checkout@v6 |
| 40 | + with: |
| 41 | + repository: cls-python/cosy-luigi-benchmarks |
| 42 | + ref: 'gh-pages' |
| 43 | + |
| 44 | + - uses: actions/checkout@v6 |
| 45 | + with: |
| 46 | + # Full history for timestamps |
| 47 | + fetch-depth: 0 |
| 48 | + path: 'cosy-luigi-nested' |
| 49 | + |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v6 |
| 52 | + with: |
| 53 | + python-version: '3.13' |
| 54 | + |
| 55 | + - name: Install Hatch |
| 56 | + uses: pypa/hatch@install |
| 57 | + |
| 58 | + - name: Fetch PR branch from fork |
| 59 | + if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} |
| 60 | + run: gh pr checkout ${{ github.event.number }} |
| 61 | + env: |
| 62 | + GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }} |
| 63 | + working-directory: 'cosy-luigi-nested' |
| 64 | + |
| 65 | + - name: Run Benchmark Suite |
| 66 | + run: hatch test benchmarks --benchmark-json benchmarks.json |
| 67 | + working-directory: 'cosy-luigi-nested' |
| 68 | + |
| 69 | + - name: Config Git |
| 70 | + run: | |
| 71 | + git config user.name "cls-python-workflows[bot]" |
| 72 | + git config user.email "269699678+cls-python-workflows[bot]@users.noreply.github.com" |
| 73 | +
|
| 74 | + - name: Determine Push Or Not |
| 75 | + if: github.event_name != 'pull_request' |
| 76 | + run: | |
| 77 | + echo "PUSH_TO_BENCHMARKS=true" >> $GITHUB_ENV |
| 78 | + echo "COMMENT_ALWAYS=false" >> $GITHUB_ENV |
| 79 | +
|
| 80 | + - name: Store Benchmark Result |
| 81 | + uses: benchmark-action/github-action-benchmark@v1 |
| 82 | + with: |
| 83 | + name: Benchmark cosy-luigi |
| 84 | + tool: 'pytest' |
| 85 | + output-file-path: cosy-luigi-nested/benchmarks.json |
| 86 | + github-token: ${{ steps.cls-python-workflow-token.outputs.token }} |
| 87 | + auto-push: ${{ env.PUSH_TO_BENCHMARKS }} |
| 88 | + alert-threshold: '300%' |
| 89 | + comment-on-alert: true |
| 90 | + fail-on-alert: true |
| 91 | + comment-always: ${{ env.COMMENT_ALWAYS }} |
| 92 | + summary-always: true |
| 93 | + gh-repository: 'github.com/cls-python/cosy-luigi-benchmarks' |
| 94 | + benchmark-data-dir-path: '${{ env.BRANCH_NAME }}/benchmarks' |
0 commit comments