Skip to content

Fix unit test and code check actions #389

Fix unit test and code check actions

Fix unit test and code check actions #389

name: Static Code Analysis
on:
push:
branches: master
pull_request:
branches: master
jobs:
formatJob:
name: Check Code Format
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install pep8 python3-autopep8 python3-pep8 python-is-python3
- name: Check Code Format
uses: peter-evans/autopep8@v2
with:
args: --max-line-length=120 --ignore=E731 --recursive --in-place .
qualityJob:
name: Check Code Quality
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install python3-pip pep8 python3-autopep8 python3-pep8 python-is-python3 libgeos-dev
sudo pip3 install pylint --upgrade
sudo pip3 install -r requirements.txt
- name: Check Code Quality with Pylint
run: |
pylint --version
static_code_quality_passed=1
pylint --rcfile=.pylintrc --disable=I srunner/scenariomanager
pylint --rcfile=.pylintrc --disable=I srunner/scenarios
pylint --rcfile=.pylintrc --disable=I srunner/tools
pylint --rcfile=.pylintrc --disable=I srunner/scenarioconfigs
pylint --rcfile=.pylintrc --disable=I scenario_runner.py
score=`pylint --rcfile=.pylintrc --disable=I srunner/scenariomanager | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi
score=`pylint --rcfile=.pylintrc --disable=I srunner/scenarios | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi
score=`pylint --rcfile=.pylintrc --disable=I srunner/tools | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi
score=`pylint --rcfile=.pylintrc --disable=I srunner/scenarioconfigs | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi
score=`pylint --rcfile=.pylintrc --disable=I scenario_runner.py | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi
if [ $static_code_quality_passed -eq 0 ]; then echo "Code is not pylint compliant. Please run code_check_and_formatting.sh"; exit 1; fi