From a8d0021a69696244120bb182ee635e1c263223ad Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 10 Feb 2019 01:49:52 -0500 Subject: [PATCH 1/5] don't rename bin if its already named bootstrap. fixes #7 --- build.sh | 7 +++++-- tests/test-func/Cargo.toml | 6 ++++++ tests/test.sh | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index f6bef59..9adf98a 100755 --- a/build.sh +++ b/build.sh @@ -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 ( + export -f package if [ -z "$BIN" ]; then - find -maxdepth 1 -executable -type f -exec package {} \; + find -maxdepth 1 -executable -type f -exec bash -c 'package "$0"' {} \; else package "$BIN" fi diff --git a/tests/test-func/Cargo.toml b/tests/test-func/Cargo.toml index 77565d3..0e94a58 100644 --- a/tests/test-func/Cargo.toml +++ b/tests/test-func/Cargo.toml @@ -4,6 +4,12 @@ version = "0.1.0" authors = ["softprops "] 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" \ No newline at end of file diff --git a/tests/test.sh b/tests/test.sh index 57e581a..37338f5 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -46,10 +46,11 @@ 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 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 \ @@ -57,6 +58,7 @@ function package_bin() { ls target/lambda/release/test-func.zip > /dev/null 2>&1 } +# test packaging all binaries function package_all() { rm target/lambda/release/ > /dev/null 2>&1 docker run --rm \ @@ -68,7 +70,7 @@ function package_all() { } # 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 From eae465a4775705c609d5eaf94ecea46a33532ef6 Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 10 Feb 2019 01:50:59 -0500 Subject: [PATCH 2/5] proper scope --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9adf98a..2cbaced 100755 --- a/build.sh +++ b/build.sh @@ -29,8 +29,8 @@ function package() { cd "$CARGO_TARGET_DIR"/release ( - export -f package if [ -z "$BIN" ]; then + export -f package find -maxdepth 1 -executable -type f -exec bash -c 'package "$0"' {} \; else package "$BIN" From bef76f6b8be409ed55a71fc3065cf215fa58bf00 Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 10 Feb 2019 02:15:41 -0500 Subject: [PATCH 3/5] fix tests --- tests/test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 37338f5..7c83a88 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -48,25 +48,25 @@ 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="$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 From 366af068edb3497262f5c89f099a3d64dd19b553 Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 10 Feb 2019 02:16:04 -0500 Subject: [PATCH 4/5] rm trailing slash --- tests/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 7c83a88..f2627d0 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -48,7 +48,7 @@ cd ${HERE}/test-func # test packaing with a single binary function package_bin() { - rm -rf target/lambda/release/ > /dev/null 2>&1 + rm -rf target/lambda/release > /dev/null 2>&1 docker run --rm \ -e BIN="$1" \ -v ${PWD}:/code \ @@ -60,7 +60,7 @@ function package_bin() { # test packaging all binaries function package_all() { - rm -rf 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 \ From e7d81ab8ee95d57ed6820a723076cb05e48e4366 Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 10 Feb 2019 03:26:22 -0500 Subject: [PATCH 5/5] unzip for right location --- tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index f2627d0..f2a705e 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -78,7 +78,7 @@ assert_success "it packages all bins" package_all 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 \