Skip to content

Commit

Permalink
ENH: Add GitHub Actions workflow for running "pre-commit"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jcfr committed Jan 13, 2024
1 parent 6f7d7dc commit 753193f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 753193f

Please sign in to comment.