Skip to content

Commit 12b8f2a

Browse files
authored
Merge pull request #1 from stride-nyc/initial-buildout
Initial buildout
2 parents cd4a301 + 0297376 commit 12b8f2a

14 files changed

+2236
-2
lines changed

.bandit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Bandit Security Scanner Configuration
2+
# https://bandit.readthedocs.io/en/latest/config.html
3+
4+
[bandit]
5+
# Exclude directories
6+
exclude_dirs = ['.venv', '.pytest_cache', '__pycache__']
7+
8+
# Skip B101 (assert_used) check for test files
9+
# Asserts are acceptable and expected in test files
10+
skips = B101
11+
12+
# Only scan specific file patterns
13+
# (using exclude_dirs above handles most cases)

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# LangSmith Data Export - Environment Variables
2+
# Copy this file to .env and fill in your actual values
3+
4+
# LangSmith API Key (required)
5+
# Get your API key from: https://smith.langchain.com/settings
6+
LANGSMITH_API_KEY=lsv2_pt_your_api_key_here
7+
8+
# LangSmith API URL (optional, uses default if not specified)
9+
LANGSMITH_API_URL=https://api.smith.langchain.com
10+
11+
# Default project name (optional)
12+
LANGSMITH_PROJECT=your-project-name
13+
14+
# Default trace limit (optional)
15+
LANGSMITH_LIMIT=150

