iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2019 The Bazel Authors. All rights reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # A script to upload a given java_tools zip on GCS. Used by the java_tools_binaries |
| 18 | # Buildkite pipeline. It is not recommended to run this script manually. |
iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 19 | |
| 20 | # Script used by the "java_tools binaries" Buildkite pipeline to build the java tools archives |
| 21 | # and upload them on GCS. |
| 22 | # |
| 23 | # The script has to be executed directly without invoking bazel: |
| 24 | # $ src/upload_all_java_tools.sh |
| 25 | # |
| 26 | # The script cannot be invoked through a sh_binary using bazel because git |
| 27 | # cannot be used through a sh_binary. |
| 28 | |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 29 | set -euo pipefail |
| 30 | |
| 31 | case "$(uname -s | tr [:upper:] [:lower:])" in |
| 32 | msys*|mingw*|cygwin*) |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 33 | declare -r platform=windows |
| 34 | ;; |
| 35 | linux*) |
| 36 | declare -r platform=linux |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 37 | ;; |
| 38 | *) |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 39 | declare -r platform=other |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 40 | ;; |
| 41 | esac |
| 42 | |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 43 | echo Platform: $platform |
| 44 | |
| 45 | if [[ "$platform" == "windows" ]]; then |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 46 | export MSYS_NO_PATHCONV=1 |
| 47 | export MSYS2_ARG_CONV_EXCL="*" |
| 48 | fi |
| 49 | |
iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 50 | commit_hash=$(git rev-parse HEAD) |
| 51 | timestamp=$(date +%s) |
| 52 | bazel_version=$(bazel info release | cut -d' ' -f2) |
| 53 | |
Fabian Meumertzheim | 92cf162 | 2023-10-17 23:28:07 -0700 | [diff] [blame] | 54 | RELEASE_BUILD_OPTS="-c opt --tool_java_language_version=8 --java_language_version=8" |
hvadehra | a1ec09a | 2022-06-28 02:58:55 -0700 | [diff] [blame] | 55 | |
iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 56 | # Passing the same commit_hash and timestamp to all targets to mark all the artifacts |
| 57 | # uploaded on GCS with the same identifier. |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 58 | |
Fabian Meumertzheim | 92cf162 | 2023-10-17 23:28:07 -0700 | [diff] [blame] | 59 | bazel build ${RELEASE_BUILD_OPTS} //src:java_tools_zip |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 60 | zip_path=${PWD}/bazel-bin/src/java_tools.zip |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 61 | |
Fabian Meumertzheim | 92cf162 | 2023-10-17 23:28:07 -0700 | [diff] [blame] | 62 | bazel build ${RELEASE_BUILD_OPTS} //src:java_tools_prebuilt_zip |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 63 | prebuilt_zip_path=${PWD}/bazel-bin/src/java_tools_prebuilt.zip |
Ivo List | 23c4406 | 2020-10-19 07:30:47 -0700 | [diff] [blame] | 64 | |
Googler | 3401d0d | 2023-11-29 12:06:13 -0800 | [diff] [blame] | 65 | # copy zips out of bazel-bin so we don't lose them on later bazel invocations |
| 66 | cp -f ${zip_path} ${prebuilt_zip_path} ./ |
| 67 | zip_path=${PWD}/java_tools.zip |
| 68 | prebuilt_zip_path=${PWD}/java_tools_prebuilt.zip |
| 69 | |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 70 | if [[ "$platform" == "windows" ]]; then |
Fabian Meumertzheim | 4a29f08 | 2023-11-27 23:40:06 -0800 | [diff] [blame] | 71 | zip_path="$(cygpath -m "${zip_path}")" |
| 72 | prebuilt_zip_path="$(cygpath -m "${prebuilt_zip_path}")" |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 73 | fi |
| 74 | |
Googler | 3f63602 | 2024-02-05 09:25:22 -0800 | [diff] [blame] | 75 | # Temporary workaround for https://github.com/bazelbuild/bazel/issues/20753 |
| 76 | TEST_FLAGS="" |
| 77 | if [[ "$platform" == "linux" ]]; then |
| 78 | TEST_FLAGS="--sandbox_tmpfs_path=/tmp" |
| 79 | fi |
| 80 | |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 81 | # Skip for now, as the test is broken on Windows. |
| 82 | # See https://github.com/bazelbuild/bazel/issues/12244 for details |
| 83 | if [[ "$platform" != "windows" ]]; then |
hvd | b02458e | 2022-04-11 04:52:04 -0700 | [diff] [blame] | 84 | JAVA_VERSIONS=`cat src/test/shell/bazel/BUILD | grep '^JAVA_VERSIONS = ' | sed -e 's/JAVA_VERSIONS = //' | sed -e 's/["(),]//g'` |
| 85 | for java_version in $JAVA_VERSIONS; do |
Googler | 3f63602 | 2024-02-05 09:25:22 -0800 | [diff] [blame] | 86 | bazel test $TEST_FLAGS --verbose_failures --test_output=all --nocache_test_results \ |
Ivo List | 23c4406 | 2020-10-19 07:30:47 -0700 | [diff] [blame] | 87 | //src/test/shell/bazel:bazel_java_test_local_java_tools_jdk${java_version} \ |
Fabian Meumertzheim | 4a29f08 | 2023-11-27 23:40:06 -0800 | [diff] [blame] | 88 | --define=LOCAL_JAVA_TOOLS_ZIP_PATH="${zip_path}" \ |
| 89 | --define=LOCAL_JAVA_TOOLS_PREBUILT_ZIP_PATH="${prebuilt_zip_path}" |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 90 | done |
| 91 | fi |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 92 | |
Fabian Meumertzheim | 92cf162 | 2023-10-17 23:28:07 -0700 | [diff] [blame] | 93 | bazel run ${RELEASE_BUILD_OPTS} //src:upload_java_tools_prebuilt -- \ |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 94 | --commit_hash ${commit_hash} \ |
| 95 | --timestamp ${timestamp} \ |
| 96 | --bazel_version ${bazel_version} |
| 97 | |
| 98 | if [[ "$platform" == "linux" ]]; then |
Fabian Meumertzheim | 92cf162 | 2023-10-17 23:28:07 -0700 | [diff] [blame] | 99 | bazel run ${RELEASE_BUILD_OPTS} //src:upload_java_tools -- \ |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 100 | --commit_hash ${commit_hash} \ |
| 101 | --timestamp ${timestamp} \ |
| 102 | --bazel_version ${bazel_version} |
| 103 | |
Fabian Meumertzheim | 92cf162 | 2023-10-17 23:28:07 -0700 | [diff] [blame] | 104 | bazel run ${RELEASE_BUILD_OPTS} //src:upload_java_tools_dist -- \ |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 105 | --commit_hash ${commit_hash} \ |
| 106 | --timestamp ${timestamp} \ |
| 107 | --bazel_version ${bazel_version} |
Ivo List | d10013d | 2020-11-25 14:41:16 -0800 | [diff] [blame] | 108 | fi |