Skip to content

Commit

Permalink
Merge pull request #11 from nupat-devops-24/lint-action
Browse files Browse the repository at this point in the history
refactor,ci: lint all python scripts and add descriptive comments in function definitions
  • Loading branch information
tomisile authored Feb 11, 2025
2 parents 3259b6b + 9544d66 commit 20faf4a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint Python scripts

on:
push:
pull_request:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
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')
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Extract Weather Reports Data

on:
schedule:
- cron: "0 0 1 * *"
- cron: "0 0 1 * *" # Runs at 00:00, day 1 of every month
workflow_dispatch:

permissions:
Expand All @@ -13,8 +13,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Run script
run: |
Expand All @@ -29,5 +28,5 @@ jobs:
- name: Commit and push changes
run: |
git add result.log
git commit -m "chore: update weather report log [skip ci]" || echo "No changes to commit"
git commit -m "chore: update weather report log" || echo "No changes to commit"
git push
7 changes: 5 additions & 2 deletions add_pass_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import csv


def increase_score():
def increase_score(): # Written by @donadams & @teemy - modified by @tomisile
"""Increments the scores in a CSV file by a given value."""
# Initialize an empty dictionary to store the data
data_dict = {}

with open('students_results.csv', newline='') as csvfile:
with open('students_results.csv', newline='', encoding="utf-8") as csvfile:
reader = csv.reader(csvfile)

# Skip the first row
Expand All @@ -25,6 +25,9 @@ def increase_score():
print(f"Invalid score value for {name}: {row[1]}")
continue # Skip this row if the score is invalid

# Define a temporary variable new_score to avoid pep8 violation
# Recommendation: update score instead
new_score = 0
# Apply the score increment logic based on conditions
if score < 40:
new_score = score + 20 # If score < 40, add 20
Expand Down

0 comments on commit 20faf4a

Please sign in to comment.