From 5921799e33d45cabeb68190ed6455a4e4c2412ad Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 21 May 2024 00:11:17 +0200 Subject: [PATCH] Add pre-commit action workflow This patch adds a GitHub Action workflow to run [pre-commit](https://pre-commit.com/) to run checks on changed files. The following checks are active: - check-added-large-files: prevent large files from being committed - check-case-conflict: checks for files that would conflict in case-insensitive filesystems - check-toml, check-yaml: check toml/yaml parseability - end-of-file-fixer: make sure files end with newline - mixed-line-ending: check for mixed line endings - trailing-whitespace: no trailing whitespace To configure `pre-commit` to run locally when committing: i) install pre-commit and ii) install the hook with `pre-commit install`. --- .github/workflows/pre-commit.yml | 13 +++++++++++++ .pre-commit-config.yaml | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000000..6531e54d4c --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,13 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [master] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..6c219d29c1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace