Skip to content

Add pre-commit #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ concurrency:

jobs:

'pre-commit':

runs-on: 'ubuntu-24.04'

steps:

- name: "Setup Python"
uses: 'actions/setup-python@v5'
with:
python-version: '3.10'

- name: "Install pre-commit"
run: 'python -m pip install pre-commit'

- name: "Checkout"
uses: 'actions/checkout@v4'

- name: "Check with pre-commit"
run: 'pre-commit run --all-files --show-diff-on-failure'

'build-job':

runs-on: 'ubuntu-24.04'
Expand Down
13 changes: 10 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---


'.common':
'pre-commit':
image: 'python:3.10'
before_script:
- 'python -m pip install pre-commit'
script:
- 'pre-commit run --all-files --show-diff-on-failure'

'.build':
image: 'python:3.10'
before_script:
- 'apt-get --assume-yes --quiet update'
Expand All @@ -18,10 +25,10 @@
- 'cp -r build/html public'

'build':
extends: '.common'
extends: '.build'

pages:
extends: '.common'
extends: '.build'
artifacts:
paths:
- 'public'
Expand Down
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---


repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
# - id: detect-aws-credentials
- id: detect-private-key
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: file-contents-sorter
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: forbid-submodules
- id: mixed-line-ending
- id: name-tests-test
# - id: no-commit-to-branch
- id: pretty-format-json
- id: requirements-txt-fixer
- id: sort-simple-yaml
- id: trailing-whitespace


... # EOF
6 changes: 3 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

AUTHOR = 'sinoroc'
MASTER_DOCUMENT = 'contents'
SUBTITLE = "Bits of knowledge"
TITLE = "Sinoroc KB"
SUBTITLE = 'Bits of knowledge'
TITLE = 'Sinoroc KB'


#
#
# General
#

Expand Down
4 changes: 2 additions & 2 deletions src/python/package_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ In ``setup.py``:
:emphasize-lines: 6-8

#!/usr/bin/env python3

import setuptools

setuptools.setup(
exclude_package_data={'thing': ['data/*.src']},
include_package_data=True,
Expand Down
2 changes: 1 addition & 1 deletion src/python/python_imports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Python imports
* Old reference, possibly outdated, but assuming I interpreted it right, it
says that running *scripts* that live in a package is an anti pattern, and
one should use ``python -m package.module`` instead:

* https://mail.python.org/pipermail/python-3000/2007-April/006793.html
* https://www.python.org/dev/peps/pep-3122/

Expand Down
2 changes: 1 addition & 1 deletion src/python/tox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Defaults

.. code-block:: ini
:caption: tox.ini

[tox]
envlist =
py37
Expand Down