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

fixes #59: Github actions added and some issue fixed #71

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Code Coverage"

on: [push, pull_request]

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run pytest with coverage
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we see the results after upload, do we need to add any thing to readme.md ?

with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
23 changes: 23 additions & 0 deletions .github/workflows/code_security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Code Security"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 5 * * 1'

jobs:
CodeQL:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
19 changes: 19 additions & 0 deletions .github/workflows/code_styling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Code Styling"

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install ruff
- name: Run ruff linter
run: |
ruff check .
26 changes: 13 additions & 13 deletions school_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ def read_tsv(file_path: str) -> List[Dict[str, str]]:
reader = csv.DictReader(file, delimiter='\t')
for row in reader:
data.append(dict(row))
except FileNotFoundError:
logger.error(f"File '{file_path}' not found.")
except FileNotFoundError as e:
logger.error(f"File '{file_path} : {e}' not found.")
sys.exit(1)
except PermissionError:
logger.error(f"Permission denied while accessing file '{file_path}'.")
except PermissionError as e:
logger.error(f"Permission denied while accessing file '{file_path}' : {e}.")
sys.exit(1)
except IOError:
logger.error(f"Error opening or reading file: {file_path}")
except IOError as e:
logger.error(f"Error opening or reading file: '{file_path}' : {e}")
sys.exit(1)
except Exception as e:
logger.error(f"An unexpected error occurred while reading file '{file_path}': {e}")
logger.error(f"An unexpected error occurred while reading file '{file_path}' : {e}")
sys.exit(1)
return data

Expand All @@ -131,14 +131,14 @@ def read_prefs(file_path: str) -> Dict[str, Dict[str, int]]:
prefs[row['scode']][row['cscode']] = int(row['pref'])
else:
prefs[row['scode']] = {row['cscode']: int(row['pref'])}
except FileNotFoundError:
logger.error(f"File '{file_path}' not found.")
except FileNotFoundError as e:
logger.error(f"File '{file_path} :{e}' not found.")
sys.exit(1)
except PermissionError:
logger.error(f"Permission denied while accessing file '{file_path}'.")
except PermissionError as e:
logger.error(f"Permission denied while accessing file '{file_path}:{e}'.")
sys.exit(1)
except IOError:
logger.error(f"Error opening or reading file: {file_path}")
except IOError as e:
logger.error(f"Error opening or reading file: {file_path} :{e}")
sys.exit(1)
except Exception as e:
logger.error(f"An unexpected error occurred while reading file '{file_path}': {e}")
Expand Down