From 753193f358a55dfb3a23f1c2b50ccf46ee334dbb Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Sat, 13 Jan 2024 11:41:58 -0500 Subject: [PATCH] ENH: Add GitHub Actions workflow for running "pre-commit" This commit adds workflow leveraging pre-commit, a framework for managing and maintaining pre-commit hooks. See https://pre-commit.com/ and https://github.com/pre-commit/action Running the pre-commit locally can be done using the following command: pre-commit run --all-files The hooks enabled in the "pre-commit-config.yaml" configuration file are: * check-added-large-files Prevent giant files from being committed. Set the size to 1024 to match the value hard-coded in https://github.com/Slicer/Slicer/blob/hooks/pre-commit#L125 * check-case-conflict Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT. * check-merge-conflict Check for files that contain merge conflict strings. * check-symlinks Checks for symlinks which do not point to anything. --- .github/workflows/lint.yml | 25 +++++++++++++++++++++++++ .pre-commit-config.yaml | 9 +++++++++ 2 files changed, 34 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..7d867a5929 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: CI (Lint) + +on: + # Triggers the workflow on push or pull request events + push: + branches: [ master ] + pull_request: + branches: + - "*" + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: '3.9' + + - uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..175be59f44 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.4.0" + hooks: + - id: check-added-large-files + args: ['--maxkb=1024'] + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks