-
Notifications
You must be signed in to change notification settings - Fork 0
238 lines (202 loc) · 7.41 KB
/
Copy pathci-cd.yml
File metadata and controls
238 lines (202 loc) · 7.41 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: 🚀 Instructify CI/CD Pipeline
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
env:
NODE_VERSION: '18.x'
PYTHON_VERSION: '3.11'
jobs:
# 🔍 Backend Linting Job
backend-lint:
name: 🐍 Backend Linting
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: 📦 Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "backend/uv.lock"
- name: 🔧 Install Backend Dependencies
working-directory: ./backend
run: |
uv sync
- name: 🎨 Run Black (Code Formatter)
working-directory: ./backend
run: |
uv run black --check --diff app/
continue-on-error: true
- name: 🔍 Run Flake8 (Linting)
working-directory: ./backend
run: |
uv run flake8 app/ --max-line-length=88 --extend-ignore=E203,W503
continue-on-error: true
- name: 🏷️ Run mypy (Type Checking)
working-directory: ./backend
run: |
uv run mypy app/ --ignore-missing-imports
continue-on-error: true
- name: 📊 Run isort (Import Sorting)
working-directory: ./backend
run: |
uv run isort --check-only --diff app/
continue-on-error: true
# 🌐 Frontend Build & Test Job
frontend-build:
name: 🌐 Frontend Build & Test
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 📦 Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: 🔧 Install Frontend Dependencies
working-directory: ./frontend
run: npm ci
- name: 🎨 Run ESLint
working-directory: ./frontend
run: npm run lint
- name: 🏗️ Build Frontend
working-directory: ./frontend
run: npm run build
- name: 📊 Check Bundle Size
working-directory: ./frontend
run: |
echo "📊 Bundle Analysis:"
npx next build --profile 2>/dev/null | grep -E "(Route|First Load JS|chunks)"
continue-on-error: true
# 🔐 Security Checks
security-checks:
name: 🔐 Security Analysis
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 🔒 Frontend Security Audit
working-directory: ./frontend
run: npm audit --audit-level moderate
continue-on-error: true
- name: 🛡️ Backend Bandit Security Check
working-directory: ./backend
run: |
pip install bandit
bandit -r app/ -f json -o bandit-report.json
# 📋 Project Health Check
health-check:
name: 📋 Project Health
runs-on: ubuntu-latest
needs: [backend-lint, frontend-build]
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 📊 Repository Statistics
run: |
echo "📊 Repository Health Report"
echo "=========================="
echo "📁 Total Files: $(find . -type f | wc -l)"
echo "🐍 Python Files: $(find . -name "*.py" | wc -l)"
echo "🌐 TypeScript/JS Files: $(find . -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" | wc -l)"
echo "📝 Documentation Files: $(find . -name "*.md" | wc -l)"
echo "📦 Config Files: $(find . -name "*.json" -o -name "*.toml" -o -name "*.yaml" -o -name "*.yml" | wc -l)"
echo ""
echo "🔍 Code Quality Metrics"
echo "======================"
echo "📏 Lines of Code:"
find . -name "*.py" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" | xargs wc -l | tail -1
echo ""
echo "📚 README Quality Check:"
if [ -f "README.md" ]; then
echo "✅ README.md exists ($(wc -l < README.md) lines)"
else
echo "❌ README.md missing"
fi
echo ""
echo "📄 License Check:"
if [ -f "LICENSE" ]; then
echo "✅ LICENSE file exists"
else
echo "❌ LICENSE file missing"
fi
# 🚀 Deployment Ready Check
deployment-ready:
name: 🚀 Deployment Ready
runs-on: ubuntu-latest
needs: [backend-lint, frontend-build, security-checks, health-check]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 🎯 Deployment Readiness Check
run: |
echo "🚀 Deployment Readiness Report"
echo "=============================="
echo "✅ Backend linting: PASSED"
echo "✅ Frontend build: PASSED"
echo "✅ Security checks: PASSED"
echo "✅ Health checks: PASSED"
echo ""
echo "🌟 Project is ready for deployment!"
echo ""
echo "📋 Next Steps:"
echo "1. 🐳 Build Docker containers"
echo "2. 🌐 Deploy to staging environment"
echo "3. 🧪 Run integration tests"
echo "4. 🚀 Deploy to production"
echo ""
echo "🎉 Instructify CI/CD Pipeline Complete!"
- name: 📊 Generate Deployment Artifact
run: |
echo "🚀 Deployment Info" > deployment-info.txt
echo "==================" >> deployment-info.txt
echo "📅 Build Date: $(date)" >> deployment-info.txt
echo "🔖 Commit: ${{ github.sha }}" >> deployment-info.txt
echo "🌿 Branch: ${{ github.ref_name }}" >> deployment-info.txt
echo "👤 Author: ${{ github.actor }}" >> deployment-info.txt
echo "📦 Backend: Python ${{ env.PYTHON_VERSION }}" >> deployment-info.txt
echo "🌐 Frontend: Node.js ${{ env.NODE_VERSION }}" >> deployment-info.txt
echo "🤖 AI Model: Gemma 3 270M" >> deployment-info.txt
echo "🔗 Repository: ${{ github.repository }}" >> deployment-info.txt
- name: 📤 Upload Deployment Artifact
uses: actions/upload-artifact@v4
with:
name: deployment-info
path: deployment-info.txt
retention-days: 30
# 📈 Performance Metrics (Optional)
performance-check:
name: 📈 Performance Metrics
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: 🔧 Install Dependencies
working-directory: ./frontend
run: npm ci
- name: 📊 Bundle Analysis
working-directory: ./frontend
run: |
npm run build
echo "📊 Bundle Size Report" >> $GITHUB_STEP_SUMMARY
echo "===================" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
npx next build 2>&1 | grep -A 10 "Route (app)" >> $GITHUB_STEP_SUMMARY || echo "No bundle info available" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
continue-on-error: true