Skip to content
This repository was archived by the owner on Dec 28, 2025. It is now read-only.

Commit 8fa714a

Browse files
authored
refact: adopt backend for ant-ui & improve configs (#348)
also enable the ci/cd & release steps
1 parent c1b94e0 commit 8fa714a

29 files changed

+264
-121
lines changed

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: hugegraph-hubble ci
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- /^release-.*$/
8+
- /^test-.*$/
9+
- /^v[0-9]\..*$/
10+
pull_request:
11+
branches:
12+
- master
13+
- /^release-.*$/
14+
- /^test-.*$/
15+
- /^v[0-9]\..*$/
16+
17+
env:
18+
TRAVIS_DIR: hubble-dist/assembly/travis
19+
SERVER_VERSION: 0.12.0
20+
21+
jobs:
22+
hubble-ci:
23+
runs-on: ubuntu-20.04
24+
steps:
25+
- name: Install JDK 8
26+
uses: actions/setup-java@v2
27+
with:
28+
java-version: '8'
29+
distribution: 'adopt'
30+
31+
# we also should cache python & yarn & downloads to avoid useless work
32+
- name: Cache Maven packages
33+
uses: actions/cache@v2
34+
with:
35+
path: ~/.m2/repository
36+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
37+
restore-keys: |
38+
${{ runner.os }}-maven-
39+
40+
- name: Get Yarn path
41+
id: yarn-cache-dir-path
42+
run: echo "::set-output name=dir::$(yarn cache dir)"
43+
44+
- name: Ceche Yarn packages
45+
uses: actions/cache@v2
46+
# use id to check `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
47+
id: yarn-cache
48+
with:
49+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
50+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-yarn-
53+
54+
- name: Ceche Python packages
55+
uses: actions/cache@v2
56+
with:
57+
path: ~/.cache/pip
58+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
59+
restore-keys: |
60+
${{ runner.os }}-pip-
61+
62+
- name: Checkout
63+
uses: actions/checkout@v2
64+
with:
65+
fetch-depth: 2
66+
67+
- name: Compile
68+
run: |
69+
mvn clean compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
70+
71+
- name: Prepare env and service
72+
run: |
73+
sudo pip install -r ${TRAVIS_DIR}/requirements.txt
74+
$TRAVIS_DIR/install-hugegraph.sh $SERVER_VERSION
75+
76+
- name: Unit test
77+
run: mvn test -P unit-test
78+
79+
- name: API test
80+
env:
81+
CI: false
82+
run: |
83+
$TRAVIS_DIR/run-api-test.sh
84+
85+
- name: Upload coverage to Codecov
86+
uses: codecov/codecov-action@v1
87+
with:
88+
file: target/site/jacoco/*.xml

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: release maven package
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: Install JDK 8
12+
uses: actions/setup-java@v2
13+
with:
14+
java-version: '8'
15+
distribution: 'adopt'
16+
17+
- name: Cache Maven packages
18+
uses: actions/cache@v2
19+
with:
20+
path: ~/.m2
21+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
22+
restore-keys: ${{ runner.os }}-m2
23+
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 2
28+
29+
- name: Release Maven package
30+
uses: samuelmeuli/action-maven-publish@v1
31+
with:
32+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
34+
nexus_username: ${{ secrets.NEXUS_USERNAME }}
35+
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
36+
server_id: sonatype-nexus-staging
37+
maven_profiles: "release"
38+
maven_args: >
39+
-Dmaven.test.skip=true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ build/
3434

3535
### VS Code ###
3636
.vscode/
37+
/hubble-fe/.history/
3738

3839
# dependencies
3940
/hubble-fe/node_modules

hubble-be/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@
9292
<artifactId>javassist</artifactId>
9393
<groupId>org.javassist</groupId>
9494
</exclusion>
95+
<exclusion>
96+
<groupId>org.eclipse.jetty</groupId>
97+
<artifactId>jetty-runner</artifactId>
98+
</exclusion>
99+
<exclusion>
100+
<groupId>com.oracle</groupId>
101+
<artifactId>ojdbc8</artifactId>
102+
</exclusion>
95103
</exclusions>
96104
</dependency>
97105

hubble-be/src/main/java/com/baidu/hugegraph/options/HubbleOptions.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public static synchronized HubbleOptions instance() {
5858

5959
public static final ConfigOption<String> SERVER_HOST =
6060
new ConfigOption<>(
61-
"server.host",
61+
"hubble.host",
6262
"The host of hugegraph-hubble server.",
6363
disallowEmpty(),
6464
"localhost"
6565
);
6666

6767
public static final ConfigOption<Integer> SERVER_PORT =
6868
new ConfigOption<>(
69-
"server.port",
69+
"hubble.port",
7070
"The port of hugegraph-hubble server.",
7171
rangeInt(1, 65535),
7272
8088
@@ -104,10 +104,7 @@ public static synchronized HubbleOptions instance() {
104104
if (CollectionUtils.isEmpty(input)) {
105105
return false;
106106
}
107-
if (input.contains(-1) && input.size() > 1) {
108-
return false;
109-
}
110-
return true;
107+
return !input.contains(-1) || input.size() <= 1;
111108
},
112109
-1
113110
);

hubble-be/src/test/java/com/baidu/hugegraph/unit/EntityUtilTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ public void testMerge() throws InterruptedException {
5050
Assert.assertEquals(oldEntity.getTimeout(), entity.getTimeout());
5151
Assert.assertEquals(newEntity.getUsername(), entity.getUsername());
5252
Assert.assertEquals(newEntity.getPassword(), entity.getPassword());
53-
Assert.assertEquals(newEntity.getEnabled(), entity.getEnabled());
54-
Assert.assertEquals(newEntity.getDisableReason(),
55-
entity.getDisableReason());
5653
Assert.assertEquals(oldEntity.getCreateTime(), entity.getCreateTime());
5754
}
5855
}

hubble-be/src/test/python/steps/check_server_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import sys
55

66
import requests
7+
from imp import reload
78
from assertpy import assert_that
89
from behave import *
910

1011
reload(sys)
11-
sys.setdefaultencoding('utf8')
1212
use_step_matcher("re")
1313

1414

hubble-dist/assembly/static/bin/common_functions

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,29 @@ function read_property() {
1515
# file path
1616
local file_name=$1
1717
# replace "." to "\."
18-
local property_name=`echo $2 | sed 's/\./\\\./g'`
19-
cat ${file_name} | sed -n -e "s/^[ ]*//g;/^#/d;s/^$property_name=//p" | tail -1
18+
local property_name=$(echo "$2" | sed 's/\./\\\./g')
19+
cat "${file_name}" | sed -n -e "s/^[ ]*//g;/^#/d;s/^$property_name=//p" | tail -1
2020
}
2121

