Skip to content

Commit

Permalink
fix/59: Github actions added and some issue fixed (#71)
Browse files Browse the repository at this point in the history
Co-authored-by: Padam ghimire <pada.ghimire@f1soft.com>
  • Loading branch information
padam-ghimire and Padam ghimire committed May 9, 2024
1 parent 3d0fb81 commit c46f515
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 13 deletions.
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
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 @@ -101,17 +101,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 @@ -133,14 +133,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

0 comments on commit c46f515

Please sign in to comment.