-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
178 lines (150 loc) · 5.51 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
178 lines (150 loc) · 5.51 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
name: Build & Deploy to Cloud Run
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
REGION: us-central1
SERVICE: a0p
REGISTRY: us-central1-docker.pkg.dev
jobs:
provider-contracts:
name: Provider adapter contracts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install Python dependencies
run: pip install -e . pytest pytest-asyncio
- name: Run provider contracts
run: |
pytest -q tests/test_open_comp_prov_v0.0.0alpha.py tests/test_open_comp_rout_v0.0.0alpha.py tests/test_aone_open_comp_adap_v0.0.0alpha.py tests/test_a0_package.py
python -m python.tests.contract_runner --only check_openai_compatible_registry_wiring --only check_openai_compatible_repair_regressions
check-console-tabs:
name: Console tab regression guard
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: a0p_check
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/a0p_check
SESSION_SECRET: ci-session-secret
INTERNAL_API_SECRET: ci-internal-secret-for-console-tab-check
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install Node dependencies
run: npm ci
- name: Install Python dependencies
run: pip install -e .
- name: Apply database schema
run: npm run db:push
- name: Boot Python backend
run: |
uvicorn python.main:app --host 127.0.0.1 --port 8001 \
> /tmp/uvicorn.log 2>&1 &
echo $! > /tmp/uvicorn.pid
for i in $(seq 1 30); do
if curl -fsS http://127.0.0.1:8001/api/health > /dev/null; then
echo "backend up after ${i}s"
exit 0
fi
sleep 1
done
echo "backend failed to start"
cat /tmp/uvicorn.log
exit 1
- name: Run console-tab regression guard
run: API_BASE=http://127.0.0.1:8001 node scripts/check-console-tabs.mjs
- name: Stop Python backend
if: always()
run: |
if [ -f /tmp/uvicorn.pid ]; then
kill "$(cat /tmp/uvicorn.pid)" 2>/dev/null || true
fi
deploy:
name: Build, push, deploy
needs: [provider-contracts, check-console-tabs]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate required secrets
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
run: |
test -n "$GCP_PROJECT_ID" || { echo "Missing GCP_PROJECT_ID"; exit 1; }
test -n "$GCP_SA_KEY" || { echo "Missing GCP_SA_KEY"; exit 1; }
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v3
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up gcloud
uses: google-github-actions/setup-gcloud@v3
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{ env.REGISTRY }} --quiet
- name: Build Docker image
run: |
docker build \
--tag ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }} \
--tag ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:latest \
.
- name: Push Docker image
run: |
docker push ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }}
docker push ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:latest
- name: Deploy to Cloud Run
run: |
gcloud run deploy ${{ env.SERVICE }} \
--project=${{ env.PROJECT_ID }} \
--image=${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }} \
--region=${{ env.REGION }} \
--platform=managed \
--allow-unauthenticated \
--port=5000 \
--min-instances=0 \
--max-instances=10 \
--memory=512Mi \
--cpu=1 \
--set-secrets="DATABASE_URL=a0p-database-url:latest,SESSION_SECRET=a0p-session-secret:latest,XAI_API_KEY=a0p-xai-api-key:latest,DEEPSEEK_API_KEY=a0p-deepseek-api-key:latest,STRIPE_SECRET_KEY=a0p-stripe-secret-key:latest,STRIPE_WEBHOOK_SECRET=a0p-stripe-webhook-secret:latest"