Skip to content

Commit

Permalink
Add pre commit
Browse files Browse the repository at this point in the history
Signed-off-by: Joostlek <[email protected]>
  • Loading branch information
joostlek committed Feb 21, 2024
1 parent a34a808 commit 3d57888
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,55 @@ jobs:
- name: 🚀 Run ruff formatter
run: poetry run ruff format --check .



pre-commit-hooks:
name: pre-commit-hooks
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🏗 Set up Poetry
run: pipx install poetry
- name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "poetry"
- name: 🏗 Install workflow dependencies
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: 🏗 Install Python dependencies
run: poetry install --no-interaction
- name: 🚀 Check Python AST
run: poetry run pre-commit run check-ast --all-files
- name: 🚀 Check for case conflicts
run: poetry run pre-commit run check-case-conflict --all-files
- name: 🚀 Check docstring is first
run: poetry run pre-commit run check-docstring-first --all-files
- name: 🚀 Check that executables have shebangs
run: poetry run pre-commit run check-executables-have-shebangs --all-files
- name: 🚀 Check JSON files
run: poetry run pre-commit run check-json --all-files
- name: 🚀 Check for merge conflicts
run: poetry run pre-commit run check-merge-conflict --all-files
- name: 🚀 Check for broken symlinks
run: poetry run pre-commit run check-symlinks --all-files
- name: 🚀 Check TOML files
run: poetry run pre-commit run check-toml --all-files
- name: 🚀 Check XML files
run: poetry run pre-commit run check-xml --all-files
- name: 🚀 Check YAML files
run: poetry run pre-commit run check-yaml --all-files
- name: 🚀 Detect Private Keys
run: poetry run pre-commit run detect-private-key --all-files
- name: 🚀 Check End of Files
run: poetry run pre-commit run end-of-file-fixer --all-files
- name: 🚀 Trim Trailing Whitespace
run: poetry run pre-commit run trailing-whitespace --all-files

pytest:
runs-on: ubuntu-latest
strategy:
Expand Down
105 changes: 105 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
repos:
- repo: local
hooks:
- id: ruff-check
name: 🐶 Ruff Linter
language: system
types: [python]
entry: poetry run ruff check --fix
require_serial: true
stages: [commit, push, manual]
- id: ruff-format
name: 🐶 Ruff Formatter
language: system
types: [python]
entry: poetry run ruff format
require_serial: true
stages: [commit, push, manual]
- id: check-ast
name: 🐍 Check Python AST
language: system
types: [python]
entry: poetry run check-ast
- id: check-case-conflict
name: 🔠 Check for case conflicts
language: system
entry: poetry run check-case-conflict
- id: check-docstring-first
name: ℹ️ Check docstring is first
language: system
types: [python]
entry: poetry run check-docstring-first
- id: check-executables-have-shebangs
name: 🧐 Check that executables have shebangs
language: system
types: [text, executable]
entry: poetry run check-executables-have-shebangs
stages: [commit, push, manual]
- id: check-json
name: { Check JSON files
language: system
types: [json]
entry: poetry run check-json
- id: check-merge-conflict
name: 💥 Check for merge conflicts
language: system
types: [text]
entry: poetry run check-merge-conflict
- id: check-symlinks
name: 🔗 Check for broken symlinks
language: system
types: [symlink]
entry: poetry run check-symlinks
- id: check-toml
name: ✅ Check TOML files
language: system
types: [toml]
entry: poetry run check-toml
- id: check-xml
name: ✅ Check XML files
entry: check-xml
language: system
types: [xml]
- id: check-yaml
name: ✅ Check YAML files
language: system
types: [yaml]
entry: poetry run check-yaml
- id: detect-private-key
name: 🕵️ Detect Private Keys
language: system
types: [text]
entry: poetry run detect-private-key
- id: end-of-file-fixer
name: ⮐ Fix End of Files
language: system
types: [text]
entry: poetry run end-of-file-fixer
stages: [commit, push, manual]
- id: mypy
name: 🆎 Static type checking using mypy
language: system
types: [python]
entry: poetry run mypy
require_serial: true
- id: no-commit-to-branch
name: 🛑 Don't commit to main branch
language: system
entry: poetry run no-commit-to-branch
pass_filenames: false
always_run: true
args:
- --branch=main
- id: poetry
name: 📜 Check pyproject with Poetry
language: system
entry: poetry check
pass_filenames: false
always_run: true
- id: trailing-whitespace
name: ✄ Trim Trailing Whitespace
language: system
types: [text]
entry: poetry run trailing-whitespace-fixer
stages: [commit, push, manual]
Loading

0 comments on commit 3d57888

Please sign in to comment.