Skip to content

Commit

Permalink
Add pre-commit file
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Oct 4, 2023
1 parent db3114e commit 7dff31b
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 25 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Check RST file syntax

on:
push:
branches: [master]
pull_request:

jobs:
# Run "pre-commit run --all-files"
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4

# ref: https://github.com/pre-commit/action
- uses: pre-commit/[email protected]
- name: Help message if pre-commit fail
if: ${{ failure() }}
run: |
echo "You can install pre-commit hooks to automatically run formatting"
echo "on each commit with:"
echo " pre-commit install"
echo "or you can run by hand on staged files with"
echo " pre-commit run"
echo "or after-the-fact on already committed files with"
echo " pre-commit run --all-files --hook-stage manual"
sphinx-build:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- run: pip install sphinx
- run: cd source && sphinx-build -b html . html index.rst
25 changes: 0 additions & 25 deletions .github/workflows/rstcheck.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
#- id: end-of-file-fixer
#- id: check-json

# We use the Python version instead of the original version which seems to require Docker
# https://github.com/koalaman/shellcheck-precommit
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck
name: shellcheck
args: ["--severity=error"]
stages: [manual]

- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.0
hooks:
- id: rstcheck
additional_dependencies: [sphinx]
args: ["--ignore-languages=c,python,java", "--report-level=error"]
stages: [manual]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
hooks:
- id: check-github-workflows

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
# - id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

# - repo: https://github.com/codespell-project/codespell
# rev: "v2.2.6"
# hooks:
# - id: codespell
# exclude_types: [json,yaml]
20 changes: 20 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ Store all source documents in the ``source/`` directory.

.. _`reStructuredText`: http://docutils.sourceforge.net/rst.html

Linting
-------

This repo uses `pre-commit <https://pypi.org/project/pre-commit/>`_
for managing linting.
``pre-commit`` performs various checks on the files and uses tools
that help follow a consistent style within the repo.

To set up ``pre-commit`` locally, run:

.. code:: bash
pip install pre-commit # or brew install pre-commit
pre-commit install
To run ``pre-commit`` manually, run ``pre-commit run --all-files``.

To run a manual hook like ``rstcheck`` manually, run:

.. code:: bash
pre-commit run --all-files --hook-stage manual rstcheck
Prose test numbering
--------------------

Expand Down

0 comments on commit 7dff31b

Please sign in to comment.