Skip to content

Commit

Permalink
Merge pull request #467 from vortexntnu/463-task-address-pylint-linti…
Browse files Browse the repository at this point in the history
…ng-errors-in-codebase

Add pylint configuration, fix linting issues, and update CI pipeline for Python
  • Loading branch information
kluge7 authored Sep 27, 2024
2 parents e2eb4e5 + bcd5cc4 commit 0cd2b87
Show file tree
Hide file tree
Showing 66 changed files with 3,033 additions and 1,477 deletions.
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theses
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# File containing words to ignore during the spell check.
ignore-words = .codespellignore

# Check file names as well.
check-filenames = true
28 changes: 0 additions & 28 deletions .github/workflows/black-formatter.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/clang-formatter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run clang-format Linter

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: "."
exclude: "./lib"
extensions: "h,cpp,c"
clangFormatVersion: 18
inplace: True
- uses: EndBug/add-and-commit@v9
with:
author_name: Clang Robot
author_email: [email protected]
message: "Committing clang-format changes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 0 additions & 24 deletions .github/workflows/clang-formatter.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: codespell

on: [pull_request]

jobs:
codespell:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Install codespell
run: |
sudo apt-get update
sudo apt-get install -y codespell
- name: Run codespell to fix spelling mistakes
run: |
codespell -w .
- name: Commit codespell changes
uses: EndBug/add-and-commit@v9
with:
author_name: Codespell Robot
author_email: [email protected]
message: "Committing codespell fixes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 10 additions & 10 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish Docker image to ghcr

on:
push:
branches: [ development ]
branches: [development]

env:
REGISTRY: ghcr.io
Expand All @@ -18,32 +18,32 @@ jobs:
steps:
- name: Checkout own repository
uses: actions/checkout@v3

# vortex_msgs needs to be in the same location as the rest of the vortex-auv packages
- name: Checkout vortex_msgs
uses: actions/checkout@v3
with:
repository: 'vortexntnu/vortex-msgs'
path: './vortex-msgs'
repository: "vortexntnu/vortex-msgs"
path: "./vortex-msgs"
- name: Move vortex_msgs
run: mv ./vortex-msgs ../vortex-msgs
# robot_localization needs to be in the same location as the rest of the vortex-auv packages

# robot_localization needs to be in the same location as the rest of the vortex-auv packages
- name: Checkout robot_localization
uses: actions/checkout@v3
with:
repository: 'vortexntnu/robot_localization'
path: './robot_localization'
repository: "vortexntnu/robot_localization"
path: "./robot_localization"
- name: Move robot_localization
run: mv ./robot_localization ../robot_localization

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: mypy

on: [pull_request]

jobs:
mypy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Install mypy
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
pip3 install mypy
- name: Run mypy type checking
run: |
mypy . --explicit-package-bases
68 changes: 68 additions & 0 deletions .github/workflows/python-format-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Python Format and Lint (isort, black, pylint)

on: [pull_request]

jobs:
isort:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Run isort to sort imports
uses: isort/isort-action@v1

- name: Commit isort changes
uses: EndBug/add-and-commit@v9
with:
author_name: Isort Robot
author_email: [email protected]
message: "Committing isort changes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

black:
runs-on: ubuntu-latest
needs: isort

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."

- name: Commit black-format changes
uses: EndBug/add-and-commit@v9
with:
author_name: Black Robot
author_email: [email protected]
message: "Committing black-format changes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pylint:
runs-on: ubuntu-latest
needs: black
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
31 changes: 31 additions & 0 deletions .github/workflows/yaml-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Yaml Format (prettier)

on: [pull_request]

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Install Prettier
run: |
sudo npm install -g prettier
# Run Prettier to format all YAML files
- name: Run Prettier to format YAML files
run: |
prettier --write "**/*.yaml" "**/*.yml"
# Commit Prettier changes
- name: Commit Prettier changes
uses: EndBug/add-and-commit@v9
with:
author_name: Prettier Robot
author_email: [email protected]
message: "Committing Prettier formatting fixes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 0cd2b87

Please sign in to comment.