Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/rs_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ jobs:
components: clippy
cache: false
- uses: mozilla-actions/sccache-action@v0.0.9
# We need to do these separately because the fips feature is incompatible with the default feature.
- working-directory: bottlecap
run: cargo clippy --workspace --all-features
run: cargo clippy --workspace --features default
- working-directory: bottlecap
run: cargo clippy --workspace --no-default-features --features fips

build-all:
name: Build All
Expand Down
1 change: 1 addition & 0 deletions .gitlab/scripts/compile_bottlecap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ docker_build() {
fi

docker buildx build --platform linux/${arch} \
--progress plain \
-t datadog/compile-bottlecap \
-f ./images/${file} \
--build-arg PLATFORM=$PLATFORM \
Expand Down
10 changes: 7 additions & 3 deletions .gitlab/templates/pipeline.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,27 @@ cargo fmt:
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
needs: []
script:
- cd bottlecap && cargo fmt
- cd bottlecap && cargo fmt --all -- --check

cargo check:
stage: test
tags: ["arch:amd64"]
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
needs: []
script:
- cd bottlecap && cargo check
- cd bottlecap && cargo check --workspace

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

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

Expand Down
46 changes: 34 additions & 12 deletions bottlecap-run/runBottlecap.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
#!/bin/bash

set -e
arch=$(uname -a)
cd ../bottlecap
# build bottlecap in debug mode
if (echo $arch | grep -q "Darwin"); then
PATH=/usr/bin:$PATH cargo zigbuild --target=aarch64-unknown-linux-gnu
build_path=../bottlecap/target/aarch64-unknown-linux-gnu/debug/bottlecap
set -ex

# Setup cleanup trap to ensure docker container is stopped and removed even if script is interrupted
cleanup() {
if [ -n "${docker_name}" ]; then
echo "Cleaning up Docker container..."
docker stop "${docker_name}" 2>/dev/null || true
docker rm "${docker_name}" 2>/dev/null || true
fi
}

# Register trap for EXIT, INT (Ctrl+C), TERM, and ERR
trap cleanup EXIT INT TERM ERR

if [ -z "$PREBUILT_BUILD_PATH" ]; then
cd ../bottlecap
arch=$(uname -a)
# build bottlecap in debug mode
if (echo $arch | grep -q "Darwin"); then
PATH=/usr/bin:$PATH cargo zigbuild --target=aarch64-unknown-linux-gnu
build_path=../bottlecap/target/aarch64-unknown-linux-gnu/debug/bottlecap
else
cargo build
build_path=../bottlecap/target/debug/bottlecap
fi
cd -

else
cargo build
build_path=../bottlecap/target/debug/bottlecap
echo "using a prebuilt bottlecap from $PREBUILT_BUILD_PATH"
build_path="$PREBUILT_BUILD_PATH"
fi
cd -

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