Repository navigation
209 lines (180 loc) · 7.33 KB
/
Copy pathdeploy.yml
File metadata and controls
209 lines (180 loc) · 7.33 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
name: Deploy
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
inputs:
environment:
description: "Deployment environment"
required: true
default: "staging"
type: choice
options:
- staging
- production
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
NODE_VERSION: "22"
jobs:
# ── Pre-deploy checks ─────────────────────────────────────────────
pre-deploy:
name: Pre-deploy Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # a test inspects HEAD~1; a depth-1 clone has no such revision
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: package-lock.json
- name: Verify Python code
run: |
export PYTHONPATH="${{ github.workspace }}:${PYTHONPATH:-}"
python -m compileall -q apexgraphswarm/ scripts/ tests/
python -m pip install --quiet pytest networkx numpy hypothesis
- name: Check out integration kernel sources
shell: bash
run: ./scripts/fetch-integration-sources.sh
- name: Run test suite
run: python -m pytest -q
- name: Verify web app
run: |
npm install --no-audit --no-fund
npm run typecheck --workspace apexgraphswarm-workbench
npm test --workspace apexgraphswarm-workbench
# ── Build & package ───────────────────────────────────────────────
build:
name: Build & Package
runs-on: ubuntu-latest
needs: pre-deploy
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm install --no-audit --no-fund
- name: Build web app
run: npm run build --workspace apexgraphswarm-workbench
- name: Package Python control plane
run: |
mkdir -p dist
tar czf dist/apexgraphswarm-python.tar.gz \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='.integration-sources' \
--exclude='node_modules' \
apexgraphswarm/ scripts/ tests/
- name: Upload Python package
uses: actions/upload-artifact@v4
with:
name: apexgraphswarm-python-${{ github.run_id }}
path: dist/apexgraphswarm-python.tar.gz
retention-days: 30
- name: Upload web build
uses: actions/upload-artifact@v4
with:
name: apexgraphswarm-web-${{ github.run_id }}
path: apps/web/.next/
retention-days: 30
# ── Deploy web ────────────────────────────────────────────────────
deploy-web:
name: Deploy Web (${{ github.event.inputs.environment || 'staging' }})
runs-on: ubuntu-latest
# There is no real deployment target: the step below writes a placeholder URL
# (apexgraphswarm.example.com). An unconditional deploy therefore fails on every
# push at a step unrelated to the code. Gated on a repository variable so it
# activates the moment infrastructure exists -- set DEPLOY_ENABLED=true.
if: vars.DEPLOY_ENABLED == 'true'
needs: build
environment:
name: ${{ github.event.inputs.environment || 'staging' }}
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Download web build
uses: actions/download-artifact@v4
with:
name: apexgraphswarm-web-${{ github.run_id }}
path: apps/web/.next/
- name: Deploy web app
id: deploy
run: |
echo "🚀 Deploying web app..."
echo "Environment: ${{ github.event.inputs.environment || 'staging' }}"
echo "Commit: ${{ github.sha }}"
echo "url=https://apexgraphswarm.example.com" >> $GITHUB_OUTPUT
echo "✅ Web deployment complete"
# ── Deploy Python ─────────────────────────────────────────────────
deploy-python:
name: Deploy Python (${{ github.event.inputs.environment || 'staging' }})
runs-on: ubuntu-latest
needs: build
environment:
name: ${{ github.event.inputs.environment || 'staging' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Download Python package
uses: actions/download-artifact@v4
with:
name: apexgraphswarm-python-${{ github.run_id }}
path: dist/
- name: Deploy Python control plane
run: |
echo "🚀 Deploying Python control plane..."
echo "Environment: ${{ github.event.inputs.environment || 'staging' }}"
echo "Commit: ${{ github.sha }}"
echo "✅ Python deployment complete"
# ── Post-deploy verification ──────────────────────────────────────
verify:
name: Post-deploy Verification
runs-on: ubuntu-latest
needs: [deploy-web, deploy-python]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Verify deployment
run: |
echo "🔍 Running post-deploy verification..."
export PYTHONPATH="${{ github.workspace }}:${PYTHONPATH:-}"
python -c "import apexgraphswarm; print('✅ Python package importable')"
echo "✅ All post-deploy checks passed"
# ── Deploy summary ────────────────────────────────────────────────
deploy-summary:
name: Deploy Summary
runs-on: ubuntu-latest
needs: [deploy-web, deploy-python, verify]
if: always()
steps:
- name: Summarize deployment
run: |
echo "## Deployment Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Job | Result |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Deploy Web | ${{ needs.deploy-web.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Deploy Python | ${{ needs.deploy-python.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Verify | ${{ needs.verify.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Environment:** ${{ github.event.inputs.environment || 'staging' }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY