|
| 1 | +name: Benchmark compare last release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + benchmark: |
| 11 | + name: Linux |
| 12 | + runs-on: ubuntu-20.04 |
| 13 | + env: |
| 14 | + ASV_DIR: "./asv_bench" |
| 15 | + CONDA_ENV_FILE: ci/requirements/environment.yml |
| 16 | + |
| 17 | + steps: |
| 18 | + # We need the full repo to avoid this issue |
| 19 | + # https://github.com/actions/checkout/issues/23 |
| 20 | + - uses: actions/checkout@v3 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Set up conda environment |
| 25 | + uses: mamba-org/provision-with-micromamba@v15 |
| 26 | + with: |
| 27 | + environment-file: ${{env.CONDA_ENV_FILE}} |
| 28 | + environment-name: xarray-tests |
| 29 | + cache-env: true |
| 30 | + cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}-benchmark" |
| 31 | + extra-specs: | |
| 32 | + asv |
| 33 | +
|
| 34 | + - name: 'Get Previous tag' |
| 35 | + id: previoustag |
| 36 | + uses: "WyriHaximus/github-action-get-previous-tag@v1" |
| 37 | + # with: |
| 38 | + # fallback: 1.0.0 # Optional fallback tag to use when no tag can be found |
| 39 | + |
| 40 | + - name: Run benchmarks |
| 41 | + shell: bash -l {0} |
| 42 | + id: benchmark |
| 43 | + env: |
| 44 | + OPENBLAS_NUM_THREADS: 1 |
| 45 | + MKL_NUM_THREADS: 1 |
| 46 | + OMP_NUM_THREADS: 1 |
| 47 | + ASV_FACTOR: 1.5 |
| 48 | + ASV_SKIP_SLOW: 1 |
| 49 | + run: | |
| 50 | + set -x |
| 51 | + # ID this runner |
| 52 | + asv machine --yes |
| 53 | + echo "Baseline: ${{ steps.previoustag.outputs.tag }} " |
| 54 | + echo "Contender: ${{ github.sha }}" |
| 55 | + # Use mamba for env creation |
| 56 | + # export CONDA_EXE=$(which mamba) |
| 57 | + export CONDA_EXE=$(which conda) |
| 58 | + # Run benchmarks for current commit against base |
| 59 | + ASV_OPTIONS="--split --show-stderr --factor $ASV_FACTOR" |
| 60 | + asv continuous $ASV_OPTIONS ${{ steps.previoustag.outputs.tag }} ${{ github.sha }} \ |
| 61 | + | sed "/Traceback \|failed$\|PERFORMANCE DECREASED/ s/^/::error::/" \ |
| 62 | + | tee benchmarks.log |
| 63 | + # Report and export results for subsequent steps |
| 64 | + if grep "Traceback \|failed\|PERFORMANCE DECREASED" benchmarks.log > /dev/null ; then |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + working-directory: ${{ env.ASV_DIR }} |
| 68 | + |
| 69 | + - name: Add instructions to artifact |
| 70 | + if: always() |
| 71 | + run: | |
| 72 | + cp benchmarks/README_CI.md benchmarks.log .asv/results/ |
| 73 | + working-directory: ${{ env.ASV_DIR }} |
| 74 | + |
| 75 | + - uses: actions/upload-artifact@v3 |
| 76 | + if: always() |
| 77 | + with: |
| 78 | + name: asv-benchmark-results-${{ runner.os }} |
| 79 | + path: ${{ env.ASV_DIR }}/.asv/results |
0 commit comments