Skip to content

Commit 30d83ef

Browse files
authored
ci: Add GitHub Actions workflow to test deploy.sh (#1)
1 parent 2a4bdb5 commit 30d83ef

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

.github/workflows/test-build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Test Build Script
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0"
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- '*'
12+
13+
jobs:
14+
test-local-build-and-e2e:
15+
runs-on: ubuntu-latest
16+
name: Test deploy.sh in standard environment
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install AWS SAM CLI
28+
run: pip install aws-sam-cli
29+
30+
- name: Test deploy.sh script
31+
run: ./deploy.sh
32+
33+
- name: Test local uvicorn/FastAPI server
34+
run: |
35+
mv .aws-sam/build/BedrockAccessGatewayLayer/python/* ./app
36+
(cd app && ./run.sh &)
37+
timeout 30 bash -c 'while ! nc -z localhost 8000; do sleep 1; done'
38+
curl localhost:8000/health | jq
39+
curl localhost:8000/api/v1/models -H 'Authorization: Bearer bedrock' | jq
40+
41+
test-cloudshell-build:
42+
runs-on: ubuntu-latest
43+
name: Test deploy.sh in CloudShell environment
44+
container:
45+
image: public.ecr.aws/amazonlinux/amazonlinux:2023
46+
env:
47+
AWS_EXECUTION_ENV: CloudShell
48+
49+
steps:
50+
- name: Install dependencies
51+
run: |
52+
yum install -y sudo python3-pip tar git
53+
pip3 install aws-sam-cli
54+
55+
- name: Checkout code
56+
uses: actions/checkout@v3
57+
58+
- name: Test deploy.sh script
59+
run: ./deploy.sh

app/run.sh

100644100755
File mode changed.

deploy.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
PYTHON_VERSION=3.12
3+
export PYTHON_VERSION=3.12
4+
export SAM_CLI_TELEMETRY=0
45

56
# Parse command line arguments
67
while [[ $# -gt 0 ]]; do
@@ -27,4 +28,9 @@ fi
2728
./prepare_source.sh $NO_EMBEDDINGS
2829

2930
sam build $USE_CONTAINER
31+
32+
if [[ ! -z "$CI" ]]; then
33+
exit
34+
fi
35+
3036
sam deploy --guided

prepare_source.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ fi
6363

6464
cp -r $REPO_DIR/src/api app/api
6565

66+
# To surpress warnings
67+
echo "" > app/requirements.txt
68+
6669
# Remove "Manum" from requirements.txt, as LWA is used instead.
6770
grep -v "mangum" $REPO_DIR/src/requirements.txt > layer/requirements.txt
6871
grep -v "Mangum" $REPO_DIR/src/api/app.py > app/api/app.py

0 commit comments

Comments
 (0)