2222
# wait_for_startup friendly_name host port timeout_s
2323
function wait_for_startup() {
2424
local server_url=$1
2525
local timeout_s=$2
26-
local now_s=`date '+%s'`
27-
local stop_s=$(( $now_s + $timeout_s ))
26+
local now_s=$(date '+%s')
27+
local stop_s=$(( now_s + timeout_s ))
28+
local status=0
2829

2930
while [[ ${now_s} -le ${stop_s} ]]; do
3031
echo -n .
31-
status=`curl -o /dev/null -s -w %{http_code} ${server_url}`
32+
status=$(curl -o /dev/null -s -w %{http_code} "${server_url}")
3233
if [[ ${status} -eq 200 ]]; then
3334
echo "OK"
3435
return 0
3536
fi
3637
sleep 2
37-
now_s=`date '+%s'`
38+
now_s=$(date '+%s')
3839
done
3940

40-
echo "timed out" >&2
41+
echo "timed out with http status $status" >&2
4142
return 1
4243
}

hubble-dist/assembly/static/bin/start-hubble.sh

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
export LANG=zh_CN.UTF-8
44
set -e
55

6-
HOME_PATH=`dirname $0`
7-
HOME_PATH=`cd ${HOME_PATH}/.. && pwd`
8-
cd ${HOME_PATH}
6+
HOME_PATH=$(dirname "$0")
7+
HOME_PATH=$(cd "${HOME_PATH}"/.. && pwd)
8+
cd "${HOME_PATH}"
99

1010
BIN_PATH=${HOME_PATH}/bin
1111
CONF_PATH=${HOME_PATH}/conf
1212
LIB_PATH=${HOME_PATH}/lib
1313
LOG_PATH=${HOME_PATH}/logs
1414
PID_FILE=${BIN_PATH}/pid
1515

