Skip to content

Commit 6a01666

Browse files
feat(PRE-COMMIT): add poetry-sphinx-build-language hook with custom types and CI fixes
This commit implements the `poetry-sphinx-build-language` pre-commit hook. Key changes: - Created `src/cicd_tools_pre_commit/sphinx.py` with the build logic. - Created `src/cicd_tools_pre_commit/system/argparse_types.py` for reusable validation logic. - Refactored logic to use custom argparse types for directory and path validation. - Exposed `sphinx_build_language` in `src/cicd_tools_pre_commit/__init__.py`. - Added the script to `pyproject.toml`. - Registered and sorted the hook in `.pre-commit-hooks.yaml`. - Fixed YAML indentation in `.pre-commit-hooks.yaml` to pass YAML linting. - Added unit tests in `src/cicd_tools_pre_commit/tests/test_sphinx.py`. Co-authored-by: niall-byrne <9848926+niall-byrne@users.noreply.github.com>
1 parent 804f457 commit 6a01666

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

.pre-commit-hooks.yaml

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,55 @@
44
description: Install a CICD-Tools toolbox from the gpg key verified manifest.
55
entry: ./src/pre-commit/cicd-tools-box.sh -c curlimages/curl:8.90.@sha256:4c1cc1c836054961219e03d71e3f48a993aa40b92c3482eed316e50ede4889d9 -j ghcr.io/cicd-tools-org/cicd-tools:main -g ghcr.io/cicd-tools-org/cicd-tools-gpg:main
66
args:
7-
- -b
8-
- 0.1.0
9-
- -m
10-
- https://raw.githubusercontent.com/cicd-tools-org/manifest/main/manifest.json.asc
7+
- -b
8+
- 0.1.0
9+
- -m
10+
- https://raw.githubusercontent.com/cicd-tools-org/manifest/main/manifest.json.asc
1111
always_run: true
1212
language: script
1313
pass_filenames: false
1414
require_serial: true
1515
stages:
16-
- manual
16+
- manual
1717
- id: cicd-tools-key
1818
name: cicd-tools-key
1919
description: Import the CICD-Tools gpg key for toolbox manifest verification.
2020
entry: ./src/pre-commit/cicd-tools-key.sh -g ghcr.io/cicd-tools-org/cicd-tools-gpg:main
2121
args:
22-
- -n
23-
- F07A79647E91E561A786B6D0D9020F7FEE20DBF2
24-
- -p
25-
- hkps://keys.openpgp.org
26-
- -s
27-
- keyserver.ubuntu.com
22+
- -n
23+
- F07A79647E91E561A786B6D0D9020F7FEE20DBF2
24+
- -p
25+
- hkps://keys.openpgp.org
26+
- -s
27+
- keyserver.ubuntu.com
2828
always_run: true
2929
language: script
3030
pass_filenames: false
3131
require_serial: true
3232
stages:
33-
- manual
33+
- manual
3434
- id: cicd-tools-schema-cookiecutter
3535
name: cicd-tools-schema-cookiecutter
3636
description: Verify a JSON file against the CICD-Tools cookiecutter schema.
3737
entry: with-cicd-resources check-jsonschema
3838
args:
39-
- --schemafile
40-
- '{CICD_RESOURCES}/schemas/cookiecutter.json'
39+
- --schemafile
40+
- '{CICD_RESOURCES}/schemas/cookiecutter.json'
4141
language: python
4242
pass_filenames: true
4343
stages:
44-
- commit
44+
- commit
4545
- id: cicd-tools-schema-manifest
4646
name: cicd-tools-schema-manifest
4747
description: Verify a JSON file against the CICD-Tools manifest schema.
4848
entry: with-cicd-resources check-jsonschema
4949
args:
50-
- --schemafile
51-
- '{CICD_RESOURCES}/schemas/manifest.json'
50+
- --schemafile
51+
- '{CICD_RESOURCES}/schemas/manifest.json'
5252
language: python
5353
pass_filenames: true
5454
stages:
55-
- commit
55+
- commit
5656
- id: commitizen-pre-bump
5757
name: commitizen-pre-bump
5858
description: TOML quote formatting for commitizen.
@@ -62,22 +62,22 @@
6262
pass_filenames: false
6363
require_serial: true
6464
stages:
65-
- manual
65+
- manual
6666
- id: format-shell
6767
name: format-shell
6868
description: Format the project's shell scripts.
6969
entry: --entrypoint=shfmt --env=FORCE_COLOR=1 ghcr.io/cicd-tools-org/cicd-tools:main
7070
args:
71-
- -w
72-
- --indent=2
73-
- -ci
74-
- -sr
71+
- -w
72+
- --indent=2
73+
- -ci
74+
- -sr
7575
exclude: ^\.cicd-tools/boxes/.+$
7676
files: ^.+\.(bash|sh)$
7777
language: docker_image
7878
pass_filenames: true
7979
stages:
80-
- commit
80+
- commit
8181
- id: format-toml
8282
name: format-toml
8383
description: Format the project's TOML files.
@@ -86,7 +86,7 @@
8686
language: docker_image
8787
pass_filenames: true
8888
stages:
89-
- commit
89+
- commit
9090
- id: gettext-translations-add
9191
name: gettext-translations-add
9292
description: Add new languages to the project folder structure for gettext.
@@ -96,7 +96,7 @@
9696
pass_filenames: false
9797
require_serial: true
9898
stages:
99-
- manual
99+
- manual
100100
- id: gettext-translations-compile
101101
name: gettext-translations-compile
102102
description: Compile gettext '.po' files into '.mo' files for distribution.
@@ -106,7 +106,7 @@
106106
pass_filenames: false
107107
require_serial: true
108108
stages:
109-
- manual
109+
- manual
110110
- id: gettext-translations-missing
111111
name: gettext-translations-missing
112112
description: Check all gettext '.po' files for untranslated strings.
@@ -117,7 +117,7 @@
117117
pass_filenames: false
118118
require_serial: true
119119
stages:
120-
- commit
120+
- commit
121121
- id: gettext-translations-update
122122
name: gettext-translations-update
123123
description: Extract translatable strings from the code base with gettext and regenerate '.pot' and '.po' files.
@@ -128,40 +128,40 @@
128128
pass_filenames: false
129129
require_serial: true
130130
stages:
131-
- commit
131+
- commit
132132
- id: git-conflict-markers
133133
name: git-conflict-markers
134134
entry: git
135135
args:
136-
- --no-pager
137-
- diff
138-
- --cached
139-
- --check
136+
- --no-pager
137+
- diff
138+
- --cached
139+
- --check
140140
language: system
141141
stages:
142-
- commit
142+
- commit
143143
- id: lint-dockerfile
144144
name: lint-dockerfile
145145
description: Lint the project's Dockerfiles.
146146
entry: --entrypoint=hadolint ghcr.io/cicd-tools-org/cicd-tools:main
147147
language: docker_image
148148
stages:
149-
- commit
149+
- commit
150150
types:
151-
- dockerfile
151+
- dockerfile
152152
- id: lint-github-workflow
153153
name: lint-github-workflow
154154
description: Lint the project's GitHub workflow files.
155155
entry: --entrypoint=actionlint ghcr.io/cicd-tools-org/cicd-tools:main
156156
args:
157-
- -color
158-
- -config-file
159-
- .cicd-tools/configuration/actionlint.yaml
157+
- -color
158+
- -config-file
159+
- .cicd-tools/configuration/actionlint.yaml
160160
files: ^.github/workflows/.+\.(yaml|yml)$
161161
language: docker_image
162162
pass_filenames: false
163163
stages:
164-
- commit
164+
- commit
165165
- id: lint-github-workflow-header
166166
name: lint-github-workflow-header
167167
description: Lint the headers of the project's GitHub workflow files.
@@ -170,34 +170,34 @@
170170
language: script
171171
pass_filenames: true
172172
stages:
173-
- commit
173+
- commit
174174
- id: lint-markdown
175175
name: lint-markdown
176176
description: Lint the Markdown files.
177177
files: ^.+\.md$
178178
entry: ghcr.io/igorshubovych/markdownlint-cli:v0.35.0@sha256:22cf4699a448a7bbc311a940e0600019423d7671cbedae9c35cd32b51f560350
179179
args:
180-
- -c
181-
- .markdownlint.yml
180+
- -c
181+
- .markdownlint.yml
182182
language: docker_image
183183
pass_filenames: true
184184
stages:
185-
- commit
185+
- commit
186186
- id: lint-shell
187187
name: lint-shell
188188
description: Lint the project's shell scripts.
189189
entry: --entrypoint=shellcheck ghcr.io/cicd-tools-org/cicd-tools:main
190190
args:
191-
- --color=always
192-
- --source-path=SCRIPTDIR
193-
- --exclude=SC2317
194-
- -x
191+
- --color=always
192+
- --source-path=SCRIPTDIR
193+
- --exclude=SC2317
194+
- -x
195195
exclude: ^\.cicd-tools/boxes/.+$
196196
files: ^.+\.(bash|sh)$
197197
language: docker_image
198198
pass_filenames: true
199199
stages:
200-
- commit
200+
- commit
201201
- id: poetry-lint-ansible
202202
name: poetry-lint-ansible
203203
description: Check the collection or role for Ansible best practices using ansible-lint from the local poetry environment.
@@ -206,15 +206,15 @@
206206
language: script
207207
pass_filenames: false
208208
stages:
209-
- commit
209+
- commit
210210
- id: poetry-lint-python
211211
name: poetry-lint-python
212212
description: Lint the project's Python files using pylint from the local poetry environment.
213213
entry: poetry run pylint
214214
files: ^.+\.py$
215215
language: system
216216
stages:
217-
- commit
217+
- commit
218218
- id: poetry-sphinx-build-language
219219
name: poetry-sphinx-build-language
220220
description: Build sphinx documentation for a specific language using poetry.
@@ -223,72 +223,72 @@
223223
pass_filenames: false
224224
require_serial: true
225225
stages:
226-
- manual
226+
- manual
227227
- id: poetry-types-python
228228
name: types-python
229229
description: Type check the project's Python files using mypy from the local poetry environment.
230230
entry: poetry run mypy
231231
args:
232-
- --strict
233-
- --show-error-codes
234-
- --implicit-reexport
235-
- --explicit-package-bases
232+
- --strict
233+
- --show-error-codes
234+
- --implicit-reexport
235+
- --explicit-package-bases
236236
files: ^.+\.pyi?$
237237
language: system
238238
require_serial: true
239239
stages:
240-
- commit
240+
- commit
241241
- id: pre-commit-sort-config
242242
name: pre-commit-sort-config
243243
description: Sort the hooks inside your pre-commit configuration files.
244244
entry: ./src/pre-commit/pre-commit-sort-config.sh
245245
args:
246-
- ghcr.io/cicd-tools-org/cicd-tools:main
246+
- ghcr.io/cicd-tools-org/cicd-tools:main
247247
files: ^(.+/)*\.pre-commit-config\.yaml$
248248
language: script
249249
pass_filenames: true
250250
require_serial: true
251251
stages:
252-
- commit
252+
- commit
253253
- id: pre-commit-sort-hooks
254254
name: pre-commit-sort-hooks
255255
description: Sort the hooks inside your pre-commit hook definition files.
256256
entry: ./src/pre-commit/pre-commit-sort-hooks.sh
257257
args:
258-
- ghcr.io/cicd-tools-org/cicd-tools:main
258+
- ghcr.io/cicd-tools-org/cicd-tools:main
259259
files: ^(.+/)*\.pre-commit-hooks\.yaml$
260260
language: script
261261
pass_filenames: true
262262
require_serial: true
263263
stages:
264-
- commit
264+
- commit
265265
- id: security-credentials
266266
name: security-credentials
267267
description: Scan codebase for checked in credentials.
268268
entry: trufflesecurity/trufflehog:3.63.2@sha256:16c1cf07b7142037a2859d4ad0f51c40603e7e58703ddb8bd80cf40e6af51f44
269269
args:
270-
- git
271-
- file://.
272-
- --fail
273-
- --no-update
274-
- --debug
275-
- --max-depth=500
270+
- git
271+
- file://.
272+
- --fail
273+
- --no-update
274+
- --debug
275+
- --max-depth=500
276276
language: docker_image
277277
pass_filenames: false
278278
stages:
279-
- commit
279+
- commit
280280
- id: spelling-commit-message
281281
name: spelling-commit-message
282282
description: Check the spelling on the commit message.
283283
entry: ./src/pre-commit/spelling-commit-message.sh
284284
args:
285-
- ghcr.io/cicd-tools-org/cicd-tools:main
285+
- ghcr.io/cicd-tools-org/cicd-tools:main
286286
always_run: true
287287
language: script
288288
pass_filenames: true
289289
require_serial: true
290290
stages:
291-
- commit-msg
291+
- commit-msg
292292
- id: spelling-markdown
293293
name: spelling-markdown
294294
description: Spellcheck the Markdown files.
@@ -297,22 +297,22 @@
297297
language: docker_image
298298
pass_filenames: true
299299
stages:
300-
- commit
300+
- commit
301301
- id: spelling-vale-sync
302302
name: spelling-vale-sync
303303
description: Download any required vale packages.
304304
entry: -v /tmp:/tmp --entrypoint=vale ghcr.io/cicd-tools-org/cicd-tools:main
305305
args:
306-
- sync
306+
- sync
307307
always_run: true
308308
language: docker_image
309309
pass_filenames: false
310310
stages:
311-
- manual
311+
- manual
312312
- id: spelling-vale-vocab
313313
name: spelling-vale-vocab
314314
entry: sh -c 'for FILE in "$@"; do sort -u -o ${FILE} ${FILE}; done' --
315315
files: ^.vale/Vocab/.+/(accept|reject)\.txt$
316316
language: system
317317
stages:
318-
- commit
318+
- commit

0 commit comments

Comments
 (0)