Skip to content

Commit

Permalink
Add pre-commit configuration and workflow
Browse files Browse the repository at this point in the history
Add our standard suite of pre-commit checks, including linting and
formatting with ruff. Arrange to run these checks on pushes and
pull requests. Remove the pep8 target from tox configuration.

This includes a dependabot configuration to keep github action
versions up to date.
  • Loading branch information
larsks committed Jan 14, 2025
1 parent 2a4ce35 commit 341f0a5
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
31 changes: 31 additions & 0 deletions .github/workflows/precommit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Run pre-commit checks"

on:
push:
pull_request:

jobs:
run-linters:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Configure caching
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: precommit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Install pre-commit
run: |
pip install pre-commit
- name: Run linters
run: |
pre-commit run --all-files
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox
- name: Lint
run: tox -epep8
- name: Unit Tests
run: tox -epy3
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-symlinks
- id: detect-private-key
- id: check-executables-have-shebangs

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff
- id: ruff-format
10 changes: 10 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends: default
rules:
line-length: disable
document-start: disable
indentation:
indent-sequences: whatever
hyphens:
max-spaces-after: 4
truthy:
check-keys: false

0 comments on commit 341f0a5

Please sign in to comment.