-
Notifications
You must be signed in to change notification settings - Fork 230
Setup Continuous Benchmarking workflow with pytest-codspeed #2908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
32d92d7
Setup Continuous Benchmarking workflow with pytest-codspeed
weiji14 2fabfb8
Try fetching all history for setuptools-scm
weiji14 bf5499c
List installed packages after make install step
weiji14 fde1048
Try bash -el -c which python
weiji14 f39abfb
Try using mostly PyPI packages, with GMT from conda-forge
weiji14 6eddb0b
Just install pygmt and dependencies in the benchmark step
weiji14 7d431b4
Install setuptools
weiji14 b527c9d
Upgrade version of pip and setuptools
weiji14 31a7567
Try plain setuptools
weiji14 5ca4565
Try to find GMT install path
weiji14 1ad03e9
Try installing GMT with bundled conda
weiji14 1b67ca7
Update GMT_LIBRARY_PATH to /usr/share/miniconda/envs/pygmt/lib
weiji14 6d2fb32
List contents of /usr/share/miniconda/envs/pygmt/lib/
weiji14 8bb1665
Back to installing dependencies with conda instead of pip
weiji14 351f8f2
Still need to install pytest-codspeed from PyPI
weiji14 e664973
Activate base environment rather than pygmt environment
weiji14 992f914
Just use default python from setup-miniconda
weiji14 2d38ecb
Install setuptools via PyPI and use GMT_LIBRARY_PATH from base env
weiji14 44533a5
Typo
weiji14 f0aba1a
Still need to upgrade setuptools version
weiji14 c5a8338
Try using conda's python rather than system python
weiji14 c4cef5c
Run tests with conda python instead of system python
weiji14 b91c1df
Actually use conda python to run pytest
weiji14 a566eb8
Install pytest-mpl from conda-forge
weiji14 3df918f
Run pytest with --pyargs pygmt
weiji14 4a0af5e
Pin to Python 3.12
weiji14 cd6884a
Try using CodSpeedHQ/action@v2 instead of 2.0.2
weiji14 1b9316f
Add shield.io badge for CodSpeed
weiji14 37015d7
Set CODSPEED_TOKEN
weiji14 f115206
Revert setup CODSPEED_TOKEN
weiji14 c92fcb2
Document benchmarks.yml workflow in docs/maintenance.md
weiji14 c8d1965
Run benchmarks when a release is published
weiji14 7bf09b9
Add benchmarks.yml to bump_gmt_checklist.md
weiji14 31eb3da
Pin to CodSpeedHQ/[email protected]
weiji14 9c04e3f
Only benchmark test_basemap for now
weiji14 f45b727
Preprend $CONDA/bin to $GITHUB_PATH
weiji14 5145649
Use make commands instead of calling $CONDA/bin/python
weiji14 0a254f8
Revert back to using python -m pytest
weiji14 dedfa7a
Only run when non-test PyGMT source files and benchmarks.yml is modified
weiji14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Run performance benchmarks | ||
# | ||
# Continuous benchmarking using pytest-codspeed. Measures the execution speed | ||
# of tests marked with @pytest.mark.benchmark decorator. | ||
|
||
name: Benchmarks | ||
|
||
on: | ||
# Run on pushes to the main branch | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- 'pygmt/**/*.py' | ||
- '!pygmt/tests/**' | ||
- '.github/workflows/benchmarks.yml' | ||
pull_request: | ||
paths: | ||
- 'pygmt/**/*.py' | ||
- '!pygmt/tests/**' | ||
- '.github/workflows/benchmarks.yml' | ||
# `workflow_dispatch` allows CodSpeed to trigger backtest | ||
# performance analysis in order to generate initial data. | ||
workflow_dispatch: | ||
release: | ||
types: | ||
- published | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
jobs: | ||
benchmarks: | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
steps: | ||
# Checkout current git repository | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
# fetch all history so that setuptools-scm works | ||
fetch-depth: 0 | ||
|
||
# Install Miniconda with conda-forge dependencies | ||
- name: Setup Miniconda | ||
uses: conda-incubator/[email protected] | ||
with: | ||
auto-activate-base: true | ||
activate-environment: "" # base environment | ||
channels: conda-forge,nodefaults | ||
channel-priority: strict | ||
|
||
# Install GMT and dependencies from conda-forge | ||
- name: Install dependencies | ||
run: | | ||
# $CONDA is an environment variable pointing to the root of the miniconda directory | ||
# Preprend $CONDA/bin to $PATH so that conda's python is used over system python | ||
echo $CONDA/bin >> $GITHUB_PATH | ||
conda install --solver=libmamba gmt=6.4.0 python=3.12 \ | ||
numpy pandas xarray netCDF4 packaging \ | ||
pytest pytest-benchmark pytest-mpl | ||
python -m pip install -U pytest-codspeed setuptools | ||
|
||
# Install the package that we want to test | ||
- name: Install the package | ||
run: make install | ||
|
||
# Run the benchmark tests | ||
- name: Run benchmarks | ||
uses: CodSpeedHQ/[email protected] | ||
with: | ||
weiji14 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
run: | | ||
python -c "import pygmt; pygmt.show_versions()" | ||
PYGMT_USE_EXTERNAL_DISPLAY="false" python -m pytest -r P --pyargs pygmt --codspeed | ||
env: | ||
GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ |
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.