diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..650ff59e --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,23 @@ +name: Python package + +on: + - push + - pull_request + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install dependencies + run: uv pip install --system .[amber,ase,pymatgen,benchmark] rdkit openbabel-wheel + - name: Run benchmarks + uses: CodSpeedHQ/action@v2 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest benchmark/ --codspeed diff --git a/benchmark/__init__.py b/benchmark/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/benchmark/test_import.py b/benchmark/test_import.py new file mode 100644 index 00000000..04d46137 --- /dev/null +++ b/benchmark/test_import.py @@ -0,0 +1,18 @@ +import subprocess +import sys + +import pytest + + +@pytest.mark.benchmark +def test_import(): + """Test import dpdata.""" + subprocess.check_output( + [sys.executable, "-c", "'from dpdata import LabeledSystem'"] + ).decode("ascii") + + +@pytest.mark.benchmark +def test_cli(): + """Test dpdata command.""" + subprocess.check_output([sys.executable, "-m", "dpdata", "-h"]).decode("ascii") diff --git a/pyproject.toml b/pyproject.toml index 8ffec5ef..5292ba9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,10 @@ docs = [ 'jupyterlite-sphinx', 'jupyterlite-xeus', ] +benchmark = [ + 'pytest', + 'pytest-codspeed', +] [tool.setuptools.packages.find] include = ["dpdata*"]