Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/actions/start-app/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Start local app"
description: "Start Flask app that will handle requests"
inputs:
deploy-command:
description: "Command to start app"
required: false
default: "make deploy"
health-path:
description: "Health probe path to POST"
required: false
default: "/2015-03-31/functions/function/invocations"
max-seconds:
description: "Maximum seconds to wait for readiness"
required: false
default: "60"
python-version:
description: "Python version to install"
required: true
runs:
using: "composite"
steps:
- name: "Start app"
shell: bash
env:
PYTHON_VERSION: ${{ inputs.python-version }}
run: |
set -euo pipefail
echo "Starting app: '${{ inputs.deploy-command }}'"
nohup ${{ inputs.deploy-command }} >/tmp/app.log 2>&1 &
echo $! > /tmp/app.pid
echo "PID: $(cat /tmp/app.pid)"
- name: "Wait for app to be ready"
shell: bash
run: |
set -euo pipefail
BASE_URL="${BASE_URL:-http://localhost:5000}"
HEALTH_URL="${BASE_URL}${{ inputs.health-path }}"
MAX="${{ inputs.max-seconds }}"
echo "Waiting for app at ${HEALTH_URL} (max ${MAX}s)..."
for i in $(seq 1 "${MAX}"); do
if curl -sSf -X POST "${HEALTH_URL}" -d '{}' >/dev/null; then
echo "App is ready"
exit 0
fi
sleep 1
done
echo "App did not become ready in time"
echo "---- recent app log ----"
tail -n 200 /tmp/app.log || true
exit 1
16 changes: 8 additions & 8 deletions .github/workflows/stage-2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
- name: "Run contract tests"
Expand Down Expand Up @@ -98,8 +98,8 @@ jobs:
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
- name: "Run schema validation tests"
Expand Down Expand Up @@ -128,8 +128,8 @@ jobs:
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
- name: "Run integration test"
Expand Down Expand Up @@ -158,8 +158,8 @@ jobs:
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
- name: "Start app"
uses: ./.github/actions/start-app
with:
python-version: ${{ inputs.python_version }}
max-seconds: 90
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ build-gateway-api: dependencies
@poetry run mypy --no-namespace-packages .
@echo "Packaging dependencies..."
@poetry build --format=wheel
@pip install "dist/gateway_api-0.1.0-py3-none-any.whl" --target "./target/gateway-api" --platform musllinux_1_1_x86_64 --only-binary=:all:
@pip install "dist/gateway_api-0.1.0-py3-none-any.whl" --target "./target/gateway-api" --platform musllinux_1_2_x86_64 --only-binary=:all:
# Copy main file separately as it is not included within the package.
@cp lambda_handler.py ./target/gateway-api/
@rm -rf ../infrastructure/images/gateway-api/resources/build/
@mkdir ../infrastructure/images/gateway-api/resources/build/
@cp -r ./target/gateway-api ../infrastructure/images/gateway-api/resources/build/
Expand Down
Loading
Loading