-
Notifications
You must be signed in to change notification settings - Fork 0
311 lines (270 loc) · 10.7 KB
/
pipeline.yaml
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
name: cicd
on:
push:
# All pushes
workflow_dispatch:
# This allows it to be triggered manually in the github console
# You could put inputs here, but we don't need them.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# This causes it to cancel previous in-progress actions in the same PR
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.5.1"
# This is the token associated with "prod-biggies" (with shared credentials on 1password)
GROUNDLIGHT_API_TOKEN: ${{ secrets.GROUNDLIGHT_API_TOKEN }}
# This is the NGINX proxy endpoint
GROUNDLIGHT_ENDPOINT: http://localhost:6717
jobs:
test-in-k3s:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install k3s
run: |
curl -sfL https://get.k3s.io | sh -
sudo chmod 644 /etc/rancher/k3s/k3s.yaml
sudo chown $USER /etc/rancher/k3s/k3s.yaml
# symlink to kubeconfig
mkdir -p ~/.kube
ln -s /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Deploy the edge-endpoint yaml
run: |
set -ex
# Once there's a fix for disk-pressure issues on GHA's runner, we can uncomment the
# following command in order to set up the environment to test out edge inference
# source test/setup_inference_test_env.sh
export INFERENCE_FLAVOR="CPU"
export DEPLOYMENT_NAMESPACE="default"
bash deploy/bin/cluster_setup.sh
kubectl describe deployment
- name: Wait for edge-endpoint pod to be ready
run: |
set -ex
kubectl rollout status deployment edge-endpoint --timeout=5m
kubectl describe pod edge-endpoint
test-motion-detection:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v4
with :
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Docker
# moby-runc is a CLI tool for spawning and running containers according to the Open Container Initiative (OCI)
# specification, and it is used by the Docker runtime. The existing version of moby-runc on the GitHub Actions runner
# is often incompatible with the version of Docker we want to install, so we need to remove it first.
run: |
sudo apt-get update
sudo apt-get remove moby-runc
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
- name: Build Docker Image
run: docker build --tag groundlight-edge .
- name: Start Docker Container
id: start_container
run: |
source test/setup_motion_detection_test_env.sh
echo "EDGE_CONFIG=$EDGE_CONFIG"
container_id=$(docker run \
-e LOG_LEVEL=DEBUG \
-e EDGE_CONFIG \
-d -p 6717:6717 \
groundlight-edge)
echo "::set-output name=container_id::$container_id"
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{hashFiles('**/poetry.lock') }}
- name: Install package
run: |
poetry install --no-interaction
- name: Run Motion Detection Tests
run: |
source test/setup_motion_detection_test_env.sh
poetry run pytest -vs test/api/test_motdet.py
- name: Dump Logs from Docker Container
if: always()
run: docker logs ${{ steps.start_container.outputs.container_id }}
- name: Stop Docker Container
# This ensures that we always stop the container regardless of the outcomes of
# the previous steps
if: always()
run: docker stop ${{ steps.start_container.outputs.container_id }}
test-general-edge-endpoint:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Docker
run: |
sudo apt-get update
sudo apt-get remove moby-runc
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
- name: Build Docker Image
run: docker build --tag groundlight-edge .
- name: Start Docker Container
id: start_container
run: |
source test/setup_plain_test_env.sh
echo "EDGE_CONFIG=$EDGE_CONFIG"
container_id=$(docker run \
-e LOG_LEVEL=DEBUG \
-e EDGE_CONFIG \
-d -p 6717:6717 \
groundlight-edge)
echo "::set-output name=container_id::$container_id"
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{hashFiles('**/poetry.lock') }}
- name: Install edge-endpoint's python dependencies
run: |
poetry install --no-interaction --no-root
- name: Run Unit Tests
run: |
source test/setup_plain_test_env.sh
poetry run pytest -k "not test_motdet"
- name: Dump Logs from Docker Container
if: always()
run: docker logs ${{ steps.start_container.outputs.container_id }}
- name: Stop Docker Container
# This ensures that we always stop the container regardless of the outcomes of
# the previous steps
if: always()
run: docker stop ${{ steps.start_container.outputs.container_id }}
# Run Groundlight SDK tests against the edge proxy endpoint
test-sdk:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Docker
run: |
sudo apt-get update
sudo apt-get remove moby-runc
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
- name: Build Docker Image
run: docker build --tag groundlight-edge .
- name: Start Docker Container
id: start_container
run: |
source test/setup_plain_test_env.sh
echo "EDGE_CONFIG=$EDGE_CONFIG"
container_id=$(docker run \
-e LOG_LEVEL=DEBUG \
-e EDGE_CONFIG \
-d -p 6717:6717 \
groundlight-edge)
echo "::set-output name=container_id::$container_id"
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{hashFiles('**/poetry.lock') }}
# Note that we're pulling the latest main from the SDK repo
# This might be ahead of what's published to pypi, but it's useful to test things before they're released.
- name: Checkout Groundlight SDK
uses: actions/checkout@v3
with:
repository: groundlight/python-sdk
path: groundlight-sdk
- name: Install Groundlight SDK dependencies
run: |
cd groundlight-sdk
make install
- name: Run Groundlight SDK tests against Prod API via Edge Proxy Endpoint
run: |
cd groundlight-sdk
make test-4edge
cd ..
- name: Dump Logs from Docker Container
if: always()
run: docker logs ${{ steps.start_container.outputs.container_id }}
- name: Stop Docker Container
# This ensures that we always stop the container regardless of the outcomes of
# the previous steps
if: always()
run: docker stop ${{ steps.start_container.outputs.container_id }}
build-push-edge-endpoint-multiplatform:
if: (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
# We only run this action if all the prior test actions succeed
needs:
- test-in-k3s
- test-motion-detection
- test-general-edge-endpoint
- test-sdk
runs-on: ubuntu-22.04
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
- name: Check out code
uses: actions/checkout@v4
- name: Build and Push Multiplatform edge-endpoint Image to ECR
timeout-minutes: 45
run:
./deploy/bin/build-push-edge-endpoint-image.sh