.github/WORKFLOWS.md

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# GitHub Actions CI/CD
2+
3+
This directory contains GitHub Actions workflows for continuous integration and code quality checks.
4+
5+
## Workflows
6+
7+
### 🧪 test.yml - Test Suite
8+
**Trigger:** Push to any branch (Python changes only), PRs to main (Python changes only)
9+
10+
**What it does:**
11+
- Matrix testing on Python 3.11 and 3.12
12+
- Runs pytest with coverage
13+
- Uploads coverage to Codecov (Python 3.11 only)
14+
15+
**Required:** ✅ Must pass for PR merge
16+
17+
---
18+
19+
### 🎨 lint.yml - Code Quality
20+
**Trigger:** Push to any branch (Python changes only), PRs to main (Python changes only)
21+
22+
**What it does:**
23+
- **Ruff**: Fast Python linter (checks imports, unused variables, etc.)
24+
- **Black**: Code formatting verification (100 char line length)
25+
- **mypy**: Static type checking
26+
27+
**Required:** ⚠️ Non-blocking but should be addressed
28+
29+
**Fix issues:**
30+
```bash
31+
# Auto-fix formatting
32+
black .
33+
34+
# Auto-fix some linting issues
35+
ruff check --fix .
36+
37+
# Check types
38+
mypy . --ignore-missing-imports
39+
```
40+
41+
---
42+
43+
### 🔒 security.yml - Security Scanning
44+
**Trigger:** Push to main (Python changes only), PRs (Python changes only), Weekly (Sundays)
45+
46+
**What it does:**
47+
- **Bandit**: Scans for common security issues
48+
- **Safety**: Checks for vulnerable dependencies
49+
- Uploads security reports as artifacts
50+
51+
**Required:** ⚠️ Review findings, critical issues must be fixed
52+
53+
---
54+
55+
### 📊 pr-metrics.yml - PR Analysis
56+
**Trigger:** PR opened/updated
57+
58+
**What it does:**
59+
- Analyzes PR size (small/medium/large/extra-large) for Python code
60+
- Calculates test-to-production code ratio
61+
- Measures commit quality:
62+
- Large commits (>100 lines): Target <20%
63+
- Sprawling commits (>5 files): Target <10%
64+
- Posts analysis comment on PR
65+
66+
**Based on:** [PDCA Framework](https://github.com/kenjudy/human-ai-collaboration-process)
67+
68+
---
69+
70+
## Configuration Files
71+
72+
Configuration can be added to `pyproject.toml` for:
73+
- **Black** (formatter)
74+
- **Ruff** (linter)
75+
- **mypy** (type checker)
76+
- **pytest** (test runner)
77+
- **coverage** (coverage reporting)
78+
- **Bandit** (security scanner)
79+
80+
---
81+
82+
## Local Development
83+
84+
### Run all quality checks locally:
85+
86+
```bash
87+
# Activate virtual environment
88+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
89+
90+
# Run tests with coverage
91+
pytest . --cov=. --cov-report=term-missing
92+
93+
# Check formatting
94+
black --check .
95+
96+
# Auto-format code
97+
black .
98+
99+
# Lint code
100+
ruff check .
101+
102+
# Auto-fix linting issues
103+
ruff check --fix .
104+
105+
# Type check
106+
mypy . --ignore-missing-imports
107+
108+
# Security scan
109+
bandit -r . --exclude ./.venv,./.pytest_cache
110+
safety check
111+
```
112+
113+
### Pre-commit checks:
114+
115+
Before committing, run:
116+
```bash
117+
black . && ruff check --fix . && pytest .
118+
```
119+
120+
---
121+
122+
## Quality Targets
123+
124+
### Test Coverage
125+
- **Target:** >80%
126+
- **Location:** All Python files
127+
128+
### Commit Quality
129+
- **Large commits:** <20% (>100 production lines)
130+
- **Sprawling commits:** <10% (>5 files changed)
131+
- **Test ratio:** 0.5-2.0 (test lines : production lines)
132+
133+
### PR Size
134+
- **Small:** <100 production lines
135+
- **Medium:** 100-200 lines
136+
- **Large:** 200-500 lines (harder to review)
137+
- **Extra-large:** >500 lines (should be split)
138+
139+
### Code Quality
140+
- **Complexity:** Max 10 (ruff C901)
141+
- **Line length:** 100 characters (black)
142+
- **Import organization:** Automatic (ruff I)
143+
144+
---
145+
146+
## Troubleshooting
147+
148+
### CI failures
149+
150+
**Tests failing:**
151+
```bash
152+
# Run locally with same environment
153+
LANGSMITH_API_KEY=test-api-key pytest . -v
154+
```
155+
156+
**Coverage too low:**
157+
- Add tests for untested code
158+
- Check coverage report: `pytest --cov=. --cov-report=html`
159+
- Open `htmlcov/index.html` in browser
160+
161+
**Linting failures:**
162+
```bash
163+
# See what needs fixing
164+
ruff check .
165+
166+
# Auto-fix
167+
ruff check --fix .
168+
black .
169+
```
170+
171+
**Security issues:**
172+
```bash
173+
# See details
174+
bandit -r . --exclude ./.venv,./.pytest_cache -f screen
175+
safety check
176+
177+
# Review and fix critical issues
178+
# Update dependencies if needed
179+
```
180+
181+
---
182+
183+
## Badges
184+
185+
Add to README.md:
186+
187+
```markdown
188+
![Tests](https://github.com/YOUR_USERNAME/export-langsmith-data/workflows/Tests/badge.svg)
189+
![Lint](https://github.com/YOUR_USERNAME/export-langsmith-data/workflows/Lint/badge.svg)
190+
![Security](https://github.com/YOUR_USERNAME/export-langsmith-data/workflows/Security/badge.svg)
191+
[![codecov](https://codecov.io/gh/YOUR_USERNAME/export-langsmith-data/branch/main/graph/badge.svg)](https://codecov.io/gh/YOUR_USERNAME/export-langsmith-data)
192+
```
193+
194+
---
195+
196+
## References
197+
198+
- [PDCA Framework for AI-Assisted Code Generation](https://github.com/kenjudy/human-ai-collaboration-process)
199+
- [Ruff Documentation](https://docs.astral.sh/ruff/)
200+
- [Black Documentation](https://black.readthedocs.io/)
201+
- [pytest Documentation](https://docs.pytest.org/)

.github/workflows/lint.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
paths:
7+
- '**.py'
8+
- 'requirements.txt'
9+
- '.github/workflows/lint.yml'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- '**.py'
14+
- 'requirements.txt'
15+
- '.github/workflows/lint.yml'
16+
17+
jobs:
18+
lint:
19+
name: Code Quality Checks
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Python 3.11
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.11"
29+
cache: 'pip'
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install ruff mypy black
35+
pip install -r requirements.txt
36+
37+
- name: Run Ruff (linting)
38+
run: |
39+
ruff check . --output-format=github
40+
continue-on-error: true
41+
42+
- name: Run Black (formatting check)
43+
run: |
44+
black --check .
45+
continue-on-error: true
46+
47+
- name: Run mypy (type checking)
48+
run: |
49+
mypy . --ignore-missing-imports --no-strict-optional
50+
continue-on-error: true
51+
52+
- name: Summary
53+
if: always()
54+
run: |
55+
echo "✅ Lint checks complete. Review warnings above."
56+
echo "Note: Failures are non-blocking but should be addressed."

0 commit comments

Comments
 (0)