Skip to content
Permalink
Browse files
refact: adopt backend for ant-ui & improve configs (#348)
also enable the ci/cd & release steps
  • Loading branch information
imbajin committed Feb 16, 2022
1 parent c1b94e0 commit 8fa714ab2b9bf85efb7a21f541d9d129416aae18
Showing 29 changed files with 264 additions and 121 deletions.
@@ -0,0 +1,88 @@
name: hugegraph-hubble ci

on:
push:
branches:
- master
- /^release-.*$/
- /^test-.*$/
- /^v[0-9]\..*$/
pull_request:
branches:
- master
- /^release-.*$/
- /^test-.*$/
- /^v[0-9]\..*$/

env:
TRAVIS_DIR: hubble-dist/assembly/travis
SERVER_VERSION: 0.12.0

jobs:
hubble-ci:
runs-on: ubuntu-20.04
steps:
- name: Install JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

# we also should cache python & yarn & downloads to avoid useless work
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Get Yarn path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Ceche Yarn packages
uses: actions/cache@v2
# use id to check `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Ceche Python packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Compile
run: |
mvn clean compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
- name: Prepare env and service
run: |
sudo pip install -r ${TRAVIS_DIR}/requirements.txt
$TRAVIS_DIR/install-hugegraph.sh $SERVER_VERSION
- name: Unit test
run: mvn test -P unit-test

- name: API test
env:
CI: false
run: |
$TRAVIS_DIR/run-api-test.sh
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: target/site/jacoco/*.xml
@@ -0,0 +1,39 @@
name: release maven package

on:
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Install JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.NEXUS_USERNAME }}
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
server_id: sonatype-nexus-staging
maven_profiles: "release"
maven_args: >
-Dmaven.test.skip=true
@@ -34,6 +34,7 @@ build/

### VS Code ###
.vscode/
/hubble-fe/.history/

# dependencies
/hubble-fe/node_modules
@@ -92,6 +92,14 @@
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
</exclusion>
<exclusion>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
</exclusion>
</exclusions>
</dependency>

@@ -58,15 +58,15 @@ public static synchronized HubbleOptions instance() {

public static final ConfigOption<String> SERVER_HOST =
new ConfigOption<>(
"server.host",
"hubble.host",
"The host of hugegraph-hubble server.",
disallowEmpty(),
"localhost"
);

public static final ConfigOption<Integer> SERVER_PORT =
new ConfigOption<>(
"server.port",
"hubble.port",
"The port of hugegraph-hubble server.",
rangeInt(1, 65535),
8088
@@ -104,10 +104,7 @@ public static synchronized HubbleOptions instance() {
if (CollectionUtils.isEmpty(input)) {
return false;
}
if (input.contains(-1) && input.size() > 1) {
return false;
}
return true;
return !input.contains(-1) || input.size() <= 1;
},
-1
);
@@ -50,9 +50,6 @@ public void testMerge() throws InterruptedException {
Assert.assertEquals(oldEntity.getTimeout(), entity.getTimeout());
Assert.assertEquals(newEntity.getUsername(), entity.getUsername());
Assert.assertEquals(newEntity.getPassword(), entity.getPassword());
Assert.assertEquals(newEntity.getEnabled(), entity.getEnabled());
Assert.assertEquals(newEntity.getDisableReason(),
entity.getDisableReason());
Assert.assertEquals(oldEntity.getCreateTime(), entity.getCreateTime());
}
}
@@ -4,11 +4,11 @@
import sys

import requests
from imp import reload
from assertpy import assert_that
from behave import *

reload(sys)
sys.setdefaultencoding('utf8')
use_step_matcher("re")


@@ -15,28 +15,29 @@ function read_property() {
# file path
local file_name=$1
# replace "." to "\."
local property_name=`echo $2 | sed 's/\./\\\./g'`
cat ${file_name} | sed -n -e "s/^[ ]*//g;/^#/d;s/^$property_name=//p" | tail -1
local property_name=$(echo "$2" | sed 's/\./\\\./g')
cat "${file_name}" | sed -n -e "s/^[ ]*//g;/^#/d;s/^$property_name=//p" | tail -1
}

# wait_for_startup friendly_name host port timeout_s
function wait_for_startup() {
local server_url=$1
local timeout_s=$2
local now_s=`date '+%s'`
local stop_s=$(( $now_s + $timeout_s ))
local now_s=$(date '+%s')
local stop_s=$(( now_s + timeout_s ))
local status=0

while [[ ${now_s} -le ${stop_s} ]]; do
echo -n .
status=`curl -o /dev/null -s -w %{http_code} ${server_url}`
status=$(curl -o /dev/null -s -w %{http_code} "${server_url}")
if [[ ${status} -eq 200 ]]; then
echo "OK"
return 0
fi
sleep 2
now_s=`date '+%s'`
now_s=$(date '+%s')
done

echo "timed out" >&2
echo "timed out with http status $status" >&2
return 1
}
@@ -3,17 +3,17 @@
export LANG=zh_CN.UTF-8
set -e

