Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/build linter #43

Merged
merged 8 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Linters

on:
pull_request:
branches:
- main

push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
PYTHON_VERSION: 3.9.12

jobs:
pylint:
name: pylint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set package version
run: |
pylint_version="$(grep '^pylint' requirements.txt | grep -oE '\-?[0-9]+\.[0-9]+\.[0-9]+')"
echo "pylint_version=$pylint_version" >> "$GITHUB_ENV"
- name: Install package
run: python -m pip install pylint==${{ env.pylint_version }}
- name: Set changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
*.py
- name: pylint
run: |
[[ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]] &&
echo "${{ steps.changed-files.outputs.all_changed_files }}" | xargs pylint ||
echo "0 Python files changed."
isort:
name: isort
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION || '3.9.12'}}
- name: Set package version
run: |
isort_version="$(grep '^isort' requirements.txt | grep -oE '\-?[0-9]+\.[0-9]+\.[0-9]+')"
echo "isort_version=$isort_version" >> "$GITHUB_ENV"
- name: Install package
run: python -m pip install isort==${{ env.isort_version }}
- name: Set changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
*.py
- name: isort
run: |
[[ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]] &&
echo "${{ steps.changed-files.outputs.all_changed_files }}" | xargs isort --check --diff ||
echo "0 Python files changed."
black:
name: black
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION || '3.9.12'}}
- name: Set package version
run: |
black_version="$(grep '^black' requirements.txt | grep -oE '\-?[0-9]+\.[0-9]+\.[0-9]+')"
echo "black_version=$black_version" >> "$GITHUB_ENV"
- name: Install package
run: python -m pip install black==${{ env.black_version }}
- name: Set changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
*.py
- name: black
run: |
[[ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]] &&
echo "${{ steps.changed-files.outputs.all_changed_files }}" | xargs black --check --diff ||
echo "0 Python files changed."
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
name: black
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
name: isort
- repo: https://github.com/PyCQA/pylint
rev: v2.15.5
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args: ["-rn", "-sn", "--rcfile=.pylintrc", "--fail-on=I"]