Skip to content

Commit 155878f

Browse files
authored
Merge pull request #9 from softprops/bootstrap-bins
don't rename bin if its already named bootstrap.
2 parents a1fef45 + e7d81ab commit 155878f

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ function package() {
2020
rm "$file.zip" > 2&>/dev/null || true
2121
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
2222
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
23-
mv "$file" bootstrap
23+
if [ "$file" != ./bootstrap ] && [ "$file" != bootstrap ]; then
24+
mv "${file}" bootstrap
25+
fi
2426
zip "$file.zip" bootstrap
2527
rm bootstrap
2628
}
2729

2830
cd "$CARGO_TARGET_DIR"/release
2931
(
3032
if [ -z "$BIN" ]; then
31-
find -maxdepth 1 -executable -type f -exec package {} \;
33+
export -f package
34+
find -maxdepth 1 -executable -type f -exec bash -c 'package "$0"' {} \;
3235
else
3336
package "$BIN"
3437
fi

tests/test-func/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ version = "0.1.0"
44
authors = ["softprops <[email protected]>"]
55
edition = "2018"
66

7+
# users don't have to do this
8+
# but when they do, the builder packaging still work
9+
[[bin]]
10+
name = "bootstrap"
11+
path = "src/main.rs"
12+
713
[dependencies]
814
lambda_runtime = "0.1"
915
serde_json = "1.0"

tests/test.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,39 @@ DIST=$(cd $HERE/..; echo $PWD)
4646

4747
cd ${HERE}/test-func
4848

49+
# test packaing with a single binary
4950
function package_bin() {
50-
rm target/lambda/release/ > /dev/null 2>&1
51+
rm -rf target/lambda/release > /dev/null 2>&1
5152
docker run --rm \
52-
-e BIN=test-func \
53+
-e BIN="$1" \
5354
-v ${PWD}:/code \
5455
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
5556
-v ${HOME}/.cargo/git:/root/.cargo/git \
5657
softprops/lambda-rust && \
57-
ls target/lambda/release/test-func.zip > /dev/null 2>&1
58+
ls target/lambda/release/bootstrap.zip > /dev/null 2>&1
5859
}
5960

61+
# test packaging all binaries
6062
function package_all() {
61-
rm target/lambda/release/ > /dev/null 2>&1
63+
rm -rf target/lambda/release > /dev/null 2>&1
6264
docker run --rm \
6365
-v ${PWD}:/code \
6466
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
6567
-v ${HOME}/.cargo/git:/root/.cargo/git \
6668
softprops/lambda-rust && \
67-
ls target/lambda/release/test-func.zip > /dev/null 2>&1
69+
ls target/lambda/release/bootstrap.zip > /dev/null 2>&1
6870
}
6971

7072
# package tests
71-
assert_success "it packages single bin" package_bin
73+
assert_success "it packages single bin" package_bin bootstrap
7274

7375
assert_success "it packages all bins" package_all
7476

7577
# verify packaged artifact by invoking it using the lambdaci "provided" docker image
7678
rm test-out.log > /dev/null 2>&1
7779
rm -rf /tmp/lambda > /dev/null 2>&1
7880
unzip -o \
79-
target/lambda/release/test-func.zip \
81+
target/lambda/release/bootstrap.zip \
8082
-d /tmp/lambda > /dev/null 2>&1 && \
8183
docker run \
8284
-i -e DOCKER_LAMBDA_USE_STDIN=1 \

0 commit comments

Comments
 (0)