Skip to content

Commit

Permalink
refactor: formatter and linter in one workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Hallfred committed Sep 22, 2024
1 parent ec2070a commit 0d4dbaf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 51 deletions.
40 changes: 36 additions & 4 deletions .github/workflows/black-formatter.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Python formatter
name: Python formatter and linter

on:
push:
branches:
- main
pull_request:
branches:
- '*'
- '**'

jobs:
linter_name:
formatter:
name: runner / black
runs-on: ubuntu-latest
steps:
Expand All @@ -32,4 +32,36 @@ jobs:
author_email: [email protected]
message: 'Committing Black formatter changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lint:
name: runner / flake8
runs-on: ubuntu-latest
needs: formatter
steps:
# Step 1: Check out the current repository so that the files are available to the workflow
- uses: actions/checkout@v4

# Step 2: Install `flake8`
- name: Install flake8
run: |
pip install flake8 # Install flake8 linter
# Step 3: Set up flake8 annotations (this is optional, to annotate lint issues in the pull request)
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1

# Step 4: Run flake8 linter with two sets of rules
- name: Lint with flake8
run: |
# First run: Focus on catching critical errors related to syntax and undefined names
# This command checks for Python syntax errors (E9) and issues related to undefined names (F63, F7, F82)
# The build will stop and fail if any of these critical errors are found.
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Second run: Check for general linting issues but ignore some rules
# --ignore=C901: Ignore complexity-related issues
# --ignore=W503: Ignore line break before binary operator
# --ignore=E203: Ignore whitespace before ':'
# This will fail the build if there are other linting issues, except the ignored ones.
flake8 . --count --max-complexity=10 --max-line-length=150 --ignore=C901,W503,E203 --statistics
47 changes: 0 additions & 47 deletions .github/workflows/flake8-linter.yml

This file was deleted.

0 comments on commit 0d4dbaf

Please sign in to comment.