|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | + |
| 21 | +case $# in |
| 22 | + 2) VERSION="$1" |
| 23 | + RC_NUMBER="$2" |
| 24 | + ;; |
| 25 | + *) echo "Usage: $0 X.Y.Z RC_NUMBER" |
| 26 | + exit 1 |
| 27 | + ;; |
| 28 | +esac |
| 29 | + |
| 30 | +set -e |
| 31 | +set -x |
| 32 | +set -o pipefail |
| 33 | + |
| 34 | +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" |
| 35 | +ARROW_DIR="$(dirname $(dirname ${SOURCE_DIR}))" |
| 36 | +ARROW_DIST_URL='https://dist.apache.org/repos/dist/dev/arrow' |
| 37 | + |
| 38 | +download_dist_file() { |
| 39 | + curl \ |
| 40 | + --silent \ |
| 41 | + --show-error \ |
| 42 | + --fail \ |
| 43 | + --location \ |
| 44 | + --remote-name $ARROW_DIST_URL/$1 |
| 45 | +} |
| 46 | + |
| 47 | +download_rc_file() { |
| 48 | + download_dist_file apache-arrow-rs-${VERSION}-rc${RC_NUMBER}/$1 |
| 49 | +} |
| 50 | + |
| 51 | +import_gpg_keys() { |
| 52 | + download_dist_file KEYS |
| 53 | + gpg --import KEYS |
| 54 | +} |
| 55 | + |
| 56 | +fetch_archive() { |
| 57 | + local dist_name=$1 |
| 58 | + download_rc_file ${dist_name}.tar.gz |
| 59 | + download_rc_file ${dist_name}.tar.gz.asc |
| 60 | + download_rc_file ${dist_name}.tar.gz.sha256 |
| 61 | + download_rc_file ${dist_name}.tar.gz.sha512 |
| 62 | + gpg --verify ${dist_name}.tar.gz.asc ${dist_name}.tar.gz |
| 63 | + shasum -a 256 -c ${dist_name}.tar.gz.sha256 |
| 64 | + shasum -a 512 -c ${dist_name}.tar.gz.sha512 |
| 65 | +} |
| 66 | + |
| 67 | +verify_dir_artifact_signatures() { |
| 68 | + # verify the signature and the checksums of each artifact |
| 69 | + find $1 -name '*.asc' | while read sigfile; do |
| 70 | + artifact=${sigfile/.asc/} |
| 71 | + gpg --verify $sigfile $artifact || exit 1 |
| 72 | + |
| 73 | + # go into the directory because the checksum files contain only the |
| 74 | + # basename of the artifact |
| 75 | + pushd $(dirname $artifact) |
| 76 | + base_artifact=$(basename $artifact) |
| 77 | + if [ -f $base_artifact.sha256 ]; then |
| 78 | + shasum -a 256 -c $base_artifact.sha256 || exit 1 |
| 79 | + fi |
| 80 | + shasum -a 512 -c $base_artifact.sha512 || exit 1 |
| 81 | + popd |
| 82 | + done |
| 83 | +} |
| 84 | + |
| 85 | +setup_tempdir() { |
| 86 | + cleanup() { |
| 87 | + if [ "${TEST_SUCCESS}" = "yes" ]; then |
| 88 | + rm -fr "${ARROW_TMPDIR}" |
| 89 | + else |
| 90 | + echo "Failed to verify release candidate. See ${ARROW_TMPDIR} for details." |
| 91 | + fi |
| 92 | + } |
| 93 | + |
| 94 | + if [ -z "${ARROW_TMPDIR}" ]; then |
| 95 | + # clean up automatically if ARROW_TMPDIR is not defined |
| 96 | + ARROW_TMPDIR=$(mktemp -d -t "$1.XXXXX") |
| 97 | + trap cleanup EXIT |
| 98 | + else |
| 99 | + # don't clean up automatically |
| 100 | + mkdir -p "${ARROW_TMPDIR}" |
| 101 | + fi |
| 102 | +} |
| 103 | + |
| 104 | +test_source_distribution() { |
| 105 | + # install rust toolchain in a similar fashion like test-miniconda |
| 106 | + export RUSTUP_HOME=$PWD/test-rustup |
| 107 | + export CARGO_HOME=$PWD/test-rustup |
| 108 | + |
| 109 | + curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path |
| 110 | + |
| 111 | + export PATH=$RUSTUP_HOME/bin:$PATH |
| 112 | + source $RUSTUP_HOME/env |
| 113 | + |
| 114 | + # build and test rust |
| 115 | + |
| 116 | + # raises on any formatting errors |
| 117 | + rustup component add rustfmt --toolchain stable |
| 118 | + cargo fmt --all -- --check |
| 119 | + |
| 120 | + # Clone testing repositories if not cloned already |
| 121 | + git clone https://github.com/apache/arrow-testing.git arrow-testing-data |
| 122 | + git clone https://github.com/apache/parquet-testing.git parquet-testing-data |
| 123 | + export ARROW_TEST_DATA=$PWD/arrow-testing-data/data |
| 124 | + export PARQUET_TEST_DATA=$PWD/parquet-testing-data/data |
| 125 | + |
| 126 | + # use local modules because we don't publish modules to crates.io yet |
| 127 | + sed \ |
| 128 | + -i.bak \ |
| 129 | + -E \ |
| 130 | + -e 's/^arrow = "([^"]*)"/arrow = { version = "\1", path = "..\/arrow" }/g' \ |
| 131 | + -e 's/^parquet = "([^"]*)"/parquet = { version = "\1", path = "..\/parquet" }/g' \ |
| 132 | + */Cargo.toml |
| 133 | + |
| 134 | + cargo build |
| 135 | + cargo test |
| 136 | +} |
| 137 | + |
| 138 | +TEST_SUCCESS=no |
| 139 | + |
| 140 | +setup_tempdir "arrow-${VERSION}" |
| 141 | +echo "Working in sandbox ${ARROW_TMPDIR}" |
| 142 | +cd ${ARROW_TMPDIR} |
| 143 | + |
| 144 | +dist_name="apache-arrow-rs-${VERSION}" |
| 145 | +import_gpg_keys |
| 146 | +fetch_archive ${dist_name} |
| 147 | +tar xf ${dist_name}.tar.gz |
| 148 | +pushd ${dist_name} |
| 149 | +test_source_distribution |
| 150 | +popd |
| 151 | + |
| 152 | +TEST_SUCCESS=yes |
| 153 | +echo 'Release candidate looks good!' |
| 154 | +exit 0 |
0 commit comments