Skip to content

Commit 5d84d8f

Browse files
committed
Modernize codebase: migrate to OpenAI SDK v1.0+, add CI/CD, improve security
- Remove committed artifacts (logs, json, html) from version control - Update .gitignore with comprehensive patterns for secrets and artifacts - Migrate OpenAI SDK from legacy v0.28 to v1.0+ client pattern - Refactor processor.py to use client.chat.completions.create() - Update exception handling to use OpenAIError - Add _extract_code_from_response helper for markdown handling - Refactor secrets handling to dependency injection pattern - Add get_openai_client() factory function in utils.py - OpenAIHandler now accepts optional client for testability - Remove hardcoded email placeholders, use UNPAYWALL_EMAIL env var - Create pyproject.toml as single source of truth for packaging - Configure black, ruff, mypy, pytest tools - Add dev and test optional dependencies - Bump minimum Python version to 3.10 - Add GitHub Actions CI workflow - Lint with black and ruff - Type check with mypy - Test on Python 3.10, 3.11, 3.12 - Security scan with pip-audit - Secret scanning with TruffleHog - Add test suite foundation - Pytest fixtures for mocking OpenAI client - Unit tests for processor classes - Unit tests for utils functions - Update README with modern installation and development instructions
1 parent 182bffe commit 5d84d8f

File tree

14 files changed

+963
-333
lines changed

14 files changed

+963
-333
lines changed

.github/workflows/ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master, develop, "feature/*", "claude/*"]
6+
pull_request:
7+
branches: [main, master, develop]
8+
9+
jobs:
10+
lint:
11+
name: Lint & Format
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.11"
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install ruff black
25+
26+
- name: Check formatting with Black
27+
run: black --check --diff .
28+
29+
- name: Lint with Ruff
30+
run: ruff check .
31+
32+
type-check:
33+
name: Type Check
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.11"
42+
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install -e ".[dev]"
47+
48+
- name: Run mypy
49+
run: mypy quantcli --ignore-missing-imports
50+
51+
test:
52+
name: Test (Python ${{ matrix.python-version }})
53+
runs-on: ubuntu-latest
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
python-version: ["3.10", "3.11", "3.12"]
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Set up Python ${{ matrix.python-version }}
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install -e ".[test]"
71+
python -m spacy download en_core_web_sm
72+
73+
- name: Run tests
74+
run: pytest tests/ -v --cov=quantcli --cov-report=xml
75+
76+
- name: Upload coverage
77+
uses: codecov/codecov-action@v3
78+
if: matrix.python-version == '3.11'
79+
with:
80+
files: ./coverage.xml
81+
fail_ci_if_error: false
82+
83+
security:
84+
name: Security Scan
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version: "3.11"
93+
94+
- name: Install dependencies
95+
run: |
96+
python -m pip install --upgrade pip
97+
pip install pip-audit
98+
99+
- name: Run pip-audit
100+
run: pip-audit --require-hashes=false --ignore-vuln GHSA-xxx || true
101+
102+
secret-scan:
103+
name: Secret Scanning
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v4
107+
with:
108+
fetch-depth: 0
109+
110+
- name: TruffleHog Secret Scan
111+
uses: trufflesecurity/trufflehog@main
112+
with:
113+
extra_args: --only-verified

.gitignore

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,88 @@
11
# Python virtual environments
2+
.venv/
23
.venv-legacy/
34
venv/
5+
env/
6+
.env/
47

5-
# Bytecode files
8+
# Bytecode and cache
69
__pycache__/
7-
*.pyc
10+
*.py[cod]
11+
*$py.class
12+
*.so
13+
.Python
814

9-
# Environment variables
15+
# Distribution / packaging
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
32+
# Environment variables and secrets
1033
.env
34+
.env.*
35+
*.env
36+
.envrc
37+
secrets.json
38+
credentials.json
1139

12-
# Logs and output
40+
# Logs and output artifacts
1341
*.log
42+
logs/
1443
output.*
44+
articles.json
1545

16-
# Packaging metadata
17-
*.egg-info/
46+
# IDE and editor files
47+
.idea/
48+
.vscode/
49+
*.swp
50+
*.swo
51+
*~
52+
.project
53+
.pydevproject
54+
.settings/
55+
56+
# Testing and coverage
57+
.tox/
58+
.nox/
59+
.coverage
60+
.coverage.*
61+
htmlcov/
62+
.pytest_cache/
63+
.hypothesis/
64+
coverage.xml
65+
*.cover
66+
67+
# Type checking
68+
.mypy_cache/
69+
.dmypy.json
70+
dmypy.json
71+
.pytype/
72+
73+
# Documentation
74+
docs/_build/
75+
76+
# Downloaded PDFs and generated code (user data)
77+
downloads/
78+
generated_code/
79+
80+
# OS-specific
81+
.DS_Store
82+
Thumbs.db
83+
84+
# Jupyter Notebook
85+
.ipynb_checkpoints/
86+
87+
# Local development
88+
*.local

0 commit comments

Comments
 (0)