|
| 1 | +name: Benchmark |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "**" |
| 7 | + paths-ignore: &paths-ignore |
| 8 | + - ".github/workflows/docs.yml" |
| 9 | + - ".github/workflows/wheels*" |
| 10 | + - ".gitmodules" |
| 11 | + - "docs/**" |
| 12 | + - "wheels/**" |
| 13 | + pull_request: |
| 14 | + paths-ignore: *paths-ignore |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +env: |
| 25 | + FORCE_COLOR: 1 |
| 26 | + PIP_DISABLE_PIP_VERSION_CHECK: 1 |
| 27 | + |
| 28 | +jobs: |
| 29 | + benchmark: |
| 30 | + |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + os: [ |
| 35 | + "ubuntu-latest", |
| 36 | + ] |
| 37 | + python-version: [ |
| 38 | + # NB: Codspeed doesn't seem to support multiple runs of the same benchmark: |
| 39 | + # > At least one benchmark was run multiple times in your benchmarking workflow. |
| 40 | + # > This could be because you used a matrix that runs your benchmarks multiple times. |
| 41 | + # Hence, this list should only ever have exactly one version. |
| 42 | + "3.14", |
| 43 | + ] |
| 44 | + |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + name: Benchmark ${{ matrix.os }} Python ${{ matrix.python-version }} |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 50 | + with: |
| 51 | + persist-credentials: false |
| 52 | + |
| 53 | + - name: Set up Python ${{ matrix.python-version }} |
| 54 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 55 | + with: |
| 56 | + python-version: ${{ matrix.python-version }} |
| 57 | + allow-prereleases: true |
| 58 | + cache: pip |
| 59 | + cache-dependency-path: | |
| 60 | + ".ci/*.sh" |
| 61 | + "pyproject.toml" |
| 62 | +
|
| 63 | + - name: Cache libavif |
| 64 | + if: startsWith(matrix.os, 'ubuntu') |
| 65 | + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 66 | + id: cache-libavif |
| 67 | + with: |
| 68 | + path: ~/cache-libavif |
| 69 | + key: ${{ runner.os }}-libavif-${{ hashFiles('depends/install_libavif.sh', 'depends/libavif-svt4.patch') }} |
| 70 | + |
| 71 | + - name: Cache libimagequant |
| 72 | + if: startsWith(matrix.os, 'ubuntu') |
| 73 | + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 74 | + id: cache-libimagequant |
| 75 | + with: |
| 76 | + path: ~/cache-libimagequant |
| 77 | + key: ${{ runner.os }}-libimagequant-${{ hashFiles('depends/install_imagequant.sh') }} |
| 78 | + |
| 79 | + - name: Cache libwebp |
| 80 | + if: startsWith(matrix.os, 'ubuntu') |
| 81 | + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 82 | + id: cache-libwebp |
| 83 | + with: |
| 84 | + path: ~/cache-libwebp |
| 85 | + key: ${{ runner.os }}-libwebp-${{ hashFiles('depends/install_webp.sh') }} |
| 86 | + |
| 87 | + - name: Install Linux dependencies |
| 88 | + if: startsWith(matrix.os, 'ubuntu') |
| 89 | + run: | |
| 90 | + .ci/install.sh |
| 91 | + env: |
| 92 | + GHA_PYTHON_VERSION: ${{ matrix.python-version }} |
| 93 | + GHA_LIBAVIF_CACHE_HIT: ${{ steps.cache-libavif.outputs.cache-hit }} |
| 94 | + GHA_LIBIMAGEQUANT_CACHE_HIT: ${{ steps.cache-libimagequant.outputs.cache-hit }} |
| 95 | + GHA_LIBWEBP_CACHE_HIT: ${{ steps.cache-libwebp.outputs.cache-hit }} |
| 96 | + |
| 97 | + - name: Run CodSpeed benchmarks |
| 98 | + uses: CodSpeedHQ/action@a4a36bb07c0638b0b4ca52bf1f3dad1b4289e52f # v4.18.1 |
| 99 | + if: ${{ matrix.os == 'ubuntu-latest' }} |
| 100 | + with: |
| 101 | + mode: simulation |
| 102 | + run: | |
| 103 | + python3 -m pip install -e . pytest-codspeed |
| 104 | + pytest -vv --codspeed Tests/benchmarks.py |
0 commit comments