16-
. ${BIN_PATH}/common_functions
16+
. "${BIN_PATH}"/common_functions
1717

1818
print_usage() {
1919
echo " usage: start-hubble.sh [options]"
@@ -25,11 +25,12 @@ print_usage() {
2525
java_env_check
2626

2727
if [[ ! -d ${LOG_PATH} ]]; then
28-
mkdir ${LOG_PATH}
28+
mkdir "${LOG_PATH}"
2929
fi
3030

3131
class_path="."
32-
for jar in `ls ${LIB_PATH}/*.jar`; do
32+
for jar in "${LIB_PATH}"/*.jar; do
33+
[[ -e "$jar" ]] || break
3334
class_path=${class_path}:${jar}
3435
done
3536

@@ -48,32 +49,32 @@ while [[ $# -gt 0 ]]; do
4849
done
4950

5051
if [[ -f ${PID_FILE} ]] ; then
51-
pid=`cat ${PID_FILE}`
52-
if kill -0 ${pid} > /dev/null 2>&1; then
52+
pid=$(cat "${PID_FILE}")
53+
if kill -0 "${pid}" > /dev/null 2>&1; then
5354
echo "HugeGraphHubble is running as process ${pid}, please stop it first!"
5455
exit 1
5556
else
56-
rm ${PID_FILE}
57+
rm "${PID_FILE}"
5758
fi
5859
fi
5960

6061
main_class="com.baidu.hugegraph.HugeGraphHubble"
6162
args=${CONF_PATH}/hugegraph-hubble.properties
6263
log=${LOG_PATH}/hugegraph-hubble.log
6364

64-
echo -n "starting HugeGraphHubble"
65-
nohup nice -n 0 java -server ${java_opts} -Dhubble.home.path=${HOME_PATH} -cp ${class_path} ${main_class} ${args} > ${log} 2>&1 < /dev/null &
65+
echo -n "starting HugeGraphHubble "
66+
nohup nice -n 0 java -server "${java_opts}" -Dhubble.home.path="${HOME_PATH}" -cp "${class_path}" ${main_class} "${args}" > "${log}" 2>&1 < /dev/null &
6667
pid=$!
67-
echo ${pid} > ${PID_FILE}
68+
echo ${pid} > "${PID_FILE}"
6869

6970
# wait hubble start
7071
timeout_s=30
71-
server_host=`read_property ${CONF_PATH}/hugegraph-hubble.properties server.host`
72-
server_port=`read_property ${CONF_PATH}/hugegraph-hubble.properties server.port`
72+
server_host=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.host)
73+
server_port=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.port)
7374
server_url="http://${server_host}:${server_port}/actuator/health"
7475

75-
wait_for_startup ${server_url} ${timeout_s} || {
76-
cat ${log}
76+
wait_for_startup "${server_url}" ${timeout_s} || {
77+
cat "${log}"
7778
exit 1
7879
}
79-
echo "logging to ${log}"
80+
echo "logging to ${log}, please check it"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/bin/bash
22

3-
HOME_PATH=`dirname $0`
4-
HOME_PATH=`cd ${HOME_PATH}/.. && pwd`
3+
HOME_PATH=$(dirname $0)
4+
HOME_PATH=$(cd "${HOME_PATH}"/.. && pwd)
55
BIN_PATH=${HOME_PATH}/bin
66
PID_FILE=${BIN_PATH}/pid
77

88
if [[ -f ${PID_FILE} ]]; then
9-
pid=`cat ${PID_FILE}`
10-
if kill -0 ${pid} > /dev/null 2>&1; then
11-
kill -9 ${pid}
9+
pid=$(cat "${PID_FILE}")
10+
if kill -0 "${pid}" > /dev/null 2>&1; then
11+
kill -9 "${pid}"
1212
echo "stopped HugeGraphHubble"
1313
else
14-
echo "process not exist"
14+
echo "process ${pid} not exist"
1515
fi
16-
rm ${PID_FILE}
16+
rm "${PID_FILE}"
1717
else
1818
echo "HugeGraphHubble not running"
1919
fi

0 commit comments

Comments
 (0)