diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 0000000..ad8ba95 --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,59 @@ +name: Test Build Script + +on: + schedule: + - cron: "0 0 * * 0" + push: + branches: + - main + pull_request: + branches: + - '*' + +jobs: + test-local-build-and-e2e: + runs-on: ubuntu-latest + name: Test deploy.sh in standard environment + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install AWS SAM CLI + run: pip install aws-sam-cli + + - name: Test deploy.sh script + run: ./deploy.sh + + - name: Test local uvicorn/FastAPI server + run: | + mv .aws-sam/build/BedrockAccessGatewayLayer/python/* ./app + (cd app && ./run.sh &) + timeout 30 bash -c 'while ! nc -z localhost 8000; do sleep 1; done' + curl localhost:8000/health | jq + curl localhost:8000/api/v1/models -H 'Authorization: Bearer bedrock' | jq + + test-cloudshell-build: + runs-on: ubuntu-latest + name: Test deploy.sh in CloudShell environment + container: + image: public.ecr.aws/amazonlinux/amazonlinux:2023 + env: + AWS_EXECUTION_ENV: CloudShell + + steps: + - name: Install dependencies + run: | + yum install -y sudo python3-pip tar git + pip3 install aws-sam-cli + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Test deploy.sh script + run: ./deploy.sh diff --git a/app/run.sh b/app/run.sh old mode 100644 new mode 100755 diff --git a/deploy.sh b/deploy.sh index b747297..ec35178 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,6 +1,7 @@ #!/bin/bash -PYTHON_VERSION=3.12 +export PYTHON_VERSION=3.12 +export SAM_CLI_TELEMETRY=0 # Parse command line arguments while [[ $# -gt 0 ]]; do @@ -27,4 +28,9 @@ fi ./prepare_source.sh $NO_EMBEDDINGS sam build $USE_CONTAINER + +if [[ ! -z "$CI" ]]; then + exit +fi + sam deploy --guided diff --git a/prepare_source.sh b/prepare_source.sh index 25deb3e..ad56f44 100755 --- a/prepare_source.sh +++ b/prepare_source.sh @@ -63,6 +63,9 @@ fi cp -r $REPO_DIR/src/api app/api +# To surpress warnings +echo "" > app/requirements.txt + # Remove "Manum" from requirements.txt, as LWA is used instead. grep -v "mangum" $REPO_DIR/src/requirements.txt > layer/requirements.txt grep -v "Mangum" $REPO_DIR/src/api/app.py > app/api/app.py