Skip to content

Commit 90e98f0

Browse files
committed
Add CI workflow for running unit tests and enhance README with badges
- Created a GitHub Actions workflow to run unit tests on push events. - Updated .gitignore to exclude additional generated files. - Enhanced README with badges for Python, NumPy, Pandas, GitHub Actions, and CodeCov. - Added pandas to requirements.txt for data manipulation. - Implemented data loading and validation tests for car dataset.
1 parent 8e4a92f commit 90e98f0

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed

.github/workflows/run-tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '**' # Runs on all branches
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Checkout the repository
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
# Set up Python
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.11' # Specify the Python version
23+
24+
# Install dependencies
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements.txt
29+
30+
# Run tests with coverage
31+
- name: Run tests
32+
run: |
33+
pytest -v --cov=src/problem_solving_questions --cov-report=html --cov-report=term tests/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ venv/
99
.vscode/
1010

1111
logs/
12+
.pytest_cache/
13+
htmlcov/
14+
__pycache__/

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Hack Complex Problems Together
22

3+
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
4+
![Streamlit](https://img.shields.io/badge/Streamlit-%23FE4B4B.svg?style=for-the-badge&logo=streamlit&logoColor=white)
5+
![NumPy](https://img.shields.io/badge/numpy-%23013243.svg?style=for-the-badge&logo=numpy&logoColor=white)
6+
![Pandas](https://img.shields.io/badge/pandas-%23150458.svg?style=for-the-badge&logo=pandas&logoColor=white)
7+
![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white)
8+
![CodeCov](https://img.shields.io/badge/codecov-%23ff0077.svg?style=for-the-badge&logo=codecov&logoColor=white)
9+
10+
311
## To install project dependencies..
412
```
513
pip install -r requirement.txt

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pytest
2+
pandas
23
pytest-cov
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pandas as pd
2+
3+
# Define column names
4+
column_names = ['mpg', 'cylinders', 'displacement', 'horsepower', 'weight', 'acceleration', 'model year', 'origin', 'car name']
5+
6+
# Import the dataset and assign column names
7+
cars_data = pd.read_csv('data/auto-mpg-data.txt', sep='\s+', header=None, names=column_names)
8+
9+
# Display the first few rows of the dataset
10+
print(cars_data.head().to_string())
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pandas as pd
2+
import pytest
3+
4+
# Define the test function
5+
def test_cars_data_loading():
6+
# Define column names
7+
column_names = ['mpg', 'cylinders', 'displacement', 'horsepower', 'weight', 'acceleration', 'model year', 'origin', 'car name']
8+
9+
# Load the dataset
10+
cars_data = pd.read_csv('data/auto-mpg-data.txt', sep='\s+', header=None, names=column_names)
11+
12+
# Assert that the dataset is not empty
13+
assert not cars_data.empty, "The dataset should not be empty."
14+
15+
# Assert that the column names are correctly assigned
16+
assert list(cars_data.columns) == column_names, "Column names do not match the expected names."
17+
18+
# Assert that the dataset has the correct number of columns
19+
assert cars_data.shape[1] == len(column_names), "The dataset should have exactly 9 columns."
20+
21+
# Assert that the dataset has rows
22+
assert cars_data.shape[0] > 0, "The dataset should have at least one row."

0 commit comments

Comments
 (0)