Skip to content

Commit 52de705

Browse files
committed
ci: run lambda integration tests via Docker Compose
- Add custom cargo-lambda runtime with containerized lambda runtime - Add Dockerfile.lambda-runtime to build minimal cargo-lambda image - Use docker-compose to start runtime with healthcheck - Simplify CI workflow: remove custom container setup, lint job
1 parent 6a00b04 commit 52de705

File tree

3 files changed

+53
-62
lines changed

3 files changed

+53
-62
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,15 @@ jobs:
1313
test:
1414
name: Test
1515
runs-on: ubuntu-latest
16-
container:
17-
image: ghcr.io/johnbasrai/cr8s/rust-dev:1.83.0-rev6
18-
credentials:
19-
username: ${{ github.actor }}
20-
password: ${{ secrets.GITHUB_TOKEN }}
2116

2217
steps:
2318
- name: Checkout code
2419
uses: actions/checkout@v4
2520

26-
- name: Show Rust version
27-
run: |
28-
rustc --version
29-
cargo --version
21+
- name: Install Rust
22+
uses: dtolnay/rust-toolchain@stable
23+
with:
24+
components: rustfmt
3025

3126
- name: Cache Cargo dependencies
3227
uses: actions/cache@v4
@@ -47,60 +42,17 @@ jobs:
4742
- name: Build release
4843
run: cargo build --release --quiet
4944

50-
- name: Run unit tests only
51-
run: cargo test --release --quiet --lib --bins
52-
53-
- name: Ensure cargo-lambda 1.8.5 is installed
54-
env:
55-
CARGO_HOME: /home/runner/.cargo
56-
PATH: /home/runner/.cargo/bin:${{ env.PATH }}
57-
run: |
58-
echo "PATH=$PATH"
59-
if ! command -v cargo-lambda &> /dev/null; then
60-
cargo install cargo-lambda --version 1.8.5
61-
fi
45+
- name: Run tests
46+
run: cargo test --release --quiet
6247

63-
- name: Start lambda runtime in background
64-
run: cargo lambda start --release &
65-
env:
66-
RUST_LOG: info
48+
- name: Build and start lambda runtime
49+
run: docker compose up -d --build
6750

68-
- name: Wait for lambda runtime to be ready
69-
run: sleep 5
51+
- name: Wait for lambda healthcheck
52+
run: |
53+
for i in {1..20}; do
54+
curl -sSf http://localhost:9000 && break || sleep 3
55+
done
7056
7157
- name: Run integration tests
72-
run: cargo test --quiet --test integration_tests --release
73-
env:
74-
RUST_LOG: info
75-
76-
lint:
77-
name: Lint
78-
runs-on: ubuntu-latest
79-
container:
80-
image: ghcr.io/johnbasrai/cr8s/rust-dev:1.83.0-rev6
81-
credentials:
82-
username: ${{ github.actor }}
83-
password: ${{ secrets.GITHUB_TOKEN }}
84-
85-
steps:
86-
- name: Checkout code
87-
uses: actions/checkout@v4
88-
89-
- name: Cache Cargo dependencies
90-
uses: actions/cache@v4
91-
with:
92-
path: |
93-
~/.cargo/bin/
94-
~/.cargo/registry/index/
95-
~/.cargo/registry/cache/
96-
~/.cargo/git/db/
97-
target/
98-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
99-
restore-keys: |
100-
${{ runner.os }}-cargo-
101-
102-
- name: Run Clippy
103-
run: cargo clippy --quiet --all-targets --all-features -- -D warnings
104-
105-
- name: Run audit & outdated
106-
run: cargo audit || cargo outdated || true
58+
run: cargo test --test integration_tests --release

Dockerfile.lambda-runtime

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM rust:1.83-slim
2+
3+
# Install system deps for building Rust packages and running cargo-lambda
4+
RUN apt-get update && apt-get install -y \
5+
build-essential \
6+
libssl-dev \
7+
pkg-config \
8+
curl \
9+
ca-certificates \
10+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
11+
12+
# Add cargo bin path explicitly
13+
ENV PATH="/usr/local/cargo/bin:${PATH}"
14+
15+
# Install cargo-lambda
16+
RUN cargo install cargo-lambda --version 1.8.5 --locked
17+
18+
# Default user
19+
RUN useradd -m dev
20+
USER dev
21+
WORKDIR /app
22+
23+
# Entry point optional
24+
CMD ["bash"]

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
services:
3+
lambda:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.lambda-runtime
7+
environment:
8+
RUST_LOG=info
9+
ports:
10+
- "9000:9000"
11+
healthcheck:
12+
test: ["CMD", "curl", "-f", "http://localhost:9000"]
13+
interval: 5s
14+
timeout: 2s
15+
retries: 10

0 commit comments

Comments
 (0)