Skip to content

Commit

Permalink
Use pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins committed Jan 30, 2024
1 parent 88fa423 commit 8b78802
Show file tree
Hide file tree
Showing 178 changed files with 11,560 additions and 7,978 deletions.
13 changes: 6 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
$ py.test -v -s africanus
```

If the pep8 tests fail, the quickest way to correct
this is to run `autopep8` and then `flake8` and
`pycodestyle` to fix the remaining issues.
If the pre-commit tests fail, install and
run the pre-commit hooks in your development
virtuale environment:

```
$ pip install -U autopep8 flake8 pycodestyle
$ autopep8 -r -i africanus
$ flake8 africanus
$ pycodestyle africanus
$ pip install pre-commit
$ pre-commit install
$ pre-commit run -a
```

- [ ] Fully documented, including `HISTORY.rst` for all changes
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on: [push]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/[email protected]
with:
python-version: 3.11
- uses: pre-commit/[email protected]
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff-format
name: ruff format
29 changes: 14 additions & 15 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,35 @@ Ready to contribute? Here's how to set up `codex-africanus` for local developmen

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ mkvirtualenv codex-africanus
$ cd codex-africanus/
$ python -m venv ./africanus
$ source ./africanus/bin/activate
$ pip install -e .

4. Create a branch for local development::
4. Install the pre-commit hooks

$ pip install pre-commit
$ pre-commit install

5. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you're done making changes, check that your changes
6. When you're done making changes, check that your changes
pass the test cases, fixup your PEP8 compliance,
and check for any code style issues:

$ py.test -v africanus
$ autopep8 -r -i africanus
$ flake8 africanus
$ pycodestyle africanus

To get autopep8 and pycodestyle, just pip install them into your virtualenv.
$ py.test -vvv africanus
$ pre-commit run -a

6. Commit your changes and push your branch to GitHub::
7. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.
8. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------
Expand All @@ -104,9 +105,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in HISTORY.rst.
3. The pull request should work for Python 2.7, 3.5 and 3.6. Check
https://travis-ci.org/ska-sa/codex-africanus/pull_requests
and make sure that the tests pass for all supported Python versions.
3. The pull request should work for Python 3.9 and above.

Tips
----
Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ Documentation
-------------

https://codex-africanus.readthedocs.io.

Loading

0 comments on commit 8b78802

Please sign in to comment.