HOME_PATH=`dirname $0`
HOME_PATH=`cd ${HOME_PATH}/.. && pwd`
cd ${HOME_PATH}
HOME_PATH=$(dirname "$0")
HOME_PATH=$(cd "${HOME_PATH}"/.. && pwd)
cd "${HOME_PATH}"

BIN_PATH=${HOME_PATH}/bin
CONF_PATH=${HOME_PATH}/conf
LIB_PATH=${HOME_PATH}/lib
LOG_PATH=${HOME_PATH}/logs
PID_FILE=${BIN_PATH}/pid

. ${BIN_PATH}/common_functions
. "${BIN_PATH}"/common_functions

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

if [[ ! -d ${LOG_PATH} ]]; then
mkdir ${LOG_PATH}
mkdir "${LOG_PATH}"
fi

class_path="."
for jar in `ls ${LIB_PATH}/*.jar`; do
for jar in "${LIB_PATH}"/*.jar; do
[[ -e "$jar" ]] || break
class_path=${class_path}:${jar}
done

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

if [[ -f ${PID_FILE} ]] ; then
pid=`cat ${PID_FILE}`
if kill -0 ${pid} > /dev/null 2>&1; then
pid=$(cat "${PID_FILE}")
if kill -0 "${pid}" > /dev/null 2>&1; then
echo "HugeGraphHubble is running as process ${pid}, please stop it first!"
exit 1
else
rm ${PID_FILE}
rm "${PID_FILE}"
fi
fi

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

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

# wait hubble start
timeout_s=30
server_host=`read_property ${CONF_PATH}/hugegraph-hubble.properties server.host`
server_port=`read_property ${CONF_PATH}/hugegraph-hubble.properties server.port`
server_host=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.host)
server_port=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.port)
server_url="http://${server_host}:${server_port}/actuator/health"

wait_for_startup ${server_url} ${timeout_s} || {
cat ${log}
wait_for_startup "${server_url}" ${timeout_s} || {
cat "${log}"
exit 1
}
echo "logging to ${log}"
echo "logging to ${log}, please check it"
@@ -1,19 +1,19 @@
#!/bin/bash

HOME_PATH=`dirname $0`
HOME_PATH=`cd ${HOME_PATH}/.. && pwd`
HOME_PATH=$(dirname $0)
HOME_PATH=$(cd "${HOME_PATH}"/.. && pwd)
BIN_PATH=${HOME_PATH}/bin
PID_FILE=${BIN_PATH}/pid

if [[ -f ${PID_FILE} ]]; then
pid=`cat ${PID_FILE}`
if kill -0 ${pid} > /dev/null 2>&1; then
kill -9 ${pid}
pid=$(cat "${PID_FILE}")
if kill -0 "${pid}" > /dev/null 2>&1; then
kill -9 "${pid}"
echo "stopped HugeGraphHubble"
else
echo "process not exist"
echo "process ${pid} not exist"
fi
rm ${PID_FILE}
rm "${PID_FILE}"
else
echo "HugeGraphHubble not running"
fi
Binary file not shown.
@@ -1,5 +1,5 @@
server.host=localhost
server.port=8088
hubble.host=0.0.0.0
hubble.port=8088

gremlin.suffix_limit=250
gremlin.vertex_degree_limit=100
Binary file not shown.
@@ -2,10 +2,10 @@

set -ev

TRAVIS_DIR=`dirname $0`
TRAVIS_DIR=$(dirname "$0")

cd hubble-be
mvn jacoco:dump@pull-test-data -Dapp.host=localhost -Dapp.port=36320 -Dskip.dump=false
cd ../
java -jar ${TRAVIS_DIR}/jacococli.jar report hubble-be/target/jacoco-it.exec \
java -jar "${TRAVIS_DIR}"/jacococli.jar report hubble-be/target/jacoco-it.exec \
--classfiles hubble-be/target/classes/com/baidu/hugegraph --xml report.xml
@@ -10,4 +10,4 @@ fi
VERSION=$1
HUGEGRAPH_LINK="https://github.com/hugegraph/hugegraph/releases/download/v${VERSION}/hugegraph-${VERSION}.tar.gz"

wget ${HUGEGRAPH_LINK} || exit 1
wget "${HUGEGRAPH_LINK}" || exit 1

0 comments on commit 8fa714a

Please sign in to comment.