diff --git a/build.sh b/build.sh index f6bef59..2cbaced 100755 --- a/build.sh +++ b/build.sh @@ -20,7 +20,9 @@ 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 } @@ -28,7 +30,8 @@ function package() { 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 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..f2a705e 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -46,29 +46,31 @@ 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 @@ -76,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 \