From 673f769119c9e219ede8a26e5899502a551323c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Mon, 16 Oct 2023 12:24:14 -0600 Subject: [PATCH] ci: Try CodSpeed (#2013) --- .github/workflows/codspeed.yml | 44 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 8 ------ noxfile.py | 4 +-- poetry.lock | 45 +++++++++++++++++++++++++++++++--- pyproject.toml | 5 +++- 5 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/codspeed.yml diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 000000000..33b53d6b1 --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,44 @@ +name: codspeed + +on: + push: + branches: + - "main" + pull_request: + # `workflow_dispatch` allows CodSpeed to trigger backtest + # performance analysis in order to generate initial data. + workflow_dispatch: + +jobs: + benchmarks: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4.1.0 + + - name: Setup Python 3.11 + uses: actions/setup-python@v4.7.1 + with: + python-version: 3.11 + architecture: x64 + + - name: Install poetry + run: | + curl -fsS https://install.python-poetry.org | python - -y + + - name: Configure poetry + run: poetry config virtualenvs.create false + + - name: Install project + run: > + poetry install + -vvv + --with dev + --with benchmark + --all-extras + + - name: Run benchmarks + uses: CodSpeedHQ/action@v1 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest tests/ --codspeed diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d217d68c..8ee9ed957 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,6 @@ jobs: - { session: tests, python-version: "3.11", os: "ubuntu-latest", sqlalchemy: "1.*" } - { session: doctest, python-version: "3.10", os: "ubuntu-latest", sqlalchemy: "2.*" } - { session: mypy, python-version: "3.8", os: "ubuntu-latest", sqlalchemy: "2.*" } - - { session: benches, python-version: "3.10", os: "ubuntu-latest", sqlalchemy: "2.*" } steps: - name: Check out the repository @@ -101,13 +100,6 @@ jobs: name: coverage-data path: ".coverage.*" - - name: Upload Benchmark Result - if: always() && (matrix.session == 'benches') - uses: actions/upload-artifact@v3.1.2 - with: - name: benchmark_results - path: output.json - tests-external: name: External Tests runs-on: ubuntu-latest diff --git a/noxfile.py b/noxfile.py index cfa5b0314..6770641d4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -43,9 +43,9 @@ "duckdb", "duckdb-engine", "pytest", - "pytest-snapshot", - "pytest-durations", "pytest-benchmark", + "pytest-durations", + "pytest-snapshot", "pyarrow", "requests-mock", "time-machine", diff --git a/poetry.lock b/poetry.lock index 25158f9a9..66dd5d225 100644 --- a/poetry.lock +++ b/poetry.lock @@ -590,6 +590,21 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "filelock" +version = "3.12.2" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.7" +files = [ + {file = "filelock-3.12.2-py3-none-any.whl", hash = "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec"}, + {file = "filelock-3.12.2.tar.gz", hash = "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81"}, +] + +[package.extras] +docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] + [[package]] name = "fs" version = "2.4.16" @@ -1445,6 +1460,28 @@ aspect = ["aspectlib"] elasticsearch = ["elasticsearch"] histogram = ["pygal", "pygaljs"] +[[package]] +name = "pytest-codspeed" +version = "2.2.0" +description = "Pytest plugin to create CodSpeed benchmarks" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest_codspeed-2.2.0-py3-none-any.whl", hash = "sha256:5da48b842fc465926d122dd15bb86e86af5d9f0c53ec1b7c736e9a9aed558c13"}, + {file = "pytest_codspeed-2.2.0.tar.gz", hash = "sha256:665003fc20117b64a98d16ffd1008f5bd6bf3b1e9af142b98c00abff7f626bbd"}, +] + +[package.dependencies] +cffi = ">=1.15.1,<1.16.0" +filelock = ">=3.12.2,<3.13.0" +pytest = ">=3.8" +setuptools = {version = ">=67.8.0,<67.9.0", markers = "python_full_version >= \"3.12.0b1\""} + +[package.extras] +compat = ["pytest-benchmark (>=4.0.0,<4.1.0)", "pytest-xdist (>=2.0.0,<2.1.0)"] +lint = ["black (>=23.3.0,<23.4.0)", "isort (>=5.12.0,<5.13.0)", "mypy (>=1.3.0,<1.4.0)", "ruff (>=0.0.275,<0.1.0)"] +test = ["pytest (>=7.0,<8.0)", "pytest-cov (>=4.0.0,<4.1.0)"] + [[package]] name = "pytest-durations" version = "1.2.0" @@ -1677,13 +1714,13 @@ crt = ["botocore[crt] (>=1.20.29,<2.0a.0)"] [[package]] name = "setuptools" -version = "68.0.0" +version = "67.8.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.7" files = [ - {file = "setuptools-68.0.0-py3-none-any.whl", hash = "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f"}, - {file = "setuptools-68.0.0.tar.gz", hash = "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235"}, + {file = "setuptools-67.8.0-py3-none-any.whl", hash = "sha256:5df61bf30bb10c6f756eb19e7c9f3b473051f48db77fddbe06ff2ca307df9a6f"}, + {file = "setuptools-67.8.0.tar.gz", hash = "sha256:62642358adc77ffa87233bc4d2354c4b2682d214048f500964dbe760ccedf102"}, ] [package.extras] @@ -2454,4 +2491,4 @@ testing = ["pytest", "pytest-durations"] [metadata] lock-version = "2.0" python-versions = ">=3.7.1,<4" -content-hash = "1074b3c2c3ec920f94b3f8503f5af099e4ff96399245e9b47415574f64321000" +content-hash = "7151732c048586777ce5c0026388b8ea5c9faff71b883483248a3769e36795de" diff --git a/pyproject.toml b/pyproject.toml index 0e2112522..c86c47153 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,6 +109,7 @@ numpy = [ { version = ">=1.22", python = ">=3.8" }, ] pyarrow = ">=11,<13" +pytest-benchmark = "^4.0.0" pytest-snapshot = ">=0.9.0" requests-mock = ">=1.10.0" time-machine = ">=2.10.0" @@ -119,7 +120,9 @@ types-requests = ">=2.28.11" types-simplejson = ">=3.18.0" types-PyYAML = ">=6.0.12" xdoctest = ">=1.1.1" -pytest-benchmark = "^4.0.0" + +[tool.poetry.group.benchmark.dependencies] +pytest-codspeed = "^2.2.0" [tool.black] exclude = ".*simpleeval.*"