Skip to content

Commit

Permalink
Push generated wasm files in postsubmit (envoyproxy#2623)
Browse files Browse the repository at this point in the history
* push generated wasm file in post submit

* rename sha256 file

* add check before push wasm file

* clean up
  • Loading branch information
bianpengyuan authored and istio-testing committed Jan 15, 2020
1 parent becda9d commit e4df956
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ test_release:
export PATH=$(PATH) CC=$(CC) CXX=$(CXX) BAZEL_BUILD_ARGS="$(BAZEL_BUILD_ARGS)" && ./scripts/release-binary.sh -i

push_release:
export PATH=$(PATH) CC=$(CC) CXX=$(CXX) BAZEL_BUILD_ARGS="$(BAZEL_BUILD_ARGS)" && ./scripts/release-binary.sh -d "$(RELEASE_GCS_PATH)" -p && ./scripts/generate-wasm.sh -b -p
export PATH=$(PATH) CC=$(CC) CXX=$(CXX) BAZEL_BUILD_ARGS="$(BAZEL_BUILD_ARGS)" && ./scripts/release-binary.sh -d "$(RELEASE_GCS_PATH)" -p && ./scripts/generate-wasm.sh -b -p -d "$(RELEASE_GCS_PATH)"

.PHONY: build clean test check artifacts

Expand Down
32 changes: 30 additions & 2 deletions scripts/generate-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ function usage() {
If the image already exist in the HUB, this will be noop.
The container will be used to compile wasm files.
-p push the wasm sdk container built from the envoy SHA. Must use with `-b`
-c controls whether to check diff of generated wasm files."
-c controls whether to check diff of generated wasm files.
-d The bucket name to store the generated wasm files."
exit 1
}

BUILD_CONTAINER=0
PUSH_CONTAINER=0
CHECK_DIFF=0
DST_BUCKET=""

while getopts bpc arg ; do
while getopts bpcd: arg ; do
case "${arg}" in
b) BUILD_CONTAINER=1;;
p) PUSH_DOCKER_IMAGE=1;;
c) CHECK_DIFF=1;;
d) DST_BUCKET="${OPTARG}";;
*) usage;;
esac
done
Expand Down Expand Up @@ -90,3 +93,28 @@ if [[ ${CHECK_DIFF} == 1 ]]; then
echo "wasm files are up to dated"
fi
fi

echo "Destination bucket: ${DST_BUCKET}"
if [ -n "${DST_BUCKET}" ]; then
cd ${ROOT}
# Get SHA of proxy repo
SHA="$(git rev-parse --verify HEAD)"
TMP_WASM=$(mktemp -d -t wasm-plugins-XXXXXXXXXX)
trap "rm -rf ${TMP_WASM}" EXIT
for i in `find . -name "*.wasm" -type f`; do
# Get name of the plugin
PLUGIN_NAME=$(basename $(dirname ${i}))
# Rename the plugin file and generate sha256 for it
WASM_NAME="${PLUGIN_NAME}-${SHA}.wasm"
WASM_PATH="${TMP_WASM}/${WASM_NAME}"
SHA256_PATH="${WASM_PATH}.sha256"
cp ${i} ${WASM_PATH}
sha256sum "${WASM_PATH}" > "${SHA256_PATH}"

# push wasm files and sha to the given bucket
gsutil stat "${DST_BUCKET}/${WASM_NAME}" \
&& { echo "WASM file ${WASM_NAME} already exist"; continue; } \
|| echo "Pushing the WASM file ${WASM_NAME}"
gsutil cp "${WASM_PATH}" "${SHA256_PATH}" "${DST_BUCKET}"
done
fi

0 comments on commit e4df956

Please sign in to comment.