Skip to content

Commit d797398

Browse files
add test workflow
1 parent 3e03fa2 commit d797398

2 files changed

Lines changed: 59 additions & 21 deletions

File tree

.github/workflows/tests.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python 3.12
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
29+
- name: Lint with flake8
30+
run: |
31+
pip install flake8
32+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=.venv,yolov5,data
33+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=.venv,yolov5,data
34+
35+
- name: Run tests
36+
run: |
37+
python -m pytest tests/ -v
38+

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DefectNet [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![CI/CD](https://github.com/stuartasiimwe7/DefectNet/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/stuartasiimwe7/DefectNet/actions/workflows/ci-cd.yml)
1+
# DefectNet [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Tests](https://github.com/stuartasiimwe7/DefectNet/actions/workflows/tests.yml/badge.svg)](https://github.com/stuartasiimwe7/DefectNet/actions/workflows/tests.yml) [![CI/CD](https://github.com/stuartasiimwe7/DefectNet/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/stuartasiimwe7/DefectNet/actions/workflows/ci-cd.yml)
22

33
A RestFul API for automated detecting of defects in Printed Circuit Boards (PCBs) using YOLOv5 deep learning models, built with FastAPI.
44

@@ -40,25 +40,25 @@ DefectNet provides a robust, scalable REST API service that uses computer vision
4040

4141
```
4242
DefectNet/
43-
├── app.py # Main FastAPI application
44-
├── config.py # Configuration management
45-
├── requirements.txt # Python dependencies
46-
├── Dockerfile # Docker configuration
43+
├── app.py
44+
├── config.py
45+
├── requirements.txt
46+
├── Dockerfile
4747
├── src/
4848
│ ├── models/
49-
│ │ └── yolo_model.py # YOLOv5 model wrapper
49+
│ │ └── yolo_model.py
5050
│ ├── utils/
51-
│ │ ├── image_processor.py # Image preprocessing
52-
│ │ └── response_formatter.py # Response formatting
51+
│ │ ├── image_processor.py
52+
│ │ └── response_formatter.py
5353
│ └── services/
54-
│ └── defect_detection_service.py # Business logic
54+
│ └── defect_detection_service.py
5555
├── tests/
56-
│ ├── test_api.py # API endpoint tests
57-
│ ├── test_config.py # Configuration tests
58-
│ ├── test_image_processor.py # Image processing tests
59-
│ ├── test_response_formatter.py # Response formatting tests
60-
│ └── test_integration.py # Integration tests
61-
└── data/ # Dataset directory
56+
│ ├── test_api.py
57+
│ ├── test_config.py
58+
│ ├── test_image_processor.py
59+
│ ├── test_response_formatter.py
60+
│ └── test_integration.py
61+
└── data/
6262
```
6363

6464
## Performance Metrics
@@ -101,7 +101,7 @@ There is comprehensive test coverage across all components with 32 passing tests
101101

102102
### Want to replicate?
103103

104-
```bash
104+
```bash
105105
# Clone and navigate
106106
git clone https://github.com/stuartasiimwe7/DefectNet
107107
cd DefectNet
@@ -111,25 +111,25 @@ python -m venv .venv
111111
source .venv/bin/activate # Windows: .venv\Scripts\activate
112112

113113
# Install dependencies
114-
pip install -r requirements.txt
114+
pip install -r requirements.txt
115115

116116
# Verify with tests
117117
python -m pytest tests/ -v
118118

119119
# Start server
120120
uvicorn app:app --reload --host 0.0.0.0 --port 8000
121-
```
121+
```
122122

123123
### Docker Setup
124124

125125
**Option 1: Pull from GitHub Container Registry**
126-
```bash
126+
```bash
127127
docker pull ghcr.io/stuartasiimwe7/defectnet:latest
128128
docker run -p 8000:8000 ghcr.io/stuartasiimwe7/defectnet:latest
129-
```
129+
```
130130

131131
**Option 2: Build locally**
132-
```bash
132+
```bash
133133
docker build -t defectnet .
134134
docker run -p 8000:8000 defectnet
135135
```

0 commit comments

Comments
 (0)