Skip to content

Commit 958193d

Browse files
authored
chore: support validate apache release automatically (#2076)
1 parent 3427625 commit 958193d

File tree

2 files changed

+239
-0
lines changed

2 files changed

+239
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Validate Apache Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
required: true
8+
default: '1.0.0'
9+
deploy:
10+
required: true
11+
default: false
12+
type: boolean
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
env:
18+
SCRIPT_PATH: hugegraph-dist/scripts/
19+
steps:
20+
- name: Checkout source
21+
uses: actions/checkout@v3
22+
- name: Install JDK ${{ matrix.java_version }}
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: ${{ matrix.java_version }}
26+
distribution: 'adopt'
27+
- name: Cache Maven packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.m2
31+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: ${{ runner.os }}-m2
33+
- name: Get Yarn path
34+
id: yarn-cache-dir-path
35+
run: echo "::set-output name=dir::$(yarn cache dir)"
36+
- name: Cache Yarn packages
37+
uses: actions/cache@v3
38+
# use id to check `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
39+
id: yarn-cache
40+
with:
41+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
42+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-yarn-
45+
46+
47+
# TODO: do we need svn & gpg environment?
48+
- name: Test Building Source & Running
49+
run: |
50+
bash $SCRIPT_PATH/validate-release.sh ${{ inputs.release_version }} ${{ matrix.java_version }}
51+
- name: Test Running Binary
52+
run: |
53+
echo "TODO: separate script to test binary"
54+
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
java_version: [ '8', '11' ]
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
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

Comments
 (0)