pre-commit: add sanity checks
authorAndrea Righi <andrea.righi@canonical.com>
Mon, 11 Dec 2023 13:44:19 +0000 (14:44 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 11 Dec 2023 13:59:01 +0000 (14:59 +0100)
Add pre-commit config to perform sanity checks. It is possible to run
these checks locally via:

 $ pre-commit run --all

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
.pre-commit-config.yaml [new file with mode: 0644]

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..a8ad20f
--- /dev/null
@@ -0,0 +1,40 @@
+# Use pyproject.toml to specify any non-standard command line args
+# - We use a sha1 rev to avoid labels getting moved unexpectedly
+# - Liberally provide file filters
+#   https://pre-commit.com/#filtering-files-with-types
+repos:
+- repo: https://github.com/pre-commit/pre-commit-hooks
+  rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # v4.4.0
+  hooks:
+    # Validate Python syntax
+  - id: check-ast
+    types: [python]
+  - id: check-executables-have-shebangs
+  - id: check-shebang-scripts-are-executable
+  - id: check-symlinks
+  - id: check-toml
+  - id: check-yaml
+  - id: debug-statements
+    types: [python]
+  - id: end-of-file-fixer
+  - id: trailing-whitespace
+    types_or: [python, shell]
+- repo: https://github.com/psf/black
+  rev: bf7a16254ec96b084a6caf3d435ec18f0f245cc7 # 23.3.0
+  hooks:
+  - id: black
+    types: [python]
+- repo: https://github.com/astral-sh/ruff-pre-commit
+  rev: 14b59ee3b18bd49d0816d1f36820c97110e780cc # v0.0.270
+  hooks:
+  - id: ruff
+    types: [python]
+- repo: local
+  hooks:
+  - id: shellcheck
+    name: shellcheck
+    description: Test shell scripts with shellcheck
+    entry: shellcheck
+    language: python
+    types: [shell]
+    require_serial: true