|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed with |
| 5 | +# this work for additional information regarding copyright ownership. |
| 6 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | +# (the "License"); you may not use this file except in compliance with |
| 8 | +# the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | +# This script is used to validate the release package, including: |
| 19 | +# 1. Check the release package name & content |
| 20 | +# 2. Check the release package sha512 & gpg signature |
| 21 | +# 3. Compile the source package & run server & toolchain |
| 22 | +# 4. Run server & toolchain in binary package |
| 23 | + |
| 24 | +URL_PREFIX="https://dist.apache.org/repos/dist/dev/incubator/hugegraph/" |
| 25 | +# release version (input by committer) |
| 26 | +RELEASE_VERSION=$1 |
| 27 | +JAVA_VERSION=$2 |
| 28 | +# git release branch (check it carefully) |
| 29 | +#GIT_BRANCH="release-${RELEASE_VERSION}" |
| 30 | + |
| 31 | +RELEASE_VERSION=${RELEASE_VERSION:?"Please input the release version behind script"} |
| 32 | + |
| 33 | +# step1: download svn files |
| 34 | +rm -rf dist/"$RELEASE_VERSION" && svn co ${URL_PREFIX}/"$RELEASE_VERSION" dist/"$RELEASE_VERSION" |
| 35 | +cd dist/"$RELEASE_VERSION" || exit |
| 36 | + |
| 37 | +# step2: check environment & import public keys |
| 38 | +shasum --version 1>/dev/null || exit |
| 39 | +gpg --version 1>/dev/null || exit |
| 40 | + |
| 41 | +wget https://downloads.apache.org/incubator/hugegraph/KEYS || exit |
| 42 | +gpg --import KEYS |
| 43 | +# TODO: how to trust all public keys in gpg list, currently only trust the first one |
| 44 | +gpg --list-keys --with-colons | grep pub | cut -d: -f5 | xargs -I {} gpg --edit-key {} trust quit |
| 45 | +for key in $(gpg --list-keys --with-colons | awk -F: '/^pub/ {print $5}'); do |
| 46 | + gpg --edit-key "$key" trust quit |
| 47 | +done |
| 48 | + |
| 49 | +# step3: check sha512 & gpg signature |
| 50 | +for i in *.tar.gz; do |
| 51 | + echo "$i" |
| 52 | + shasum -a 512 --check "$i".sha512 || exit |
| 53 | + eval gpg "${GPG_OPT}" --verify "$i".asc "$i" || exit |
| 54 | +done |
| 55 | + |
| 56 | +# step4: validate source packages |
| 57 | +ls -lh ./*.tar.gz |
| 58 | +for i in *src.tar.gz; do |
| 59 | + echo "$i" |
| 60 | + #### step4.0: check the directory name include "incubating" |
| 61 | + if [[ ! "$i" =~ "incubating" ]]; then |
| 62 | + echo "The package name should include incubating" && exit 1 |
| 63 | + fi |
| 64 | + tar xzvf "$i" || exit |
| 65 | + cd "$(basename "$i" .tar.gz)" || exit |
| 66 | + |
| 67 | + #### step4.1: check the directory include "NOTICE" and "LICENSE" file |
| 68 | + if [[ ! -f "LICENSE" ]]; then |
| 69 | + echo "The package should include LICENSE file" && exit 1 |
| 70 | + fi |
| 71 | + if [[ ! -f "NOTICE" ]]; then |
| 72 | + echo "The package should include NOTICE file" && exit 1 |
| 73 | + fi |
| 74 | + # ensure doesn't contains empty directory or file |
| 75 | + COUNT=$(find . -type d -empty | wc -l) |
| 76 | + if [[ $COUNT -ne 0 ]]; then |
| 77 | + find . -type d -empty |
| 78 | + echo "The package should not include empty directory, but get $COUNT" # TODO: && exit 1 |
| 79 | + fi |
| 80 | + |
| 81 | + #### step4.2: compile the packages |
| 82 | + if [[ $JAVA_VERSION == 8 && "$i" =~ "computer" ]]; then |
| 83 | + cd .. && echo "skip computer module in java8" |
| 84 | + continue |
| 85 | + fi |
| 86 | + mvn package -DskipTests -ntp && ls -lh |
| 87 | + cd .. || exit |
| 88 | +done |
| 89 | + |
| 90 | +#### step4.3: run the compiled packages in server |
| 91 | +ls -lh |
| 92 | +cd ./*hugegraph-incubating*src/*hugegraph*"${RELEASE_VERSION}" || exit |
| 93 | +bin/init-store.sh && sleep 1 |
| 94 | +bin/start-hugegraph.sh && ls ../../ |
| 95 | +cd ../../ || exit |
| 96 | + |
| 97 | +#### step4.4: run the compiled packages in toolchain (include loader/tool/hubble) |
| 98 | +cd ./*toolchain*src || exit |
| 99 | +ls -lh |
| 100 | +cd ./*toolchain*"${RELEASE_VERSION}" || exit |
| 101 | +ls -lh |
| 102 | + |
| 103 | +##### 4.4.1 test loader |
| 104 | +cd ./*loader*"${RELEASE_VERSION}" || exit |
| 105 | +bin/hugegraph-loader.sh -f ./example/file/struct.json -s ./example/file/schema.groovy \ |
| 106 | + -g hugegraph || exit |
| 107 | +cd .. || exit |
| 108 | + |
| 109 | +##### 4.4.2 test tool |
| 110 | +cd ./*tool*"${RELEASE_VERSION}" || exit |
| 111 | +bin/hugegraph gremlin-execute --script 'g.V().count()' || exit |
| 112 | +bin/hugegraph task-list || exit |
| 113 | +bin/hugegraph backup -t all --directory ./backup-test || exit |
| 114 | +cd .. || exit |
| 115 | + |
| 116 | +##### 4.4.3 test hubble |
| 117 | +cd ./*hubble*"${RELEASE_VERSION}" || exit |
| 118 | +# TODO: add hubble doc & test it |
| 119 | +cat conf/hugegraph-hubble.properties && bin/start-hubble.sh |
| 120 | +cd ../../../ || exit |
| 121 | + |
| 122 | +# step5: validate the binary packages |
| 123 | +#### step5.0: check the directory name include "incubating" |
| 124 | +#### step5.1: check the directory include "NOTICE" and "LICENSE" file |
| 125 | +rm -rf ./*src* && ls -lh |
| 126 | +for i in *.tar.gz; do |
| 127 | + echo "$i" |
| 128 | + if [[ ! "$i" =~ "incubating" ]]; then |
| 129 | + echo "The package name should include incubating" && exit 1 |
| 130 | + fi |
| 131 | + tar xzvf "$i" || exit |
| 132 | + |
| 133 | + cd "$(basename "$i" .tar.gz)" && ls -lh || exit |
| 134 | + if [[ ! -f "LICENSE" ]]; then |
| 135 | + echo "The package should include LICENSE file" && exit 1 |
| 136 | + fi |
| 137 | + if [[ ! -f "NOTICE" ]]; then |
| 138 | + echo "The package should include NOTICE file" && exit 1 |
| 139 | + fi |
| 140 | + # ensure doesn't contains empty directory or file |
| 141 | + COUNT=$(find . -type d -empty | wc -l) |
| 142 | + if [[ $COUNT -ne 0 ]]; then |
| 143 | + find . -type d -empty |
| 144 | + echo "The package should not include empty directory, but get $COUNT" # TODO: && exit 1 |
| 145 | + fi |
| 146 | + cd - || exit |
| 147 | +done |
| 148 | + |
| 149 | +#### step5.2: start the server |
| 150 | +cd ./*hugegraph-incubating*"${RELEASE_VERSION}" || exit |
| 151 | +bin/init-store.sh && sleep 1 |
| 152 | +# kill the HugeGraphServer process by jps |
| 153 | +jps | grep HugeGraphServer | awk '{print $1}' | xargs kill -9 |
| 154 | +bin/start-hugegraph.sh && ls ../ |
| 155 | +cd - || exit |
| 156 | + |
| 157 | +#### step5.2: running toolchain |
| 158 | +cd ./*toolchain*"${RELEASE_VERSION}" || exit |
| 159 | +ls -lh |
| 160 | + |
| 161 | +##### 5.2.1 test loader |
| 162 | +cd ./*loader*"${RELEASE_VERSION}" || exit |
| 163 | +bin/hugegraph-loader.sh -f ./example/file/struct.json -s ./example/file/schema.groovy \ |
| 164 | + -g hugegraph || exit |
| 165 | +cd - || exit |
| 166 | + |
| 167 | +##### 5.2.2 test tool |
| 168 | +cd ./*tool*"${RELEASE_VERSION}" || exit |
| 169 | +bin/hugegraph gremlin-execute --script 'g.V().count()' || exit |
| 170 | +bin/hugegraph task-list || exit |
| 171 | +bin/hugegraph backup -t all --directory ./backup-test || exit |
| 172 | +cd - || exit |
| 173 | + |
| 174 | +##### 5.2.3 test hubble |
| 175 | +cd ./*hubble*"${RELEASE_VERSION}" || exit |
| 176 | +# TODO: add hubble doc & test it |
| 177 | +cat conf/hugegraph-hubble.properties |
| 178 | +bin/stop-hubble.sh && bin/start-hubble.sh |
| 179 | +cd - || exit |
| 180 | + |
| 181 | +echo "Finish validate, please check all steps manually again!" |
0 commit comments