From: Bernhard Kaindl Date: Fri, 5 Jan 2024 11:00:00 +0000 (+0100) Subject: CI: Add basic pre-commit integration and hook into Github Actions X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=aedcc76764306f221c6131d36abd600b2e04e909;p=people%2Fandrewcoop%2Fxen-test-framework.git CI: Add basic pre-commit integration and hook into Github Actions Signed-off-by: Bernhard Kaindl Signed-off-by: Andrew Cooper --- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fac842d..d370c2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 index 0000000..6bf5c96 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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