Skip to content

Commit

Permalink
Refactor pre-commit using composite action. (#18)
Browse files Browse the repository at this point in the history
* Refactor workflow

* Re-work .pre-commit-config

* Revert pre commit config

* Try different flake8 version

* Try changing isort version
  • Loading branch information
wagnerlmichael authored May 9, 2024
1 parent 342de02 commit 88a5481
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 57 deletions.
28 changes: 3 additions & 25 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install pre-commit
run: python -m pip install pre-commit isort flake8 black
shell: bash

- name: Freeze dependencies
run: python -m pip freeze --local
shell: bash

- name: Cache pre-commit environment
uses: actions/cache@v3
with:
path: |
~/.cache/pre-commit
~/.cache/R
key: pre-commit-3-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
shell: bash
- name: Run pre-commit checks
uses: ccao-data/actions/pre-commit@main
58 changes: 26 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
repos:
- repo: local
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
language_version: python3
types: [python]
files: '^(assesspy/|tests/)'

- id: black
name: black
entry: black
language: system
types: [ python ]
files: ^(assesspy/|tests/)

- id: isort
name: isort
entry: isort
language: system
types: [ python ]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args:
- '--line-length=110'
- '--multi-line=3'
- '--force-grid-wrap=0'
- '--trailing-comma'
- '--use-parentheses'
- '--ensure-newline-before-comments'
types: [python]
exclude: '.*/migrations/.*'
args: [
'--line-length=110',
'--multi-line=3',
'--force-grid-wrap=0',
'--trailing-comma',
'--use-parentheses',
'--ensure-newline-before-comments',
]

- id: flake8
name: flake8
entry: flake8
language: system
types: [ python ]
files: ^(assesspy/|tests/)
args: [
'--per-file-ignores=
assesspy/*:E501
assesspy/__init__.py:F401'
]
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args:
- '--per-file-ignores=assesspy/*:E501 assesspy/__init__.py:F401'
types: [python]
files: '^(assesspy/|tests/)'

0 comments on commit 88a5481

Please sign in to comment.