Repository navigation
222 lines (211 loc) · 9.26 KB
/
Copy pathci.yml
File metadata and controls
222 lines (211 loc) · 9.26 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
# Continuous Integration: verifies that a change (in particular Dependabot / security
# dependency updates) does not break the agent service, the web UI, or the CDK app.
#
# Everything runs offline against fakes: no AWS account, credentials, secrets or internet
# services (STAC API, satellite imagery, map tiles) are needed, so it also works for pull
# requests opened by Dependabot and from forks.
#
# ui type-check + production build of the React web app
# agent pinned requirements resolve + geospatial library and agent service tests
# (pytest, moto, local STAC API over synthetic GeoTIFFs, scripted LLM)
# agent-image the AgentCore container image builds on ARM64, as in CodeBuild
# e2e Playwright tests of the built UI: map (MapLibre/WebGL) and polygon drawing,
# Cognito sign-in + AgentCore SDK path, chat rendering, and a full-stack run
# against the real agent service
# infrastructure `cdk synth` of all stacks (incl. the optional object detection stack),
# with the cdk-nag AwsSolutions checks
# ci-status single aggregated status, convenient as the required branch-protection check
name: CI
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: "22"
PYTHON_VERSION: "3.11" # matches the agent Dockerfile base image
AWS_CDK_CLI_VERSION: "2.1148.1"
jobs:
ui:
name: UI - type-check & build
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: user-interface
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: user-interface/package-lock.json
- name: Install dependencies (from lockfile)
run: npm ci --no-audit --no-fund
- name: Type-check
run: npm run typecheck
- name: Production build
run: npm run build
agent:
name: Agent - dependencies & service tests
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: agent
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: agent/requirements*.txt
- name: Install pinned agent requirements
run: |
uv venv "$RUNNER_TEMP/agent-venv"
echo "VIRTUAL_ENV=$RUNNER_TEMP/agent-venv" >> "$GITHUB_ENV"
echo "$RUNNER_TEMP/agent-venv/bin" >> "$GITHUB_PATH"
VIRTUAL_ENV="$RUNNER_TEMP/agent-venv" uv pip install -r requirements.txt -r requirements-test.txt
- name: Check dependency compatibility
run: uv pip check
- name: Run geospatial library and agent service tests
run: python -m pytest -p no:cacheprovider
agent-image:
name: Agent - container image (ARM64)
# AgentCore runs ARM64 images, built by CodeBuild on an ARM host (see agentcore_stack.py).
runs-on: ubuntu-24.04-arm
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build image
run: docker build --pull -t geospatial-agent:ci agent
- name: Smoke-test image
run: |
# AgentCore sets the region; the geospatial library creates AWS clients at import time.
docker run --rm -e AWS_DEFAULT_REGION=us-east-1 --entrypoint python geospatial-agent:ci -c "
import importlib.metadata as md
import bedrock_agentcore, strands, strands_code_agent, smolagents, boto3, jinja2
import numpy, pandas, scipy, matplotlib, seaborn, plotly, PIL, pycocotools
import pystac, pystac_client, xarray, stackstac, shapely, pyproj, rasterio, rio_tiler, rioxarray, geopandas
from bedrock_agentcore.runtime import BedrockAgentCoreApp
from geospatial_agent import agent_service
from geospatial_agent.agent import GeospatialAgent
print({p: md.version(p) for p in ['strands-agents', 'strands-code-agent', 'bedrock-agentcore', 'boto3', 'pillow', 'rasterio']})
print('GDAL', rasterio.__gdal_version__)
"
test "$(docker run --rm --entrypoint id geospatial-agent:ci -un)" = "bedrock_agentcore"
docker run --rm --entrypoint sh geospatial-agent:ci -c "command -v opentelemetry-instrument"
# Test-only files must not be shipped in the image.
docker run --rm --entrypoint sh geospatial-agent:ci -c "test ! -e tests && test ! -e requirements-test.txt"
e2e:
name: E2E - UI (Playwright) & full stack
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: user-interface
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: user-interface/package-lock.json
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: agent/requirements*.txt
- name: Install agent requirements (for the full-stack tests)
working-directory: agent
run: |
uv venv "$RUNNER_TEMP/agent-venv"
VIRTUAL_ENV="$RUNNER_TEMP/agent-venv" uv pip install -r requirements.txt -r requirements-test.txt
- name: Install UI dependencies (from lockfile)
run: npm ci --no-audit --no-fund
- name: Install Playwright Chromium
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
env:
E2E_AGENT_PYTHON: ${{ runner.temp }}/agent-venv/bin/python
run: npx playwright test
- name: Upload Playwright report
if: ${{ !cancelled() && failure() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-report
path: |
user-interface/playwright-report/
user-interface/test-results/
retention-days: 14
infrastructure:
name: Infrastructure - CDK synth & cdk-nag
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: infrastructure
env:
# Synthesis needs no AWS access; a placeholder environment is enough.
CDK_DEFAULT_ACCOUNT: "123456789012"
CDK_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: infrastructure/requirements.txt
- name: Install CDK app requirements
run: |
uv venv "$RUNNER_TEMP/cdk-venv"
echo "$RUNNER_TEMP/cdk-venv/bin" >> "$GITHUB_PATH"
VIRTUAL_ENV="$RUNNER_TEMP/cdk-venv" uv pip install -r requirements.txt
- name: Seed the CDK context (no AWS lookups in CI)
# The VPC stack (env-specific, max_azs=2) looks up the availability zones of the
# target account; cdk.context.json is gitignored, so provide the cached lookup here.
run: |
cat > cdk.context.json << EOF
{"availability-zones:account=${CDK_DEFAULT_ACCOUNT}:region=${CDK_DEFAULT_REGION}": ["us-east-1a", "us-east-1b", "us-east-1c"]}
EOF
- name: Synthesize all stacks (fails on cdk-nag errors)
run: npx --yes "aws-cdk@${AWS_CDK_CLI_VERSION}" synth --quiet --no-notices --output "$RUNNER_TEMP/cdk.out"
- name: Synthesize all stacks including object detection (fails on cdk-nag errors)
run: npx --yes "aws-cdk@${AWS_CDK_CLI_VERSION}" synth --quiet --no-notices -c deploy_object_detection=true --output "$RUNNER_TEMP/cdk-od.out"
ci-status:
name: CI status
if: ${{ always() }}
needs: [ui, agent, agent-image, e2e, infrastructure]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check job results
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
echo "Job results: $RESULTS"
for result in $RESULTS; do
if [ "$result" != "success" ]; then
echo "::error::At least one CI job did not succeed."
exit 1
fi
done