Skip to content

Commit 27bf549

Browse files
authored
Create ci.yml
1 parent badcf98 commit 27bf549

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/ci.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y tesseract-ocr tesseract-ocr-eng
28+
29+
- name: Install Python dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -r requirements.txt
33+
34+
- name: Lint with flake8
35+
run: |
36+
# Run flake8 to check code style and quality
37+
flake8 main.py tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
38+
# Run full flake8 check but allow it to fail (for now)
39+
flake8 main.py tests/ --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
40+
41+
- name: Test with unittest
42+
run: |
43+
python -m unittest discover tests/ -v
44+
45+
- name: Test application functionality
46+
run: |
47+
# Create a simple test image with text (using ImageMagick)
48+
sudo apt-get install -y imagemagick
49+
convert -size 300x100 xc:white -font DejaVu-Sans -pointsize 20 -fill black -annotate +10+30 'Test Image' test_image.png
50+
51+
# Test the application
52+
python main.py -i test_image.png > output.txt
53+
54+
# Check if output contains expected text
55+
if grep -q "Test" output.txt; then
56+
echo "✅ Application test passed - OCR working correctly"
57+
else
58+
echo "❌ Application test failed - OCR not working"
59+
cat output.txt
60+
exit 1
61+
fi
62+
63+
code-quality:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Set up Python
69+
uses: actions/setup-python@v4
70+
with:
71+
python-version: '3.11'
72+
73+
- name: Install dependencies
74+
run: |
75+
python -m pip install --upgrade pip
76+
pip install -r requirements.txt
77+
78+
- name: Run flake8 (strict)
79+
run: |
80+
flake8 main.py tests/ --max-line-length=120 --max-complexity=10
81+
82+
- name: Check for security issues with bandit
83+
run: |
84+
pip install bandit
85+
bandit -r . -f json -o bandit-report.json || true
86+
87+
- name: Upload bandit report
88+
uses: actions/upload-artifact@v3
89+
if: always()
90+
with:
91+
name: bandit-security-report
92+
path: bandit-report.json

0 commit comments

Comments
 (0)