From cb767a8f3b4eec82c6be9cc2210a3632da3b52b1 Mon Sep 17 00:00:00 2001 From: Robin-Manuel Thiel Date: Thu, 18 Apr 2024 11:47:38 +0200 Subject: [PATCH] Fix GitHub workflow for Git Hooks and add Git Hooks to this repo --- .github/workflows/style.yaml | 10 ++++++- .gitlint | 3 +++ .pre-commit-config.yaml | 26 +++++++++++++++++++ .../{.workflows => workflows}/style.yaml | 0 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .gitlint create mode 100644 .pre-commit-config.yaml rename src/git-hooks/templates/.github/{.workflows => workflows}/style.yaml (100%) diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index d114ffb..bb0c073 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -10,10 +10,18 @@ jobs: name: Check Coding Style runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Check EditorConfig - name: Install eclint run: sudo npm install -g eclint - name: Check EditorConfig style run: eclint check $(git ls-files) + + # Check Commit Messages + - name: Install pre-commit + run: pip install pre-commit + - name: Check commits + run: pre-commit run --hook-stage manual diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..d6714d0 --- /dev/null +++ b/.gitlint @@ -0,0 +1,3 @@ +[general] +ignore = body-is-missing +contrib = contrib-title-conventional-commits diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9f59ccb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +default_install_hook_types: +- pre-commit +- pre-push +- commit-msg + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - name: Check, that no large files have been committed + id: check-added-large-files + +- repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: '2.7.1' + hooks: + - name: Check EditorConfig + id: editorconfig-checker + alias: ec + +- repo: https://github.com/jorisroovers/gitlint + rev: "v0.19.1" + hooks: + - name: Lint commit messages + id: gitlint + - id: gitlint-ci + args: ['--commits', 'origin/main..HEAD'] diff --git a/src/git-hooks/templates/.github/.workflows/style.yaml b/src/git-hooks/templates/.github/workflows/style.yaml similarity index 100% rename from src/git-hooks/templates/.github/.workflows/style.yaml rename to src/git-hooks/templates/.github/workflows/style.yaml