diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index e8951731..f3a302c9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -62,6 +62,23 @@ jobs: python-version: ${{ matrix.python-version }} secret-codecov-token: ${{ secrets.CODECOV_TOKEN }} + benchmarks: + name: Check benchmarks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + shell: bash + run: | + python -mpip install --upgrade pip + python -mpip install .[asv_version] + - name: Run asv check + shell: bash + run: asv check -v -E existing + build_sdist_wheels: name: Build source distribution needs: [test] diff --git a/tests/benchmarks/__init__.py b/tests/benchmarks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/benchmarks/test_cellfinder.py b/tests/benchmarks/test_cellfinder.py deleted file mode 100644 index c323aed0..00000000 --- a/tests/benchmarks/test_cellfinder.py +++ /dev/null @@ -1,100 +0,0 @@ -import json -import subprocess -from pathlib import Path - -import pytest -from asv import util - - -@pytest.fixture() -def asv_config_monkeypatched_path(tmp_path: Path) -> str: - """ - Create a monkeypatched asv.conf.json file - in a Pytest-generated temporary directory - and return its path - - Parameters - ---------- - tmp_path : Path - path to pytest-generated temporary directory - - Returns - ------- - str - Path to monkeypatched asv config file - """ - # read reference asv config - asv_original_path = Path(__file__).resolve().parents[3] / "asv.conf.json" - asv_monkeypatched_dict = util.load_json( - asv_original_path, js_comments=True - ) - - # change directories - for ky in ["env_dir", "results_dir", "html_dir"]: - asv_monkeypatched_dict[ky] = str( - Path(tmp_path) / asv_monkeypatched_dict[ky] - ) - - # change repo to URL rather than local - asv_monkeypatched_dict[ - "repo" - ] = "https://github.com/brainglobe/brainglobe-workflows.git" - - # define path to a temp json file to dump config data - asv_monkeypatched_path = tmp_path / "asv.conf.json" - - # save monkeypatched config data to json file - with open(asv_monkeypatched_path, "w") as js: - json.dump(asv_monkeypatched_dict, js) - - # check json file exists - assert asv_monkeypatched_path.is_file() - - return str(asv_monkeypatched_path) - - -@pytest.mark.skip(reason="focus of PR32") -def test_run_benchmarks(asv_config_monkeypatched_path): - # --- ideally monkeypatch an asv config so that results are in tmp_dir? - - # set up machine (env_dir, results_dir, html_dir) - asv_machine_output = subprocess.run( - [ - "asv", - "machine", - "--yes", - "--config", - asv_config_monkeypatched_path, - ] - ) - assert asv_machine_output.returncode == 0 - - # run benchmarks - asv_benchmark_output = subprocess.run( - [ - "asv", - "run", - "--config", - asv_config_monkeypatched_path, - # "--dry-run" - # # Do not save any results to disk? not truly testing then - ], - cwd=str( - Path(asv_config_monkeypatched_path).parent - ), # run from where asv config is - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - encoding="utf-8", - ) - # STDOUT: "· Cloning project\n· Fetching recent changes\n· - # Creating environments\n· No __init__.py file in 'benchmarks'\n" - - # check returncode - assert asv_benchmark_output.returncode == 0 - - # check logs? - - # delete directories? - # check teardown after yield: - # https://docs.pytest.org/en/6.2.x/fixture.html#yield-fixtures-recommended