Skip to content

Commit

Permalink
Run java test before uploading java tools zip to GCS.
Browse files Browse the repository at this point in the history
  • Loading branch information
iirina committed May 6, 2019
1 parent c63b3ad commit 337cbd3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
13 changes: 10 additions & 3 deletions src/test/shell/bazel/bazel_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${CURRENT_DIR}/../integration_test_setup.sh" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }

echo "args are $@"

JAVA_TOOLCHAIN="$1"; shift
add_to_bazelrc "build --java_toolchain=${JAVA_TOOLCHAIN}"

JAVA_TOOLS_ZIP="$1"; shift

echo "JAVA_TOOLS_ZIP=$JAVA_TOOLS_ZIP"
if [[ "${JAVA_TOOLS_ZIP}" != "released" ]]; then
JAVA_TOOLS_ZIP_FILE_URL="file://$(rlocation io_bazel/$JAVA_TOOLS_ZIP)"
if [[ "${JAVA_TOOLS_ZIP}" != file* ]]; then
echo "file is in rlocation"
JAVA_TOOLS_ZIP_FILE_URL="file://$(rlocation io_bazel/$JAVA_TOOLS_ZIP)"
else
JAVA_TOOLS_ZIP_FILE_URL="${JAVA_TOOLS_ZIP}"
fi
echo "JAVA_TOOLS_ZIP_FILE_URL=$JAVA_TOOLS_ZIP_FILE_URL"
fi
JAVA_TOOLS_ZIP_FILE_URL=${JAVA_TOOLS_ZIP_FILE_URL:-}
Expand All @@ -47,7 +54,7 @@ EOF
if [[ ! -z "${JAVA_TOOLS_ZIP_FILE_URL}" ]]; then
cat >>WORKSPACE <<EOF
http_archive(
name = "local_java_tools",
name = "java_tools",
urls = ["${JAVA_TOOLS_ZIP_FILE_URL}"]
)
EOF
Expand Down
45 changes: 31 additions & 14 deletions src/upload_java_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ while [[ -n "$@" ]]; do
"--commit_hash") commit_hash="$val" ;;
"--timestamp") timestamp="$val" ;;
"--bazel_version") bazel_version="$val" ;;
"--bazel_repo") bazel_repo="$val" ;;
*) echo "Flag $arg is not recognized." && exit 1 ;;
esac
done
Expand Down Expand Up @@ -90,6 +91,35 @@ EOF
# Add the README.md file to the temp zip.
zip -rv "${tmp_zip}" "${readme_file}"


# Test the artifact is valid
#cd "$tmp_dir"
#git clone https://bazel.googlesource.com/bazel
#cd bazel
#git checkout "$commit_hash"

cd "$bazel_repo"
test_name="bazel_java_test_${java_version}_${commit_hash}"
cat >>src/test/shell/bazel/BUILD <<EOF
sh_test(
name = "${test_name}",
size = "large",
timeout = "eternal",
srcs = ["bazel_java_test.sh"],
args = [
"@java_tools//:toolchain",
"file://${tmp_zip}",
],
data = [":test-deps"],
tags = [
# TODO(laszlocsomor): make this run on Windows. Currently fails because
# the java_common provider doesn't work on Windows.
"no_windows",
],
)
EOF
bazel test //src/test/shell/bazel:$test_name

gsutil_cmd="gsutil"
if [[ "$platform" == "windows" ]]; then
gsutil_cmd="gsutil.cmd"
Expand All @@ -99,17 +129,4 @@ gsutil_artifact="gs://bazel-mirror/bazel_java_tools/${gcs_java_tools_dir}/${comm
gsutil_url="https://mirror.bazel.build/bazel_java_tools/${gcs_java_tools_dir}/${commit_hash}/java${java_version}/java_tools_javac${java_version}_${platform}-${timestamp}.zip"

# Upload the zip that contains the README.md to GCS.
"$gsutil_cmd" cp "$tmp_zip" "$gsutil_artifact"

# Test the artifact is valid
cd "$tmp_dir"
git clone https://github.com/bazelbuild/bazel.git
cd bazel
git checkout "$commit_hash"
cat >>WORKSPACE <<EOF
http_archive(
name = "remote_java_tools",
urls = ["${gsutil_url}"]
)
EOF

"$gsutil_cmd" cp "$tmp_zip" "$gsutil_artifact"

0 comments on commit 337cbd3

Please sign in to comment.