Skip to content

Commit 21ee2ad

Browse files
committed
pre-commit: add initial config and workflow
1 parent 5bed4c5 commit 21ee2ad

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: PreCommit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
PreCommit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- uses: actions/setup-python@v6
18+
with:
19+
python-version: 3.x
20+
- uses: pre-commit/[email protected]
21+
- uses: pre-commit-ci/[email protected]
22+
if: always()
23+
with:
24+
msg: "pre-commit: apply automatic fixes"

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Recommended workflow:
2+
# - `git add --verbose --patch` to stage changes
3+
# - `git commit` to commit them
4+
# - rinse and repeat, if pre-commit wants / applied changes
5+
#
6+
# To limit impact to just the `docs` subfolder, uncomment the below
7+
# files: ^docs/
8+
9+
repos:
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v6.0.0
12+
hooks:
13+
- id: trailing-whitespace
14+
- id: end-of-file-fixer
15+
- id: check-added-large-files
16+
17+
- repo: https://github.com/executablebooks/mdformat
18+
rev: 0.7.22
19+
hooks:
20+
- id: mdformat
21+
additional_dependencies:
22+
- mdformat-black
23+
- mdformat-beautysh
24+
- mdformat-gfm
25+
- mdformat-myst
26+
- setuptools # Necessary until beautysh fix their stuff, see: https://github.com/hukkin/mdformat/issues/442
27+
28+
- repo: https://github.com/jackdewinter/pymarkdown
29+
rev: v0.9.32
30+
hooks:
31+
- id: pymarkdown
32+
args:
33+
- --config=docs/.sphinx/.pymarkdown.json
34+
- fix

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
## Upcoming
44

55
* Changes metrics script to a less brittle Python script
6+
* Adds pre-commit configuration for automatic fixes and checks
67

78
### Added
89

910
* `docs/.sphinx/metrics/build_metrics.py` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
11+
* `.pre-commit-config.py`
1012

1113
## Changed
1214

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ This directory contains files used for documentation build checks via GitHub's C
2929

3030
The file `test-starter-pack.yml` tests the functionality of the starter pack project.
3131

32+
### `.pre-commit-config.yaml`
33+
34+
This file has configuration for [pre-commit](pre-commit) checks for automatic fixes and checks, local or in CI.
35+
36+
It can apply the automatic fixes directly through [the GitHub App](pre-commit-ci-lite) - configure it to enable access to repositories you want it on.
37+
3238
## Contributing
3339

3440
We welcome contributions to this project! If you have suggestions, bug fixes, or improvements, please open an issue or submit a pull request.
@@ -39,3 +45,5 @@ Please read and sign our [Contributor Licence Agreement (CLA)] before submitting
3945

4046
[Sphinx]: https://www.sphinx-doc.org/
4147
[Contributor Licence Agreement (CLA)]: https://ubuntu.com/legal/contributors
48+
[pre-commit]: https://pre-commit.com/
49+
[pre-commit-ci-lite]: https://github.com/apps/pre-commit-ci-lite

0 commit comments

Comments
 (0)