]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
CI: Add basic pre-commit integration and hook into Github Actions
authorBernhard Kaindl <bernhard.kaindl@cloud.com>
Fri, 5 Jan 2024 11:00:00 +0000 (12:00 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 8 Jan 2024 11:24:56 +0000 (11:24 +0000)
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
.github/workflows/build.yml
.pre-commit-config.yaml [new file with mode: 0644]

index fac842d56f563bc6b33c0a917dc795eca6d4b881..d370c2fd0b10096556e727a4d6f588fa949f6792 100644 (file)
@@ -3,7 +3,26 @@ name: build
 on: [push, pull_request]
 
 jobs:
-  build:
+  python:
+    name: "Python Tests"
+
+    runs-on: ubuntu-20.04
+
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v3
+
+    - name: pre-commit checks - setup cache
+      uses: actions/cache@v3
+      with:
+        path: ~/.cache/pre-commit
+        key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
+
+    - name: pre-commit checks - run checks
+      uses: pre-commit/action@v3.0.0
+
+  C:
+    name: "C Builds"
 
     strategy:
       matrix:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..6bf5c96
--- /dev/null
@@ -0,0 +1,35 @@
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+#
+
+fail_fast: false
+default_stages: [commit, push]
+repos:
+
+-   repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.5.0
+    # https://pre-commit.com/hooks.html
+    hooks:
+    -   id: check-ast
+    -   id: check-builtin-literals
+    -   id: check-case-conflict
+    -   id: check-docstring-first
+    -   id: check-merge-conflict
+    -   id: check-symlinks
+    -   id: check-yaml
+    -   id: debug-statements
+    -   id: destroyed-symlinks
+    -   id: fix-byte-order-marker
+    -   id: fix-encoding-pragma
+    -   id: mixed-line-ending
+        args: ['--fix=lf']
+    -   id: trailing-whitespace
+
+-   repo: local
+    hooks:
+    -   id: git-diff # https://github.com/pre-commit/pre-commit/issues/1712
+        name: Show not staged changes (fixups may make them too)
+        entry: git diff --exit-code
+        language: system
+        pass_filenames: false
+        always_run: true