Skip to content

Commit

Permalink
feat: add CodSpeed to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencaccia committed Apr 17, 2024
1 parent d4f58e5 commit bcb56ac
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 62 deletions.
46 changes: 13 additions & 33 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
name: Benchmark
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/benchmark.yml'
- 'src/**'
- 'tests/**'
workflow_dispatch:
inputs:
base_commit:
description: The base commit to compare against


permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

Expand All @@ -28,38 +23,23 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
timeout-minutes: 3
with:
persist-credentials: false
path: "cryptography-pr"
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
timeout-minutes: 3
with:
repository: "pyca/cryptography"
path: "cryptography-base"
ref: "${{ github.event.inputs.base_commit || github.base_ref }}"
- name: Clone test vectors
timeout-minutes: 2
uses: ./cryptography-base/.github/actions/fetch-vectors
uses: ./.github/actions/fetch-vectors

- name: Setup python
id: setup-python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.11"
python-version: "3.12"

- name: Create virtualenv (base)
run: |
python -m venv .venv-base
.venv-base/bin/pip install -v -c ./cryptography-base/ci-constraints-requirements.txt "./cryptography-base[test]" ./cryptography-base/vectors/
- name: Create virtualenv (PR)
- name: Create virtualenv
run: |
python -m venv .venv-pr
.venv-pr/bin/pip install -v -c ./cryptography-pr/ci-constraints-requirements.txt "./cryptography-pr[test]" ./cryptography-pr/vectors/
python -m venv .venv
.venv/bin/pip install -v -c ./ci-constraints-requirements.txt "./[test]" ./vectors/
- name: Run benchmarks (base)
run: .venv-base/bin/pytest --benchmark-enable --benchmark-only ./cryptography-pr/tests/bench/ --benchmark-json=bench-base.json --x509-limbo-root=x509-limbo/
- name: Run benchmarks (PR)
run: .venv-pr/bin/pytest --benchmark-enable --benchmark-only ./cryptography-pr/tests/bench/ --benchmark-json=bench-pr.json --x509-limbo-root=x509-limbo/

- name: Compare results
run: python ./cryptography-pr/.github/compare_benchmarks.py bench-base.json bench-pr.json | tee -a $GITHUB_STEP_SUMMARY
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: .venv/bin/pytest --codspeed --benchmark-enable --benchmark-only ./tests/bench/ --benchmark-json=bench-pr.json --x509-limbo-root=x509-limbo/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ target/
.rust-cov/
*.lcov
*.profdata
.venv
49 changes: 20 additions & 29 deletions ci-constraints-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

alabaster==0.7.16
# via sphinx
argcomplete==3.3.0; python_version >= "3.8"
argcomplete==3.3.0
# via nox
babel==2.14.0
# via sphinx
Expand All @@ -16,7 +16,9 @@ build==1.2.1
# check-sdist
# cryptography (pyproject.toml)
certifi==2024.2.2
# via requests
# via
# cryptography (pyproject.toml)
# requests
charset-normalizer==3.3.2
# via requests
check-sdist==0.1.3
Expand All @@ -25,23 +27,21 @@ click==8.1.7
# via cryptography (pyproject.toml)
colorlog==6.8.2
# via nox
coverage==7.4.4; python_version >= "3.8"
# via
# coverage
# pytest-cov
coverage==7.4.4
# via pytest-cover
distlib==0.3.8
# via virtualenv
docutils==0.20.1
# via
# readme-renderer
# sphinx
# sphinx-rtd-theme
exceptiongroup==1.2.0
# via pytest
execnet==2.1.1; python_version >= "3.8"
execnet==2.1.1
# via pytest-xdist
filelock==3.13.4; python_version >= "3.8"
# via virtualenv
filelock==3.13.4
# via
# pytest-codspeed
# virtualenv
idna==3.7
# via requests
imagesize==1.4.1
Expand All @@ -68,9 +68,9 @@ packaging==24.0
# sphinx
pathspec==0.12.1
# via check-sdist
platformdirs==4.2.0; python_version >= "3.8"
platformdirs==4.2.0
# via virtualenv
pluggy==1.4.0; python_version >= "3.8"
pluggy==1.4.0
# via pytest
pretend==1.0.9
# via cryptography (pyproject.toml)
Expand All @@ -86,16 +86,19 @@ pygments==2.17.2
# sphinx
pyproject-hooks==1.0.0
# via build
pytest==8.1.1; python_version >= "3.8"
pytest==8.1.1
# via
# cryptography (pyproject.toml)
# pytest-benchmark
# pytest-codspeed
# pytest-cov
# pytest-randomly
# pytest-xdist
pytest-benchmark==4.0.0
# via cryptography (pyproject.toml)
pytest-cov==5.0.0; python_version >= "3.8"
pytest-codspeed==2.2.1
# via cryptography (pyproject.toml)
pytest-cov==5.0.0
# via cryptography (pyproject.toml)
pytest-randomly==3.15.0
# via cryptography (pyproject.toml)
Expand All @@ -113,12 +116,7 @@ sphinx==7.3.5
# via
# cryptography (pyproject.toml)
# sphinx-rtd-theme
# sphinxcontrib-applehelp
# sphinxcontrib-devhelp
# sphinxcontrib-htmlhelp
# sphinxcontrib-jquery
# sphinxcontrib-qthelp
# sphinxcontrib-serializinghtml
# sphinxcontrib-spelling
sphinx-rtd-theme==2.0.0
# via cryptography (pyproject.toml)
Expand All @@ -138,15 +136,7 @@ sphinxcontrib-serializinghtml==1.1.10
# via sphinx
sphinxcontrib-spelling==8.0.0
# via cryptography (pyproject.toml)
tomli==2.0.1
# via
# build
# check-manifest
# coverage
# mypy
# pyproject-hooks
# pytest
typing-extensions==4.11.0; python_version >= "3.8"
typing-extensions==4.11.0
# via mypy
urllib3==2.2.1
# via requests
Expand All @@ -156,3 +146,4 @@ virtualenv==20.25.3
# The following packages are considered to be unsafe in a requirements file:
# cffi
# pycparser
# setuptools
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ test = [
"cryptography_vectors",
"pytest >=6.2.0",
"pytest-benchmark",
"pytest-codspeed",
"pytest-cov",
"pytest-xdist",
"pretend",
Expand Down

0 comments on commit bcb56ac

Please sign in to comment.