Skip to content

Commit 2384a4e

Browse files
Merge pull request #6 from savitharaghunathan/ci
adding ci
2 parents a0bd4e7 + 1a686f4 commit 2384a4e

25 files changed

Lines changed: 2905 additions & 1796 deletions

.github/workflows/ci.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: CI
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+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest, macos-latest]
19+
python-version: ["3.12"]
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v3
32+
with:
33+
version: "latest"
34+
35+
- name: Cache dependencies
36+
uses: actions/cache@v4
37+
with:
38+
path: |
39+
~/.cache/uv
40+
.venv
41+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-uv-
44+
45+
- name: Install dependencies
46+
run: uv sync --dev --all-extras
47+
48+
- name: Run tests
49+
run: make test-ci
50+
51+
52+
lint:
53+
name: Lint and Format Check
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Python 3.12
60+
uses: actions/setup-python@v4
61+
with:
62+
python-version: "3.12"
63+
64+
- name: Install uv
65+
uses: astral-sh/setup-uv@v3
66+
with:
67+
version: "latest"
68+
69+
- name: Cache dependencies
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
~/.cache/uv
74+
.venv
75+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
76+
restore-keys: |
77+
${{ runner.os }}-uv-
78+
79+
- name: Install dependencies
80+
run: uv sync --dev --all-extras
81+
82+
- name: Run linting
83+
run: make lint
84+
85+
security:
86+
name: Security Check
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout code
90+
uses: actions/checkout@v4
91+
92+
- name: Set up Python 3.12
93+
uses: actions/setup-python@v4
94+
with:
95+
python-version: "3.12"
96+
97+
- name: Install uv
98+
uses: astral-sh/setup-uv@v3
99+
with:
100+
version: "latest"
101+
102+
- name: Cache dependencies
103+
uses: actions/cache@v4
104+
with:
105+
path: |
106+
~/.cache/uv
107+
.venv
108+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
109+
restore-keys: |
110+
${{ runner.os }}-uv-
111+
112+
- name: Install dependencies
113+
run: uv sync --dev --all-extras
114+
115+
- name: Run security checks
116+
run: make security
117+
118+
build:
119+
name: Build Package
120+
runs-on: ubuntu-latest
121+
needs: [test, lint, security]
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v4
125+
126+
- name: Set up Python 3.12
127+
uses: actions/setup-python@v4
128+
with:
129+
python-version: "3.12"
130+
131+
- name: Install uv
132+
uses: astral-sh/setup-uv@v3
133+
with:
134+
version: "latest"
135+
136+
- name: Cache dependencies
137+
uses: actions/cache@v4
138+
with:
139+
path: |
140+
~/.cache/uv
141+
.venv
142+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
143+
restore-keys: |
144+
${{ runner.os }}-uv-
145+
146+
- name: Install dependencies
147+
run: uv sync --dev --all-extras
148+
149+
- name: Build package
150+
run: make build
151+
152+
- name: Check package
153+
run: |
154+
uv run python -m pip install dist/*.whl
155+
uv run python -c "import geneval; print('Package imports successfully')"

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python 3.12
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
26+
with:
27+
version: "latest"
28+
29+
- name: Set up cache
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/.cache/uv
34+
.venv
35+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-uv-
38+
39+
- name: Install dependencies
40+
run: |
41+
uv sync --all-extras
42+
43+
- name: Run tests
44+
run: |
45+
uv run pytest tests/ -v
46+
47+
- name: Build package
48+
run: |
49+
uv build
50+
51+
- name: Create GitHub Release
52+
uses: ncipollo/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
artifacts: "dist/*.whl"
57+
generateReleaseNotes: true
58+
makeLatest: "legacy"

.gitignore

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,12 @@ pip-log.txt
3737
pip-delete-this-directory.txt
3838

3939
# Unit test / coverage reports
40-
htmlcov/
4140
.tox/
4241
.nox/
43-
.coverage
4442
.coverage.*
4543
.cache
4644
nosetests.xml
47-
coverage.xml
48-
*.cover
49-
*.py,cover
5045
.hypothesis/
51-
.pytest_cache/
5246
cover/
5347

5448
# Translations
@@ -143,6 +137,15 @@ venv.bak/
143137
.dmypy.json
144138
dmypy.json
145139

140+
# Ruff
141+
.ruff_cache/
142+
143+
# Pre-commit
144+
.pre-commit-config.yaml.bak
145+
146+
# uv
147+
.uv/
148+
146149
# Pyre type checker
147150
.pyre/
148151

@@ -175,10 +178,6 @@ Desktop.ini
175178
# Linux
176179
*~
177180

178-
# Temporary files
179-
*.tmp
180-
*.temp
181-
182181
# IDE files
183182
.idea/
184183
*.swp
@@ -206,10 +205,30 @@ models/
206205
config.ini
207206
secrets.json
208207
.env.local
209-
.env.production
208+
.env.production
210209

211210
# local test files
212211
tests/test_data.yaml
213212
tests/test_data_clean.yaml
214213

215-
.deepeval/
214+
# DeepEval
215+
.deepeval/
216+
217+
# Security scan results
218+
safety-report.json
219+
220+
# Temporary files
221+
*.tmp
222+
*.temp
223+
*.bak
224+
*.swp
225+
*.swo
226+
227+
# OS generated files
228+
.DS_Store
229+
.DS_Store?
230+
._*
231+
.Spotlight-V100
232+
.Trashes
233+
ehthumbs.db
234+
Thumbs.db

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: debug-statements
11+
- id: check-docstring-first
12+
13+
- repo: https://github.com/psf/black
14+
rev: 24.1.1
15+
hooks:
16+
- id: black
17+
language_version: python3.12
18+
19+
- repo: https://github.com/pycqa/isort
20+
rev: 5.13.2
21+
hooks:
22+
- id: isort
23+
args: ["--profile", "black"]
24+
25+
- repo: https://github.com/astral-sh/ruff-pre-commit
26+
rev: v0.1.6
27+
hooks:
28+
- id: ruff
29+
args: [--fix, --exit-non-zero-on-fix]
30+
- id: ruff-format

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.PHONY: help install dev pre-commit pre-push test test-ci lint format build security clean
2+
3+
help: ## Show this help message
4+
@echo 'Usage: make [target]'
5+
@echo ''
6+
@echo 'Targets:'
7+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
8+
9+
install: ## Install the package
10+
uv sync --dev --all-extras
11+
12+
dev: ## Install pre-commit hooks
13+
uv run pre-commit install
14+
15+
pre-commit: ## Run pre-commit on all files
16+
uv run pre-commit run --all-files
17+
18+
pre-push: ## Run clean, format, lint and test before pushing
19+
$(MAKE) clean
20+
$(MAKE) format
21+
$(MAKE) lint
22+
$(MAKE) test-ci
23+
24+
test: ## Run tests with coverage (for local development)
25+
uv run pytest tests/ -v --cov=geneval --cov-report=term-missing --cov-report=xml --cov-report=html
26+
27+
test-ci: ## Run tests without coverage (for CI)
28+
uv run pytest tests/ -v
29+
30+
lint: ## Run linters
31+
uv run black --check --diff .
32+
uv run isort --check-only --diff .
33+
uv run ruff check geneval/ tests/
34+
35+
36+
format: ## Format code
37+
uv run black .
38+
uv run isort .
39+
uv run ruff check --fix geneval/ tests/
40+
41+
build: ## Build the package
42+
uv build
43+
44+
security: ## Run security checks
45+
@echo "Running security checks..."
46+
@echo "1. Checking for known vulnerabilities with pip-audit..."
47+
uv run pip-audit --desc --format=json --output=security-report.json || true
48+
@echo "2. Checking for outdated packages..."
49+
uv run pip list --outdated || true
50+
@echo "3. Running bandit security linter..."
51+
uv run bandit -r geneval/ -f json -o bandit-report.json || true
52+
@echo "✅ Security checks completed!"
53+
54+
clean: ## Clean up generated files
55+
rm -rf htmlcov/
56+
rm -rf .coverage
57+
rm -rf .pytest_cache/
58+
rm -rf build/
59+
rm -rf dist/
60+
rm -rf *.egg-info/

0 commit comments

Comments
 (0)