Skip to content

Commit

Permalink
Added linters to the pull request GitHub action workflows (#9)
Browse files Browse the repository at this point in the history
* Added linters to the pull request GitHub action workflows

* Added linters to the pull request GitHub action workflows

* Fixed flake error

* Fixed black error

* Fixed black error v2
  • Loading branch information
palisadoes authored Jan 11, 2025
1 parent 0c7425c commit d098f0f
Show file tree
Hide file tree
Showing 14 changed files with 1,007 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = E402,E722,E203,F401,W503
max-line-length = 80
101 changes: 74 additions & 27 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,6 @@ env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}

jobs:
Python-Format-Checker:
name: Python Black Format Checker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rickstaa/action-black@v1
with:
black_args: ". --check"

Python-Linter:
name: Python Flake8 Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run lint 💅
run: tox
env:
TOXENV: flake8

Code-Quality-Checks:
name: Performs linting, formatting, type-checking, checking for different source and target branch
runs-on: ubuntu-latest
Expand All @@ -68,6 +41,28 @@ jobs:
echo "Error: Close this PR and try again."
exit 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black pydocstyle flake8-docstrings
- name: Run Black Formatter Check
run: |
black --check .
- name: Run Flake8 Linter
run: |
flake8 --docstring-convention google switchmap bin setup tests .github --ignore E402,E722,E203,F401,W503
- name: Run pydocstyle
run: |
pydocstyle switchmap setup bin tests --convention=google --add-ignore=D415,D205
Check-Sensitive-Files:
if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }}
name: Checks if sensitive files have been changed without authorization
Expand Down Expand Up @@ -179,3 +174,55 @@ jobs:
echo "Error: Pull request target branch must be 'develop'. Please refer PR_GUIDELINES.md"
echo "Error: Close this PR and try again."
exit 1
Validate-CodeRabbit:
name: Validate CodeRabbit Approval
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
needs: [Code-Quality-Checks, Test-Docusaurus-Deployment]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate CodeRabbit.ai Approval
run: |
chmod +x $GITHUB_WORKSPACE/.github/workflows/scripts/validate-coderabbit.sh
$GITHUB_WORKSPACE/.github/workflows/scripts/validate-coderabbit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}

Docstring-Compliance:
name: Check Docstring Compliance
runs-on: ubuntu-latest
needs: [Code-Quality-Checks]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run docstring compliance check
run: |
source venv/bin/activate
python .github/workflows/scripts/check_docstrings.py --directories switchmap setup bin tests .github
Loading

0 comments on commit d098f0f

Please sign in to comment.