Skip to content

Commit

Permalink
[CHORE] Configure ruff to use isort and add workflow to auto-update p…
Browse files Browse the repository at this point in the history
…re-commit (#57)

* feat: configure ruff to use isort and add workflow to auto update pre-commit

* ci: add manual trigger on auto-update-pre-commit.yaml
  • Loading branch information
seyLu authored Sep 9, 2023
1 parent 9ec3d08 commit 81e54c5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 24 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/auto-update-pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Auto-update Pre-commit
run-name: Updating Pre-commit Configuration on ${{ github.repository }}

on:
schedule:
- cron: '0 0 * * 0' # Run every Sunday at midnight UTC
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'info'

jobs:
auto_update:
name: Perform auto-update of pre-commit configuration
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.11"]

steps:
- name: Harden Runner
uses: step-security/harden-runner@394d78e5b40cc35c170eb909b1f81551f37feb05 # v2.5.0
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.5.3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@f97b83114c6f41cfaa57698147ad3ce20543a127 # v4.7.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install and upgrade PIP
run: python -m pip install --upgrade pip

- name: Install Pre-commit
run: pip install pre-commit

- name: Update pre-commit
run: pre-commit autoupdate

- name: Create PR
uses: peter-evans/create-pull-request@6d9c0cdf5825c01278b6e63a0788434e6b3c5e27 # v5.0.2
with:
token: ${{ secrets.SEYLUBOT_PAT }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
delete-branch: true
branch-suffix: 'timestamp'
4 changes: 0 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@ jobs:
run: >
pip install
ruff
isort
black
mypy
- name: Ruff Linter
run: ruff check . --diff

- name: Isort Import Sorter
run: isort . --diff --check

- name: Black Formatter
run: black . --diff --check

Expand Down
11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
rev: v0.0.287
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.0
hooks:
- id: black
1 change: 0 additions & 1 deletion cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
__maintainer__ = "seyLu"
__status__ = "Prototype"


import json
import logging
import os
Expand Down
17 changes: 6 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ authors = [


[tool.ruff]
# Enable flake8-bugbear (`B`) rules.
select = ["E", "F", "B"]
select = [
"E", # Pyflakes
"F", # Pycodestyle
"B", # flake8-bugbear
"I001" # isort
]

# Never enforce `E501` (line length violations).
ignore = ["E501"]
Expand All @@ -37,14 +41,5 @@ implicit_reexport = "True"
# Exclude type checking on files/dirs
exclude = [
# TOML basic string (double-quotes, backslash and other characters need escaping)
"app",
"migrations",
"routers",

# TOML literal string (single-quotes, no escaping necessary)
'/managers\.py$',
'/models\.py$',
'/serializers\.py$',
'/urls\.py$',
'/views\.py$',
]

0 comments on commit 81e54c5

Please sign in to comment.