Skip to content

Commit 7e1cf23

Browse files
committed
feat: establish Docker-based CI pipeline with consistent toolchain
- Add Rust 1.85 toolchain pinning via rust-toolchain.toml - Create scripts/build.sh for unified build/test process in containers - Mount rustfmt.toml to ensure consistent formatting between host/container - Add rustfmt component installation to Dockerfile - Mount tests/ directory for integration test access - Standardize CI to run all operations inside containers Eliminates toolchain version mismatches and provides single source of truth for build/test process that works identically in development and CI.
1 parent 72290d0 commit 7e1cf23

File tree

5 files changed

+28
-39
lines changed

5 files changed

+28
-39
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,5 @@ jobs:
2121
- name: Checkout code
2222
uses: actions/checkout@v4
2323

24-
- name: Install Rust
25-
uses: dtolnay/rust-toolchain@stable
26-
with:
27-
components: rustfmt
28-
29-
- name: Cache Cargo dependencies
30-
uses: actions/cache@v4
31-
with:
32-
path: |
33-
~/.cargo/bin/
34-
~/.cargo/registry/index/
35-
~/.cargo/registry/cache/
36-
~/.cargo/git/db/
37-
target/
38-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
39-
restore-keys: |
40-
${{ runner.os }}-cargo-
41-
42-
- name: Check formatting
43-
run: cargo fmt --check
44-
45-
- name: Build release
46-
run: cargo build --release --quiet
47-
48-
- name: Run tests
49-
run: cargo test --release --quiet --lib --bins
50-
51-
- name: Build and start lambda runtime
52-
run: docker compose up -d --build
53-
54-
- name: Wait for lambda healthcheck
55-
run: |
56-
for i in {1..20}; do
57-
timeout 2 nc -z localhost 9000 && break || sleep 3
58-
done
59-
60-
- name: Run integration tests
61-
run: docker exec aws-lambda-action-filter-lambda-1 \
62-
cargo test --test integration_tests --release --quiet
24+
- name: Run build and test script
25+
run: ./scripts/build.sh

Dockerfile.lambda-runtime

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ RUN apt-get update && apt-get install -y \
1212
# Add cargo bin path explicitly
1313
ENV PATH="/usr/local/cargo/bin:${PATH}"
1414

15+
# Install rustfmt component
16+
RUN rustup component add rustfmt
17+
1518
# Install cargo-lambda
1619
RUN cargo install cargo-lambda --version 1.8.5 --locked --quiet
1720

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ services:
99
- "9000:9000"
1010
volumes:
1111
- ./src:/app/src # hot-reload watch point for lambda server
12+
- ./tests:/app/tests # Integration tests.
1213
- ./testdata:/app/testdata # testdata for lambda invoke
1314
- ./Cargo.toml:/app/Cargo.toml
1415
- ./Cargo.lock:/app/Cargo.lock
16+
- ./rustfmt.toml:/app/rustfmt.toml
1517
- ${CR8S_SCRATCH_DIR:-/var/tmp}/aws/dev-cargo:/usr/local/cargo/registry
1618
- ${CR8S_SCRATCH_DIR:-/var/tmp}/aws/dev-target:/app/target
1719
environment:

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.85"
3+
components = ["rustfmt", "clippy"]

scripts/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Build and start the container
5+
docker compose up -d --build
6+
7+
# Wait for the service to be ready
8+
for i in {1..20}; do
9+
timeout 2 nc -z localhost 9000 && break || sleep 3
10+
done
11+
12+
# Run all tests inside the container
13+
docker exec aws-lambda-action-filter-lambda-1 cargo fmt --version
14+
docker exec aws-lambda-action-filter-lambda-1 cargo fmt --check
15+
docker exec aws-lambda-action-filter-lambda-1 cargo build --release --quiet
16+
docker exec aws-lambda-action-filter-lambda-1 cargo test --release --quiet
17+
18+
echo "All tests passed!"

0 commit comments

Comments
 (0)