Skip to content

Commit

Permalink
Add pre-commit and its workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
VDuchauffour committed May 22, 2023
1 parent 6b0d5f5 commit 071ead4
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pre_commit_auto_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Run a pre-commit autoupdate every week and open a pull request if needed
name: Pre-commit auto-update

on:
# At 00:00 on the 1st of every month.
schedule:
- cron: "0 0 1 * *"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
pre-commit-auto-update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit autoupdate
- name: Set git config
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- uses: peter-evans/create-pull-request@v5
with:
token: ${{ github.token }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "Update pre-commit hooks"
body: Update versions of pre-commit hooks to latest version.
labels: "dependencies,github_actions"
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-xml
- id: check-json
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: check-executables-have-shebangs
- id: check-case-conflict
- id: check-added-large-files
- id: detect-aws-credentials
- id: detect-private-key
# Formatter for Json and Yaml files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
types: [json, yaml, toml]
# Formatter for markdown files
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
args: ["--number"]
additional_dependencies:
- mdformat-gfm
- mdformat-tables
- mdformat-frontmatter
- mdformat-black
- mdformat-shfmt
# An extremely fast Python linter, written in Rust
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.263"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
# Python code formatter
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: ["--config", "pyproject.toml"]
# Python's import formatter
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
# Formats docstrings to follow PEP 257
- repo: https://github.com/PyCQA/docformatter
rev: v1.6.4
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: ["--in-place", "--config", "pyproject.toml"]
# Python tool for docstring coverage
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args:
[
"--config",
"pyproject.toml",
"--generate-badge",
".github/assets/badges",
"--badge-style",
"flat",
]
pass_filenames: false

0 comments on commit 071ead4

Please sign in to comment.