Skip to content

Commit c46f515

Browse files
padam-ghimirePadam ghimire
andauthored
fix/59: Github actions added and some issue fixed (#71)
Co-authored-by: Padam ghimire <[email protected]>
1 parent 3d0fb81 commit c46f515

File tree

4 files changed

+81
-13
lines changed

4 files changed

+81
-13
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Code Coverage"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
coverage:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Set up Python
11+
uses: actions/setup-python@v5
12+
with:
13+
python-version: '3.11'
14+
- name: Install dependencies
15+
run: |
16+
pip install -r requirements.txt
17+
- name: Run pytest with coverage
18+
run: |
19+
pytest --cov=./ --cov-report=xml
20+
- name: Upload coverage to Codecov
21+
uses: codecov/codecov-action@v1
22+
with:
23+
file: ./coverage.xml
24+
flags: unittests
25+
name: codecov-umbrella
26+
fail_ci_if_error: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Code Security"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 5 * * 1'
10+
11+
jobs:
12+
CodeQL:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Initialize CodeQL
19+
uses: github/codeql-action/init@v2
20+
with:
21+
languages: python
22+
- name: Perform CodeQL Analysis
23+
uses: github/codeql-action/analyze@v2

.github/workflows/code_styling.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "Code Styling"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Set up Python
11+
uses: actions/setup-python@v5
12+
with:
13+
python-version: '3.11'
14+
- name: Install dependencies
15+
run: |
16+
pip install ruff
17+
- name: Run ruff linter
18+
run: |
19+
ruff check .

school_center.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ def read_tsv(file_path: str) -> List[Dict[str, str]]:
101101
reader = csv.DictReader(file, delimiter='\t')
102102
for row in reader:
103103
data.append(dict(row))
104-
except FileNotFoundError:
105-
logger.error(f"File '{file_path}' not found.")
104+
except FileNotFoundError as e:
105+
logger.error(f"File '{file_path} : {e}' not found.")
106106
sys.exit(1)
107-
except PermissionError:
108-
logger.error(f"Permission denied while accessing file '{file_path}'.")
107+
except PermissionError as e:
108+
logger.error(f"Permission denied while accessing file '{file_path}' : {e}.")
109109
sys.exit(1)
110-
except IOError:
111-
logger.error(f"Error opening or reading file: {file_path}")
110+
except IOError as e:
111+
logger.error(f"Error opening or reading file: '{file_path}' : {e}")
112112
sys.exit(1)
113113
except Exception as e:
114-
logger.error(f"An unexpected error occurred while reading file '{file_path}': {e}")
114+
logger.error(f"An unexpected error occurred while reading file '{file_path}' : {e}")
115115
sys.exit(1)
116116
return data
117117

@@ -133,14 +133,14 @@ def read_prefs(file_path: str) -> Dict[str, Dict[str, int]]:
133133
prefs[row['scode']][row['cscode']] = int(row['pref'])
134134
else:
135135
prefs[row['scode']] = {row['cscode']: int(row['pref'])}
136-
except FileNotFoundError:
137-
logger.error(f"File '{file_path}' not found.")
136+
except FileNotFoundError as e:
137+
logger.error(f"File '{file_path} :{e}' not found.")
138138
sys.exit(1)
139-
except PermissionError:
140-
logger.error(f"Permission denied while accessing file '{file_path}'.")
139+
except PermissionError as e:
140+
logger.error(f"Permission denied while accessing file '{file_path}:{e}'.")
141141
sys.exit(1)
142-
except IOError:
143-
logger.error(f"Error opening or reading file: {file_path}")
142+
except IOError as e:
143+
logger.error(f"Error opening or reading file: {file_path} :{e}")
144144
sys.exit(1)
145145
except Exception as e:
146146
logger.error(f"An unexpected error occurred while reading file '{file_path}': {e}")

0 commit comments

Comments
 (0)