Skip to content

don't rename bin if its already named bootstrap. #9

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Feb 10, 2019
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
7 changes: 5 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ function package() {
rm "$file.zip" > 2&>/dev/null || true
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
mv "$file" bootstrap
if [ "$file" != ./bootstrap ] && [ "$file" != bootstrap ]; then
mv "${file}" bootstrap
fi
zip "$file.zip" bootstrap
rm bootstrap
}

cd "$CARGO_TARGET_DIR"/release
(
if [ -z "$BIN" ]; then
find -maxdepth 1 -executable -type f -exec package {} \;
export -f package
find -maxdepth 1 -executable -type f -exec bash -c 'package "$0"' {} \;
else
package "$BIN"
fi
Expand Down
6 changes: 6 additions & 0 deletions tests/test-func/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ version = "0.1.0"
authors = ["softprops <d.tangren@gmail.com>"]
edition = "2018"

# users don't have to do this
# but when they do, the builder packaging still work
[[bin]]
name = "bootstrap"
path = "src/main.rs"

[dependencies]
lambda_runtime = "0.1"
serde_json = "1.0"
16 changes: 9 additions & 7 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,39 @@ DIST=$(cd $HERE/..; echo $PWD)

cd ${HERE}/test-func

# test packaing with a single binary
function package_bin() {
rm target/lambda/release/ > /dev/null 2>&1
rm -rf target/lambda/release > /dev/null 2>&1
docker run --rm \
-e BIN=test-func \
-e BIN="$1" \
-v ${PWD}:/code \
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
-v ${HOME}/.cargo/git:/root/.cargo/git \
softprops/lambda-rust && \
ls target/lambda/release/test-func.zip > /dev/null 2>&1
ls target/lambda/release/bootstrap.zip > /dev/null 2>&1
}

# test packaging all binaries
function package_all() {
rm target/lambda/release/ > /dev/null 2>&1
rm -rf target/lambda/release > /dev/null 2>&1
docker run --rm \
-v ${PWD}:/code \
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
-v ${HOME}/.cargo/git:/root/.cargo/git \
softprops/lambda-rust && \
ls target/lambda/release/test-func.zip > /dev/null 2>&1
ls target/lambda/release/bootstrap.zip > /dev/null 2>&1
}

# package tests
assert_success "it packages single bin" package_bin
assert_success "it packages single bin" package_bin bootstrap

assert_success "it packages all bins" package_all

# verify packaged artifact by invoking it using the lambdaci "provided" docker image
rm test-out.log > /dev/null 2>&1
rm -rf /tmp/lambda > /dev/null 2>&1
unzip -o \
target/lambda/release/test-func.zip \
target/lambda/release/bootstrap.zip \
-d /tmp/lambda > /dev/null 2>&1 && \
docker run \
-i -e DOCKER_LAMBDA_USE_STDIN=1 \
Expand Down