Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f66dc81
feat(gha): more output logging
SafeEval Aug 11, 2025
a7e5ec9
Split zip and image build scripts
SafeEval Aug 23, 2025
1394727
Update semantic version config for main VS feature branches
SafeEval Aug 23, 2025
287afbb
Add script to get next version
SafeEval Aug 23, 2025
2e0bf8d
Use existing token if present
SafeEval Aug 23, 2025
e62e662
Prerelease versions include metadata
SafeEval Aug 23, 2025
94dd211
Just use the standard dev metadata in versions
SafeEval Aug 23, 2025
d7183e3
Update demo app with metadata
SafeEval Aug 23, 2025
e8edf57
Update tests to pass
SafeEval Aug 23, 2025
d902986
Update pyproject.toml with new SemVer config
SafeEval Aug 23, 2025
496a308
Add multi-stage Dockerfile for Lambda image
SafeEval Aug 23, 2025
fbb45b3
Docker build script works
SafeEval Aug 23, 2025
356a61a
Minor tweaks
SafeEval Aug 23, 2025
58a5c4e
Update tests
SafeEval Aug 23, 2025
147dd6c
Tear down env vars
SafeEval Aug 23, 2025
392307a
Better test failure messages
SafeEval Aug 23, 2025
aac1f9a
Refactor
SafeEval Aug 23, 2025
8672d76
Allow default value
SafeEval Aug 23, 2025
b039299
Update local-instance.sh script to work with Docker image
SafeEval Aug 24, 2025
fea8018
Update integration test to match
SafeEval Aug 24, 2025
17a5e47
Update integration-test task with deferred cleanup
SafeEval Aug 24, 2025
ffb228f
Refactor
SafeEval Aug 24, 2025
8ff7186
Just use Task in PR workflow
SafeEval Aug 24, 2025
acec50e
Add task binary to Python deps
SafeEval Aug 24, 2025
c2b1bbc
Add get-version task
SafeEval Aug 24, 2025
f3e3f20
Checkout full history and tags
SafeEval Aug 24, 2025
ae69e6c
Ignore dev dependencies in Dockerfile
SafeEval Aug 24, 2025
a3caa7d
Use build-image.sh for build task
SafeEval Aug 24, 2025
0d7fbb8
Add integration-test task without build dependency
SafeEval Aug 24, 2025
6e0b88b
Use integration-test-no-build in PR workflow
SafeEval Aug 24, 2025
09dfc73
Update pr-code-checks name
SafeEval Aug 24, 2025
1f1bebc
Trigger PR workflow
SafeEval Aug 24, 2025
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
157 changes: 0 additions & 157 deletions .github/workflows/pull-request-code.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/pull-request-format.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: PR Checks

on:
pull_request:
branches:
- main
- master
types:
- opened
- synchronize
- reopened
- edited

jobs:
pr-code-checks:
name: Code
runs-on: ubuntu-latest
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened'
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.head_ref || github.ref }}
# Need full history and tags to find the last release.
fetch-depth: 0
fetch-tags: true

# Work around occasional fetch-tags quirks.
- run: git fetch --tags --force

- name: Install Python
uses: actions/setup-python@v5

- name: Install uv
uses: astral-sh/[email protected]
with:
version: latest

- name: Setup
run: uv run task setup

- name: Lint
run: uv run task lint

- name: Unit Test
run: uv run task unit-test

- name: Build
run: uv run task build

- name: Integration Test
run: uv run task integration-test-no-build

pr-content-checks:
name: Content
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Validate PR title
run: ./scripts/conventional-commit.sh "${{ github.event.pull_request.title }}"
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
########################################################
# Stage 1: Install dependencies with uv and copy to /opt/python
########################################################
FROM python:3.12-slim AS deps

# Avoid prompts & keep images small
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1

ARG APP_ROOT="/app"
WORKDIR ${APP_ROOT}

# Bring in lockfiles first for better caching
COPY pyproject.toml ${APP_ROOT}/
COPY uv.lock ${APP_ROOT}/

# Install uv and create a local venv, then sync (no dev deps)
RUN pip install --no-cache-dir uv
RUN uv sync --no-group dev --frozen

# Materialize a Lambda-style "layer" dir with only runtime packages
# (Lambda adds /opt/python to sys.path automatically)
RUN mkdir -p /opt/python
RUN cp -a ${APP_ROOT}/.venv/lib/python3.12/site-packages/. /opt/python/


########################################################
# Stage 2: Create final AWS Lambda image
########################################################
#FROM public.ecr.aws/lambda/python:3.12-arm64
FROM public.ecr.aws/lambda/python:3.12

ARG APP_NAME
ARG APP_VERSION
ARG COMMIT_SHA
ARG BRANCH
ARG BUILD_DATE

ENV APP_NAME="${APP_NAME}"
ENV APP_VERSION="${APP_VERSION}"
ENV COMMIT_SHA="${COMMIT_SHA}"
ENV BRANCH="${BRANCH}"
ENV BUILD_DATE="${BUILD_DATE}"

LABEL org.opencontainers.image.name="${APP_NAME}" \
org.opencontainers.image.version="${APP_VERSION}" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.ref.branch="${BRANCH}" \
org.opencontainers.image.created="${BUILD_DATE}"

# This image automatically adds packages in /opt/python to sys.path
COPY --from=deps /opt/python /opt/python
COPY src/ ${LAMBDA_TASK_ROOT}/

ENV _HANDLER="main.handler"
CMD ["main.handler"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# lambda-application
Lambda app code and release, decoupled from Terraformed infrastructure
# Demo Lambda Application

Lambda app code and release, decoupled from Terraformed infrastructure.
28 changes: 24 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

version: "3"

vars:
DOCKER_IMAGE_NAME: lambda-application
DOCKER_IMAGE_TAG:
sh: ./scripts/get-version.sh
DOCKER_IMAGE: "{{.DOCKER_IMAGE_NAME}}:{{.DOCKER_IMAGE_TAG}}"

tasks:
default:
cmds:
Expand All @@ -18,6 +24,11 @@ tasks:
cmds:
- ./scripts/setup.sh

get-version:
run: once
cmds:
- ./scripts/get-version.sh

format:
run: once
cmds:
Expand All @@ -31,28 +42,37 @@ tasks:
build:
run: once
cmds:
- ./scripts/build.sh
- ./scripts/build-image.sh

unit-test:
run: once
cmds:
- ./scripts/unit-test.sh

integration-test-no-build:
run: once
cmds:
- task: start-local-instance
- defer: { task: stop-local-instance }
- ./scripts/integration-test.sh

integration-test:
run: once
deps:
- build
cmds:
- task: start-local-instance
- defer: { task: stop-local-instance }
- ./scripts/integration-test.sh
- task: stop-local-instance

start-local-instance:
desc: Start a local Lambda instance for testing
run: once
cmds:
- ./scripts/local-instance.sh start
- ./scripts/local-instance.sh start {{.DOCKER_IMAGE}}

stop-local-instance:
desc: Stop the local Lambda instance
run: once
cmds:
- ./scripts/local-instance.sh stop
- ./scripts/local-instance.sh stop {{.DOCKER_IMAGE}}
Loading