Skip to content

Commit

Permalink
add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
erexer committed Oct 15, 2024
1 parent 62f7418 commit 8554475
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ The following is the recommended workflow for contributing to **cerf**:
git clone https://github.com/<your-user-name>/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
Expand All @@ -48,12 +50,14 @@ The following is the recommended workflow for contributing to **cerf**:
git commit -m '<my short message>'
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
Expand All @@ -62,6 +66,7 @@ The following is the recommended workflow for contributing to **cerf**:
git push origin <my-branch-name>
5. Submit a pull request with the following information:

- **Purpose**: The reason for your pull request in short
Expand Down
15 changes: 9 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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]
Expand All @@ -71,4 +74,4 @@ Documentation = "https://immm-sfa.github.io/cerf"

[tool.hatch.build]
packages = ["cerf"] # set importable package name to "cerf"
include = ["cerf"]
include = ["cerf"]

0 comments on commit 8554475

Please sign in to comment.