[pull] main from xarray-contrib:main #291
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: Benchmark | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, labeled] | |
| workflow_dispatch: | |
| jobs: | |
| benchmark: | |
| # if: ${{ contains( github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} # Run if the PR has been labelled correctly. | |
| if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} # Always run. | |
| name: Linux | |
| runs-on: ubuntu-latest | |
| env: | |
| ASV_DIR: "./asv_bench" | |
| steps: | |
| # We need the full repo to avoid this issue | |
| # https://github.com/actions/checkout/issues/23 | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python and uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| python-version: "3.12" | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --group benchmark --no-dev | |
| - name: Run benchmarks | |
| id: benchmark | |
| env: | |
| OPENBLAS_NUM_THREADS: 1 | |
| MKL_NUM_THREADS: 1 | |
| OMP_NUM_THREADS: 1 | |
| ASV_FACTOR: 1.5 | |
| ASV_SKIP_SLOW: 1 | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| LAST_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| HEAD_LABEL: ${{ github.event.pull_request.head.label }} | |
| BASE_LABEL: ${{ github.event.pull_request.base.label }} | |
| run: | | |
| # set -x | |
| # ID this runner | |
| uv run --no-dev asv machine --yes | |
| echo "Baseline: $LAST_HEAD_SHA ($BASE_LABEL)" | |
| echo "Contender: ${GITHUB_SHA} ($HEAD_LABEL)" | |
| # Run benchmarks for current commit against base | |
| ASV_OPTIONS="--split --show-stderr --factor $ASV_FACTOR" | |
| uv run --no-dev asv continuous $ASV_OPTIONS $BASE_SHA ${GITHUB_SHA} \ | |
| | sed "/Traceback \|failed$\|PERFORMANCE DECREASED/ s/^/::error::/" \ | |
| | tee benchmarks.log | |
| # Report and export results for subsequent steps | |
| if grep "Traceback \|failed\|PERFORMANCE DECREASED" benchmarks.log > /dev/null ; then | |
| exit 1 | |
| fi | |
| working-directory: ${{ env.ASV_DIR }} | |
| - name: Add instructions to artifact | |
| if: always() | |
| run: | | |
| cp benchmarks/README_CI.md benchmarks.log .asv/results/ | |
| working-directory: ${{ env.ASV_DIR }} | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: asv-benchmark-results-${{ runner.os }} | |
| path: ${{ env.ASV_DIR }}/.asv/results |