Skip to content

Commit 68671a5

Browse files
feat: [SVLS-6242] fips bottlecap build
1 parent 02b5891 commit 68671a5

File tree

19 files changed

+624
-394
lines changed

19 files changed

+624
-394
lines changed

.github/workflows/rs_ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ jobs:
7676
components: clippy
7777
cache: false
7878
- uses: mozilla-actions/sccache-action@v0.0.9
79+
# We need to do these separately because the fips feature is incompatible with the default feature.
7980
- working-directory: bottlecap
80-
run: cargo clippy --workspace --all-features
81+
run: cargo clippy --workspace --features default
82+
- working-directory: bottlecap
83+
run: cargo clippy --workspace --no-default-features --features fips
8184

8285
build-all:
8386
name: Build All

.gitlab/scripts/compile_bottlecap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ docker_build() {
6262
fi
6363

6464
docker buildx build --platform linux/${arch} \
65+
--progress plain \
6566
-t datadog/compile-bottlecap \
6667
-f ./images/${file} \
6768
--build-arg PLATFORM=$PLATFORM \

.gitlab/templates/pipeline.yaml.tpl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,27 @@ cargo fmt:
2222
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
2323
needs: []
2424
script:
25-
- cd bottlecap && cargo fmt
25+
- cd bottlecap && cargo fmt --all -- --check
2626

2727
cargo check:
2828
stage: test
2929
tags: ["arch:amd64"]
3030
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
3131
needs: []
3232
script:
33-
- cd bottlecap && cargo check
33+
- cd bottlecap && cargo check --workspace
3434

3535
cargo clippy:
3636
stage: test
3737
tags: ["arch:amd64"]
3838
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
3939
needs: []
4040
script:
41-
- cd bottlecap && cargo clippy --all-features
41+
- apt-get update && apt-get install -y --fix-missing --no-install-recommends golang-go
42+
- cd bottlecap
43+
# We need to do these separately because the fips feature is incompatible with the default feature.
44+
- cargo clippy --workspace --features default
45+
- cargo clippy --workspace --no-default-features --features fips
4246

4347
{{ range $flavor := (ds "flavors").flavors }}
4448

bottlecap-run/runBottlecap.sh

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
#!/bin/bash
22

3-
set -e
4-
arch=$(uname -a)
5-
cd ../bottlecap
6-
# build bottlecap in debug mode
7-
if (echo $arch | grep -q "Darwin"); then
8-
PATH=/usr/bin:$PATH cargo zigbuild --target=aarch64-unknown-linux-gnu
9-
build_path=../bottlecap/target/aarch64-unknown-linux-gnu/debug/bottlecap
3+
set -ex
4+
5+
# Setup cleanup trap to ensure docker container is stopped and removed even if script is interrupted
6+
cleanup() {
7+
if [ -n "${docker_name}" ]; then
8+
echo "Cleaning up Docker container..."
9+
docker stop "${docker_name}" 2>/dev/null || true
10+
docker rm "${docker_name}" 2>/dev/null || true
11+
fi
12+
}
13+
14+
# Register trap for EXIT, INT (Ctrl+C), TERM, and ERR
15+
trap cleanup EXIT INT TERM ERR
16+
17+
if [ -z "$PREBUILT_BUILD_PATH" ]; then
18+
cd ../bottlecap
19+
arch=$(uname -a)
20+
# build bottlecap in debug mode
21+
if (echo $arch | grep -q "Darwin"); then
22+
PATH=/usr/bin:$PATH cargo zigbuild --target=aarch64-unknown-linux-gnu
23+
build_path=../bottlecap/target/aarch64-unknown-linux-gnu/debug/bottlecap
24+
else
25+
cargo build
26+
build_path=../bottlecap/target/debug/bottlecap
27+
fi
28+
cd -
29+
1030
else
11-
cargo build
12-
build_path=../bottlecap/target/debug/bottlecap
31+
echo "using a prebuilt bottlecap from $PREBUILT_BUILD_PATH"
32+
build_path="$PREBUILT_BUILD_PATH"
1333
fi
14-
cd -
1534

1635
# run a hello world function in Lambda RIE (https://github.com/aws/aws-lambda-runtime-interface-emulator)
1736
# the lambda_extension binary is copied to /opt/extensions
1837
docker_name=$(docker create \
1938
--publish 9000:8080 \
2039
-e DD_API_KEY=XXX \
40+
-e DD_SERVERLESS_FLUSH_STRATEGY='periodically,1' \
41+
-e DD_LOG_LEVEL=debug \
42+
-e RUST_BACKTRACE=full \
43+
-e DD_ENV=dev \
44+
-e DD_VERSION=1 \
2145
"public.ecr.aws/lambda/nodejs:20" "index.handler")
2246
echo -e 'export const handler = async () => {\n\tconsole.log("Hello world!");\n};' > /tmp/index.mjs
2347
docker cp "/tmp/index.mjs" "${docker_name}:/var/task/index.mjs"
@@ -26,5 +50,3 @@ docker exec "${docker_name}" mkdir -p /opt/extensions
2650
docker cp "${build_path}" "${docker_name}:/opt/extensions/datadog-agent"
2751
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
2852
docker logs "${docker_name}"
29-
docker stop "${docker_name}"
30-
docker rm "${docker_name}"

bottlecap/Cargo.lock

Lines changed: 61 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)