Repository navigation
Validate errors argument in variable, index, and node drops #19539
Workflow file for this run
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: | |
| env: | |
| PR_HEAD_LABEL: ${{ github.event.pull_request.head.label }} | |
| permissions: {} | |
| jobs: | |
| benchmark: | |
| if: ${{ contains( github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || contains( github.event.pull_request.labels.*.name, 'topic-performance') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} | |
| name: Linux | |
| runs-on: ubuntu-latest | |
| env: | |
| ASV_DIR: "./asv_bench" | |
| CONDA_ENV_FILE: ci/requirements/environment-benchmark.yml | |
| steps: | |
| # We need the full repo to avoid this issue | |
| # https://github.com/actions/checkout/issues/23 | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Determine the baseline | |
| id: baseline | |
| # Compare against the first parent of the test merge commit, i.e. the base | |
| # branch this PR was merged into. `pull_request.base.sha` can lag behind it, | |
| # which attributes changes on the base branch to the PR. | |
| run: echo "sha=$(git rev-parse "${GITHUB_SHA}^1")" >> "$GITHUB_OUTPUT" | |
| - name: Set up conda environment | |
| uses: mamba-org/setup-micromamba@v3.2.1 | |
| with: | |
| micromamba-version: "1.5.10-0" | |
| environment-file: ${{env.CONDA_ENV_FILE}} | |
| environment-name: xarray-benchmark | |
| cache-environment: true | |
| cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}-benchmark" | |
| # add "build" because of https://github.com/airspeed-velocity/asv/issues/1385 | |
| create-args: >- | |
| asv | |
| python-build | |
| mamba<=1.5.10 | |
| - name: Run benchmarks | |
| shell: bash -l {0} | |
| id: benchmark | |
| env: | |
| OPENBLAS_NUM_THREADS: 1 | |
| MKL_NUM_THREADS: 1 | |
| OMP_NUM_THREADS: 1 | |
| ASV_FACTOR: 1.5 | |
| ASV_SKIP_SLOW: 1 | |
| GITHUB_LABEL: ${{ github.event.pull_request.base.label }} | |
| BASE_SHA: ${{ steps.baseline.outputs.sha }} | |
| run: | | |
| set -x | |
| # ID this runner | |
| asv machine --yes | |
| echo "Baseline: ${BASE_SHA} ($GITHUB_LABEL)" | |
| echo "Contender: ${GITHUB_SHA} ($PR_HEAD_LABEL)" | |
| # Run benchmarks for current commit against base | |
| ASV_OPTIONS="--split --show-stderr --factor $ASV_FACTOR" | |
| 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: Write the PR comment | |
| # read by `benchmarks-comment.yml`, which posts it on the PR | |
| if: always() && github.event_name == 'pull_request' | |
| shell: bash -l {0} | |
| env: | |
| ASV_FACTOR: 1.5 | |
| BASE_SHA: ${{ steps.baseline.outputs.sha }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| run: | | |
| # pick one of the given messages at random | |
| pick() { local messages=("$@"); echo "${messages[RANDOM % ${#messages[@]}]}"; } | |
| compare=$(asv compare --split --only-changed --factor "$ASV_FACTOR" "$BASE_SHA" "$GITHUB_SHA" 2>&1) | |
| status=$? | |
| # the first column of the table marks benchmarks that got better (-), worse (+), | |
| # started failing (!), were fixed (*) or are not comparable (x) | |
| changes=$(grep -E '^\| [-+!*x] ' <<< "$compare" | cut -c3) | |
| if [ $status -ne 0 ]; then | |
| title=$(pick \ | |
| "π₯ The benchmarks could not be compared. Somebody tripped over the cable." \ | |
| "π₯ Something went wrong while comparing the benchmarks. Not even asv knows what happened.") | |
| elif grep -q '[+!]' <<< "$changes" && grep -q '[-*]' <<< "$changes"; then | |
| title=$(pick \ | |
| "π’ Some benchmarks got better, some got worse. What a ride!" \ | |
| "βοΈ You win some, you lose some. Mixed benchmark results ahead.") | |
| elif grep -q '[+!]' <<< "$changes"; then | |
| title=$(pick \ | |
| "π Some benchmarks got worse. Even the snail is concerned." \ | |
| "π’ This PR takes the scenic route: some benchmarks got worse." \ | |
| "π΅οΈ The benchmarks went the wrong way. Time to put on the detective hat.") | |
| elif grep -q '[-*]' <<< "$changes"; then | |
| title=$(pick \ | |
| "π Some benchmarks got better. To infinity and beyond!" \ | |
| "β‘ Zoom zoom! Some benchmarks improved." \ | |
| "ποΈ New personal best! Some benchmarks got better.") | |
| else | |
| title=$(pick \ | |
| "π΄ No significant changes. The benchmarks took a nap." \ | |
| "π§ No significant changes. Perfectly balanced, as all things should be." \ | |
| "π₯± No significant changes. Boring, in the best possible way.") | |
| fi | |
| mkdir -p comment | |
| echo "$PR_NUMBER" > comment/pr_number | |
| { | |
| echo "<!-- asv-benchmark-comment -->" | |
| echo "## $title" | |
| echo | |
| if [ $status -eq 0 ] && [ -n "$changes" ]; then | |
| # replace asv's markers by something more fun, and separate the tables | |
| # of the different groups by a blank line: with --only-changed, asv | |
| # prints them right after each other, which markdown renders as one table | |
| sed -E \ | |
| -e 's/^\| - +\|/| π |/' \ | |
| -e 's/^\| \+ +\|/| π |/' \ | |
| -e 's/^\| ! +\|/| π₯ |/' \ | |
| -e 's/^\| \* +\|/| π©Ή |/' \ | |
| -e 's/^\| x +\|/| π€· |/' \ | |
| <<< "$compare" \ | |
| | awk '/^\| Change / && NR > 1 { print "" } { print }' | |
| echo | |
| echo "π better Β· π worse Β· π₯ now failing Β· π©Ή fixed Β· π€· not comparable" | |
| echo | |
| fi | |
| echo "Comparing \`${GITHUB_SHA::8}\` (this PR merged into the base branch) with \`${BASE_SHA::8}\` (base branch)." | |
| echo "Only changes by more than a factor of $ASV_FACTOR are shown, see [the workflow run]($RUN_URL) for all results." | |
| } > comment/comment.md | |
| cat comment/comment.md | |
| working-directory: ${{ env.ASV_DIR }} | |
| - uses: actions/upload-artifact@v7.0.2 | |
| if: always() && github.event_name == 'pull_request' | |
| with: | |
| name: asv-benchmark-comment | |
| path: ${{ env.ASV_DIR }}/comment | |
| - 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@v7.0.2 | |
| if: always() | |
| with: | |
| name: asv-benchmark-results-${{ runner.os }} | |
| path: ${{ env.ASV_DIR }}/.asv/results |