Refactor: homogenize code surrounding VNF converter #170
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | |
# | |
# SPDX-License-Identifier: MPL-2.0 | |
# GitHub Action that uses | |
# isort, black, mypy and pylint to reformat the Python code in an incoming pull request. | |
# clang-format to reformat the C++ code in an incoming pull request. | |
# If all code in the pull request is compliant with Black and clang-format then this Action | |
# does nothing. Otherwise, it will print the files which need to be reformatted and raise an error. | |
name: Check Code Quality | |
on: | |
# run pipeline on push event of main branch | |
push: | |
branches: | |
- main | |
# run pipeline on pull request | |
pull_request: | |
# run pipeline on merge queue | |
merge_group: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check-code-quality: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Upgrade pip | |
run: pip install --upgrade pip | |
- name: Install and run isort | |
run: | | |
pip install isort | |
isort . | |
- name: Install and run black | |
run: | | |
pip install black | |
black . | |
- name: Install and run mypy | |
run: | | |
pip install mypy | |
mkdir -p .mypy_cache | |
mypy . | |
- name: Install and run pylint | |
run: | | |
pip install pylint . | |
pylint power_grid_model_io_native | |
git restore README.md | |
- name: Install and run clang-format | |
run: | | |
sudo apt-get update && sudo apt-get install -y clang-format-15 | |
find . -regex '.*\.\(h\|c\|cpp\|hpp\|cc\|cxx\)' -exec clang-format-15 -style=file -i {} \; | |
- name: If needed raise error | |
run: | | |
if [[ `git status --porcelain --untracked-files=no --ignore-submodules=dirty` ]]; then | |
echo "Formatting not correct! See below the files which need to be reformatted!" | |
git status --porcelain --untracked-files=no --ignore-submodules=dirty | |
exit 1 | |
fi |