From c22140f02355748c21d781788d74d61a92e109c1 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Fri, 15 Mar 2024 08:36:45 +0100 Subject: [PATCH] Check build (#27) --- .github/workflows/pytest.yml | 40 ++++++++++++++++++++++++----------- .pre-commit-config.yaml | 11 ++++------ README.rst | 5 ++++- examples/rnn_dbscan_big.py | 1 - examples/rnn_dbscan_simple.py | 1 - pyproject.toml | 8 +++---- 6 files changed, 39 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 2127a27..89b5d4d 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,6 +1,10 @@ name: Run tests -on: [push, workflow_dispatch] +on: + push: + branches: [main] + pull_request: + workflow_dispatch: jobs: test: @@ -9,12 +13,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + filter: blob:none + fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" cache: pip - name: Install project and dependencies @@ -23,14 +30,23 @@ jobs: - name: Run test suite run: pytest -v --color=yes - check: # TODO: replace with pre-commit.ci + check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 with: - python-version: "3.10" - cache: pip - - uses: pre-commit/action@v3.0.0 - env: - SKIP: no-commit-to-branch # only for local development + filter: blob:none + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + # cache: pip # TODO: cache tools + + - name: Install tools + run: pip install twine build + + - name: Build and check + run: | + python -m build + twine check dist/*.whl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13a5206..849e16b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,16 +12,13 @@ repos: - id: detect-private-key - id: no-commit-to-branch args: ["--branch=main"] - - repo: https://github.com/psf/black - rev: "23.12.0" - hooks: - - id: black - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.7 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.2 hooks: - id: ruff args: ["--fix"] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.4 + rev: v4.0.0-alpha.8 hooks: - id: prettier diff --git a/README.rst b/README.rst index 0845627..8db98d6 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,9 @@ .. -*- mode: rst -*- -|ReadTheDocs|_ +|PyPI|_ |ReadTheDocs|_ + +.. |PyPI| image:: https://img.shields.io/pypi/v/sklearn-ann +.. _PyPI: https://pypi.org/project/sklearn-ann/ .. |ReadTheDocs| image:: https://readthedocs.org/projects/sklearn-ann/badge/?version=latest .. _ReadTheDocs: https://sklearn-ann.readthedocs.io/en/latest/?badge=latest diff --git a/examples/rnn_dbscan_big.py b/examples/rnn_dbscan_big.py index 37066dd..15a0fe1 100644 --- a/examples/rnn_dbscan_big.py +++ b/examples/rnn_dbscan_big.py @@ -6,7 +6,6 @@ Tests RnnDBSCAN on a large dataset. Requires pandas. """ -print(__doc__) import numpy as np from joblib import Memory diff --git a/examples/rnn_dbscan_simple.py b/examples/rnn_dbscan_simple.py index fbca3d8..3220499 100644 --- a/examples/rnn_dbscan_simple.py +++ b/examples/rnn_dbscan_simple.py @@ -8,7 +8,6 @@ Mostly copypasted from sklearn's DBSCAN example. """ -print(__doc__) import numpy as np from sklearn import metrics diff --git a/pyproject.toml b/pyproject.toml index 3a1d6ab..82ebe4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,9 +55,7 @@ addopts = [ # this will notify us when a test considered broken starts succeeding. xfail_strict = true -[tool.ruff] -# TODO: remove `target-version` when switching to PEP 621 -target-version = "py39" +[tool.ruff.lint] select = [ "F", # Pyflakes "E", # Pycodestyle errors @@ -72,9 +70,9 @@ ignore = [ # Don’t complain about “confusables” "RUF001", "RUF002", "RUF003" ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "examples/*.py" = ["E402"] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["sklearn_ann"] [tool.hatch.envs.default]