Skip to content

Commit ff975d6

Browse files
committed
feat: add CI/CD workflows and pre-commit configuration
- Add GitHub Actions workflows for CI, testing, quality checks, security, and releases - Add pre-commit configuration with code formatting, linting, and security checks - Enable automated dependency updates with Dependabot - Configure Python code quality tools (black, isort, flake8, mypy, bandit)
1 parent 6a2556f commit ff975d6

8 files changed

Lines changed: 1812 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: 2
2+
updates:
3+
# Monitor Python dependencies
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
reviewers:
11+
- "agbcloud/maintainers"
12+
assignees:
13+
- "agbcloud/maintainers"
14+
commit-message:
15+
prefix: "chore"
16+
prefix-development: "chore"
17+
include: "scope"
18+
labels:
19+
- "dependencies"
20+
- "automated"
21+
open-pull-requests-limit: 5
22+
rebase-strategy: "auto"
23+
24+
# Monitor GitHub Actions
25+
- package-ecosystem: "github-actions"
26+
directory: "/"
27+
schedule:
28+
interval: "weekly"
29+
day: "monday"
30+
time: "10:00"
31+
reviewers:
32+
- "agbcloud/maintainers"
33+
commit-message:
34+
prefix: "ci"
35+
include: "scope"
36+
labels:
37+
- "github-actions"
38+
- "automated"

.github/workflows/ci.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
python-version: ["3.10", "3.11", "3.12"]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Cache pip dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install build twine
41+
pip install -e .[dev,test]
42+
43+
- name: Run tests with pytest
44+
run: |
45+
pytest tests/ -v --cov=agb --cov-report=xml --cov-report=term-missing
46+
env:
47+
# Set environment variables if tests require API keys
48+
AGB_API_KEY: ${{ secrets.AGB_API_KEY_TEST }}
49+
50+
- name: Upload coverage reports to Codecov
51+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
52+
uses: codecov/codecov-action@v3
53+
with:
54+
file: ./coverage.xml
55+
flags: unittests
56+
name: codecov-umbrella
57+
58+
- name: Build package
59+
run: python -m build
60+
61+
- name: Check package integrity
62+
run: twine check dist/*
63+
64+
- name: Upload build artifacts
65+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
66+
uses: actions/upload-artifact@v3
67+
with:
68+
name: python-package
69+
path: dist/
70+
retention-days: 7
71+
72+
lint:
73+
name: Code Quality Checks
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Set up Python
80+
uses: actions/setup-python@v4
81+
with:
82+
python-version: "3.11"
83+
84+
- name: Install dependencies
85+
run: |
86+
python -m pip install --upgrade pip
87+
pip install -e .[dev,test]
88+
89+
- name: Run Black
90+
run: black --check --diff .
91+
92+
- name: Run isort
93+
run: isort --check-only --diff .
94+
95+
- name: Run Flake8
96+
run: flake8 .
97+
98+
- name: Run MyPy
99+
run: mypy agb/
100+
continue-on-error: true # MyPy may have some type issues, allow failure for now
101+
102+
security:
103+
name: Security Scan
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Checkout code
107+
uses: actions/checkout@v4
108+
109+
- name: Set up Python
110+
uses: actions/setup-python@v4
111+
with:
112+
python-version: "3.11"
113+
114+
- name: Install dependencies
115+
run: |
116+
python -m pip install --upgrade pip
117+
pip install bandit[toml] safety
118+
119+
- name: Run Bandit security scan
120+
run: bandit -r agb/ -f json -o bandit-report.json
121+
continue-on-error: true
122+
123+
- name: Run Safety dependency scan
124+
run: safety check --json --output safety-report.json
125+
continue-on-error: true
126+
127+
- name: Upload security reports
128+
uses: actions/upload-artifact@v3
129+
with:
130+
name: security-reports
131+
path: |
132+
bandit-report.json
133+
safety-report.json
134+
if: always()
135+
136+
# Only run on main branch when tests pass
137+
integration-test:
138+
name: Integration Tests
139+
runs-on: ubuntu-latest
140+
needs: [test, lint]
141+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
142+
steps:
143+
- name: Checkout code
144+
uses: actions/checkout@v4
145+
146+
- name: Set up Python
147+
uses: actions/setup-python@v4
148+
with:
149+
python-version: "3.11"
150+
151+
- name: Install dependencies
152+
run: |
153+
python -m pip install --upgrade pip
154+
pip install -e .[dev,test]
155+
156+
- name: Run integration tests
157+
run: |
158+
# Run integration tests
159+
pytest tests/integration/ -v --maxfail=5
160+
env:
161+
AGB_API_KEY: ${{ secrets.AGB_API_KEY_TEST }}
162+
continue-on-error: true # Integration tests may fail due to external dependencies

0 commit comments

Comments
 (0)