Skip to content

Commit

Permalink
Add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Aug 2, 2024
1 parent aefb102 commit 83282b8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .github/workflows/tox.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ on:
pull_request:

jobs:
test:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: pip install pre-commit poetry

- name: Run pre-commit checks
run: pre-commit run --all-files
tox:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
coverage: 'codecov'
Expand Down
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
# Prevent giant files from being committed.
- id: check-case-conflict
# Check for files with names that would conflict on a case-insensitive
# filesystem like MacOS HFS+ or Windows FAT.
- id: check-json
# Attempts to load all json files to verify syntax.
- id: check-merge-conflict
# Check for files that contain merge conflict strings.
- id: check-symlinks
# Checks for symlinks which do not point to anything.
- id: check-toml
# Attempts to load all TOML files to verify syntax.
- id: check-xml
# Attempts to load all xml files to verify syntax.
- id: check-yaml
# Attempts to load all yaml files to verify syntax.
- id: detect-private-key
# Checks for the existence of private keys.
- id: end-of-file-fixer
# Makes sure files end in a newline and only a newline.
- id: trailing-whitespace
# Trims trailing whitespace.
exclude_types: [python] # Covered by Ruff W291.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.5
hooks:
# Run the linter.
- id: ruff
args: ["--extend-select", "I", "--fix"]
# Run the formatter.
- id: ruff-format

0 comments on commit 83282b8

Please sign in to comment.