From 855447510982ffcf76a4e5fa43a61c02bea34952 Mon Sep 17 00:00:00 2001 From: erexer <13180883+erexer@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:03:02 -0700 Subject: [PATCH] add pre-commit --- .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ docs/source/contributing.rst | 9 +++++++-- pyproject.toml | 15 +++++++++------ 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..df51270 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +# pre-commit hooks require a user to have installed `pre-commit`: +# $ pip install pre-commit +# Then install the hooks within the repo: +# $ cd /PATH/TO/REPO +# $ pre-commit install + +repos: +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.6.9 + hooks: + - id: ruff + args: [ --fix, --exit-non-zero-on-fix] + exclude: .rst +- repo: https://github.com/psf/black + rev: 24.10.0 + hooks: + - id: black + args: [--line-length=100] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-ast + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 17f6b97..7838962 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -21,11 +21,13 @@ The following is the recommended workflow for contributing to **cerf**: git clone https://github.com//cerf - Cloning the repository will give you access to the test suite. It is important to install the package in development mode before running tests. This will give you the flexibility to make changes in the code without having to rebuild your package before running tests. To do this run the following from your terminal in the **cerf** directory containing your ``setup.py`` script: + + Cloning the repository will give you access to the test suite. It is important to install the package in development mode before running tests. This will give you the flexibility to make changes in the code without having to rebuild your package before running tests. Also install `pre-commit`, a code formatting tool. To do this run the following from your terminal in the **cerf** directory containing the ``pyproject.toml`` file: .. code-block:: bash - python setup.py develop + pip install -e ".[dev]" + pre-commit install 2. Create a branch for your changes @@ -48,12 +50,14 @@ The following is the recommended workflow for contributing to **cerf**: git commit -m '' + Changes to the documenation can be made in the ``cerf/docs/source`` directory containing the RST files. To view your changes, ensure you have the development dependencies of **cerf** installed and run the following from the ``cerf/docs/source`` directory: .. code-block:: bash make html + This will generate your new documentation in a directory named ``cerf/docs/build/html``. You can open the ``index.html`` in your browser to view the documentation site locally. If your changes are merged into the main branch of **cerf**, changes in your documentation will go live as well. 4. Push your changes to the remote @@ -62,6 +66,7 @@ The following is the recommended workflow for contributing to **cerf**: git push origin + 5. Submit a pull request with the following information: - **Purpose**: The reason for your pull request in short diff --git a/pyproject.toml b/pyproject.toml index 6d84998..a716c56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,9 +45,11 @@ classifiers = [ ] [project.optional-dependencies] -test = [ - "pytest>=6.0", - "pytest-cov>=2.12.1", +deploy = [ + "twine>=4.0.1", +] +dev = [ + "pre-commit>=4.0.1", ] docs = [ "setuptools>=57.0.0", @@ -61,8 +63,9 @@ docs = [ "sphinx-mathjax-offline~=0.0.2", "sphinx-panels>=0.6.0", ] -deploy = [ - "twine>=4.0.1", +test = [ + "pytest>=6.0", + "pytest-cov>=2.12.1", ] [project.urls] @@ -71,4 +74,4 @@ Documentation = "https://immm-sfa.github.io/cerf" [tool.hatch.build] packages = ["cerf"] # set importable package name to "cerf" -include = ["cerf"] \ No newline at end of file +include = ["cerf"]