-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (152 loc) · 4.62 KB
/
ci.yml
File metadata and controls
183 lines (152 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Continuous Integration
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
# Job 1: Code Quality Checks
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-ci.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-ci.txt
- name: Check code formatting with Black
run: |
black --check --diff app/ src/ examples/ scripts/ tests/ || echo "Black formatting issues found"
continue-on-error: true
- name: Lint with Ruff
run: |
ruff check app/ src/ examples/ scripts/ tests/ --output-format=github || echo "Ruff linting issues found"
continue-on-error: true
- name: Check import sorting with isort
run: |
isort --check-only --diff app/ src/ examples/ scripts/ tests/ || echo "Import sorting issues found"
continue-on-error: true
- name: Type checking with MyPy
run: |
mypy app/ src/ --ignore-missing-imports || echo "Type checking issues found"
continue-on-error: true
- name: Check for security issues with Semgrep
run: |
pip install semgrep
semgrep --config=auto app/ src/ || echo "Security scan completed with findings"
continue-on-error: true
# Job 2: Security Scan
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-ci.txt
- name: Run Bandit security scan
run: |
bandit -r app/ src/ -f json -o bandit-report.json || true
continue-on-error: true
- name: Upload Bandit report
uses: actions/upload-artifact@v4
if: always()
with:
name: bandit-report
path: bandit-report.json
# Job 3: Tests
test:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements-ci.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-ci.txt
- name: Create test environment file
run: |
echo "ANTHROPIC_API_KEY=test_key" > .env
echo "OPENAI_API_KEY=test_key" >> .env
echo "ENVIRONMENT=test" >> .env
- name: Run basic tests
run: |
python -m pytest tests/ -v || echo "Tests completed with issues"
env:
PYTHONPATH: ${{ github.workspace }}
continue-on-error: true
- name: Test basic imports
run: |
python -c "
try:
import sys
sys.path.append('.')
print('Python path:', sys.path)
print('Testing basic imports...')
import app
print('✅ app module imported')
except Exception as e:
print(f'Import test result: {e}')
"
continue-on-error: true
# Job 4: Build Test
build-test:
name: Build Test
runs-on: ubuntu-latest
needs: [code-quality, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build
continue-on-error: true
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: dist-packages
path: dist/