Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pylint-related GitHub Action as automated workflow #29

Merged
merged 10 commits into from
Jan 19, 2023
Merged
26 changes: 26 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- 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
pip install behave==1.2.6
pip install pygame==2.1.2
pip install PyYAML
- name: pylint analysis whilst disabling no-name-in-module and no-member to avoid false positives
run: |
pylint $(git ls-files '*.py') --disable=E0611,E1101
2 changes: 1 addition & 1 deletion checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pip3 install bandit
bandit --ini .bandit -r > bandit.txt

# run pylint
pylint --extension-pkg-whitelist=pygame rc_car/*.py features/steps/*.py > pylint.txt
pylint --extension-pkg-whitelist=pygame rc_car/*.py features/steps/*.py --disable=E0611,E1101 > pylint.txt
66 changes: 33 additions & 33 deletions features/steps/steps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Cucumber steps"""
from behave import given,when,then # pylint: disable=no-name-in-module
from behave import given, when, then # pylint: disable=no-name-in-module

from pygame.math import Vector2
from pygame import K_DOWN, K_LEFT, K_RIGHT, K_SPACE, K_UP, K_h, K_c
Expand All @@ -21,20 +21,20 @@ def the_race_car_is_out_of_battery(context):


@given('the parental controls "{text}" previously been configured')
def the_parental_controls_previously_been_configured(context, text):
"""TODO"""
def the_parental_controls_previously_been_configured():
"""TODO, considering 'context' and 'text' as input args"""
# have not
# have


@given('the user has validated parental control credentials')
def the_user_has_validated_parental_control_credentials(context):
"""TODO"""
def the_user_has_validated_parental_control_credentials():
"""TODO, considering 'context' as input arg"""


@given('the server is online')
def the_server_is_online(context):
"""TODO"""
def the_server_is_online():
"""TODO, considering 'context' as input arg"""


@when('the user pushes a direction')
Expand All @@ -43,8 +43,8 @@ def the_user_pushes_a_direction(context):
push_button(context, K_UP)

@when('the user selects a LED colour scheme')
def the_user_selects_a_led_colour_scheme(context):
"""TODO"""
def the_user_selects_a_led_colour_scheme():
"""TODO, considering 'context' as input arg"""


@when('the user pushes the "{text}" button')
Expand All @@ -57,8 +57,7 @@ def the_user_pushes_the_button(context, text):
if text == 'horn':
push_button(context, K_h)
else:
#TODO
pass
raise NotImplementedError


@when('the user tries to connect the remote')
Expand All @@ -67,30 +66,30 @@ def the_user_tries_to_connect_the_remote(context):
push_button(context, K_UP)

@when('inserts the correct password')
def inserts_the_correct_password(context):
"""TODO"""
def inserts_the_correct_password():
"""TODO, considering 'context' as input arg"""


@when('"{text}" is selected')
def option_is_selected(context, text):
"""TODO"""
def option_is_selected():
"""TODO, considering 'context' and 'text' as input args"""
# maximum speed


@when('a picture is uploaded')
def a_picture_is_uploaded(context):
"""TODO"""
def a_picture_is_uploaded():
"""TODO, considering 'context' as input arg"""
# maximum speed


@when('the app is online')
def the_app_is_online(context):
"""TODO"""
def the_app_is_online():
"""TODO, considering 'context' as input arg"""


@then('the user is prompted to set "{text}"')
def the_user_is_prompted_to_set_option(context, text):
"""TODO"""
def the_user_is_prompted_to_set_option():
"""TODO, considering 'context' and 'text' as input args"""
# driver’s appearance
# a password
# the maximum speed
Expand All @@ -113,25 +112,25 @@ def the_car_sounds_the_horn(context):
== AudioEffect.HORN.value.path

@then('the car LEDs change colour to the selected scheme')
def the_car_leds_change_colour_to_the_selected_scheme(context):
"""TODO"""
def the_car_leds_change_colour_to_the_selected_scheme():
"""TODO, considering 'context' as input arg"""


@then('the {text} is updated in the app')
def the_option_is_updated_in_the_app(context, text):
"""TODO"""
def the_option_is_updated_in_the_app():
"""TODO, considering 'context' and 'text' as input args"""
# driver's appearance
# colour scheme


@then('the appearance is updated on the race car')
def the_appearance_is_updated_on_the_race_car(context):
"""TODO"""
def the_appearance_is_updated_on_the_race_car():
"""TODO, considering 'context' as input arg"""


@then('the app displays the estimated range left in the battery')
def the_app_displays_the_estimated_range_left_in_the_battery(context):
"""TODO"""
def the_app_displays_the_estimated_range_left_in_the_battery():
"""TODO, considering 'context' as input arg"""


@then('the remote suggests that the race care is out of range or the battery is empty')
Expand All @@ -143,8 +142,8 @@ def the_remote_suggests_that_the_race_care_is_out_of_range_or_the_battery_is_emp


@then('the server is notified')
def the_server_is_notified(context):
"""TODO"""
def the_server_is_notified():
"""TODO, considering 'context' as input arg"""


def init(context, battery_is_full:bool):
Expand All @@ -153,7 +152,8 @@ def audio_handler(effect):
context.audio_handler_calls.append(effect)
def notifications(message):
context.notifications.append(message)
def check_walls_handler(position:Vector2):
def check_walls_handler():
"""TODO, considering 'position' (Vector2) as input arg"""
return True
context.pressed = {}
context.pressed[K_RIGHT] = False
Expand All @@ -165,7 +165,7 @@ def check_walls_handler(position:Vector2):
context.pressed[K_c] = False
context.audio_handler_calls = []
context.notifications = []
context.car = Car(Vector2(0,0), audio_handler, check_walls_handler)
context.car = Car(Vector2(0, 0), audio_handler, check_walls_handler)
if not battery_is_full:
context.car.battery.consume(100)
context.remote = Remote(notifications)
Expand Down
3 changes: 1 addition & 2 deletions rc_car/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def play_audio(self, audio: AudioEffect):
log.info('Playing sound %s', audio.value.path)

def notify(self, message: str):
"""prints a notification"""
# TODO: add some text in the screen
"""prints a notification. To add some text in the screen"""
log.info(message)

def check_walls(self, next_position):
Expand Down