Skip to content

Commit

Permalink
Merge pull request #22 from canonical/add-precommit-checks
Browse files Browse the repository at this point in the history
Add pre-commit checks
  • Loading branch information
dviererbe committed Jul 26, 2023
2 parents 3bfbad6 + 00ec3af commit 2260e1f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/get-woke/woke
rev: v0.19.0
hooks:
- id: woke
args: ["-c", "https://github.com/canonical-web-and-design/Inclusive-naming/raw/main/config.yml"]
files: \.rst
2 changes: 2 additions & 0 deletions .wokeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.sphinx/
_build/
27 changes: 27 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,30 @@ Some notes about translating the guide:

To test your translation, use ``make BUILDER-LANGUAGE`` command (for example,
``make html-it`` will build HTML docs in Italian language).

Pre-commit checks
-----------------

Optionally, you can run pre-commit checks on your changes. To do so, run::

make install-pre-commit-hooks

The following checks are run automatically on the staged files before every commit:
- Inclusive naming checks (``woke``).

To run all pre-commit checks on all files, run::

make pre-commit

You can ignore a violation reported by ``woke``.
- To ignore an entire file, specify the file name in the ``.wokeignore`` file at the root of this repository::

# This will ignore the report.xml file in the build directory
build/report.xml

- To ignore a single line, use ``.. wokeignore:rule=<violation-name>`` before the line::

.. wokeignore:rule=foo
This line containing foo will be ignored.

For more information on ignoring ``woke`` violations, see `<https://docs.getwoke.tech/ignore/>`_.
17 changes: 14 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,20 @@ linkcheck: html epub
$(IN_VENV); $(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)"/html
$(IN_VENV); $(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)"/epub

woke:
type woke >/dev/null 2>&1 || { snap install woke; exit 1; }
woke $(find -name "*.rst") -c https://github.com/canonical-web-and-design/Inclusive-naming/raw/main/config.yml
install-pre-commit:
type pre-commit >/dev/null 2>&1 || sudo apt install -y pre-commit

install-woke:
type woke >/dev/null 2>&1 || sudo snap install woke

install-pre-commit-hooks: install-pre-commit install-woke
pre-commit install --install-hooks

pre-commit: install-pre-commit install-woke
pre-commit run -a

woke: install-pre-commit install-woke
pre-commit run woke -a

.PHONY: help Makefile

Expand Down
2 changes: 2 additions & 0 deletions docs/explanation/auto-pkg-test.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ can find examples of these tests and easily assign them to yourself.
If you should run into any problems, you can join the `#ubuntu-quality IRC
channel <qualityirc_>`_ to get in touch with developers who can help you.
.. wokeignore:rule=master
.. _DEP8: https://salsa.debian.org/ci-team/autopkgtest/blob/master/doc/README.package-tests.rst
.. _libxml2: https://git.launchpad.net/ubuntu/+source/libxml2/tree/debian/tests
.. _gvfs: https://git.launchpad.net/ubuntu/+source/gvfs/tree/debian/tests
.. _gtk3: https://git.launchpad.net/ubuntu/+source/gtk+3.0/tree/debian/tests
.. _ubiquity: https://bazaar.launchpad.net/+branch/ubiquity/files/head:/debian/tests/
.. _jenkins: http://autopkgtest.ubuntu.com/
.. wokeignore:rule=master
.. _running_tests: https://salsa.debian.org/ci-team/autopkgtest/blob/master/doc/README.running-tests.rst
.. _requiredtests: https://wiki.ubuntu.com/QATeam/RequiredTests
.. _qualityirc: https://web.libera.chat/#ubuntu-quality

0 comments on commit 2260e1f

Please sign in to comment.