Skip to content

Commit de8781e

Browse files
contrueCTimbajin
andauthored
chore(ci): optimize rerun workflow and add macOS RocksDB coverage (#3010)
- Resolve Travis helper directory to an absolute path - Use the script directory directly for JaCoCo agent lookup - Avoid nesting absolute paths under the repository root --------- Co-authored-by: imbajin <jin@apache.org>
1 parent 06c52e4 commit de8781e

5 files changed

Lines changed: 196 additions & 30 deletions

File tree

.github/workflows/rerun-ci.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818

1919
jobs:
2020
decide-rerun-action:
21+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
2122
runs-on: ubuntu-latest
2223
outputs:
2324
action: ${{ steps.decision.outputs.action }}
@@ -28,19 +29,16 @@ jobs:
2829
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
2930
RUN_ID: ${{ github.event.workflow_run.id }}
3031
RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
31-
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
3232
EVENT_NAME: ${{ github.event.workflow_run.event }}
3333
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
3434
run: |
3535
set -euo pipefail
3636
3737
action="skip"
38-
reason="non-failure"
38+
reason="unsupported event: $EVENT_NAME"
3939
40-
if [[ "$CONCLUSION" == "failure" ]]; then
41-
if [[ "$EVENT_NAME" != "push" && "$EVENT_NAME" != "pull_request" ]]; then
42-
reason="unsupported event: $EVENT_NAME"
43-
elif (( RUN_ATTEMPT > MAX_RERUNS )); then
40+
if [[ "$EVENT_NAME" == "push" || "$EVENT_NAME" == "pull_request" ]]; then
41+
if (( RUN_ATTEMPT > MAX_RERUNS )); then
4442
reason="retry limit reached"
4543
else
4644
action="rerun"

.github/workflows/server-ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,76 @@ jobs:
100100
with:
101101
token: ${{ secrets.CODECOV_TOKEN }}
102102
file: ${{ env.REPORT_DIR }}/*.xml
103+
104+
build-server-macos-rocksdb:
105+
runs-on: ${{ matrix.os }}
106+
strategy:
107+
fail-fast: false
108+
matrix:
109+
include:
110+
- os: macos-15-intel
111+
server_java_options: ''
112+
- os: macos-15
113+
server_java_options: '-Xms512m -Xmx2g'
114+
env:
115+
USE_STAGE: 'false' # Whether to include the stage repository.
116+
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
117+
REPORT_DIR: target/site/jacoco
118+
BACKEND: rocksdb
119+
JAVA_VERSION: '11'
120+
SERVER_JAVA_OPTIONS: ${{ matrix.server_java_options }}
121+
122+
steps:
123+
- name: Checkout
124+
uses: actions/checkout@v4
125+
with:
126+
fetch-depth: 5
127+
128+
- name: Install Java ${{ env.JAVA_VERSION }}
129+
uses: actions/setup-java@v4
130+
with:
131+
java-version: ${{ env.JAVA_VERSION }}
132+
distribution: 'zulu'
133+
134+
- name: Cache Maven packages
135+
uses: actions/cache@v4
136+
with:
137+
path: ~/.m2
138+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
139+
restore-keys: ${{ runner.os }}-m2
140+
141+
- name: Use staged maven repo settings
142+
if: ${{ env.USE_STAGE == 'true' }}
143+
run: |
144+
cp $HOME/.m2/settings.xml /tmp/settings.xml
145+
cp -vf .github/configs/settings.xml $HOME/.m2/settings.xml && cat $HOME/.m2/settings.xml
146+
147+
- name: Compile
148+
run: |
149+
mvn clean compile -pl hugegraph-server/hugegraph-test -am -U -Dmaven.javadoc.skip=true -ntp
150+
151+
- name: Run RocksDB core test
152+
run: |
153+
$TRAVIS_DIR/run-core-test.sh $BACKEND
154+
155+
- name: Run RocksDB API test
156+
run: |
157+
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
158+
159+
- name: Show server log on failure
160+
if: failure()
161+
run: |
162+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
163+
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
164+
if [ -f "$SERVER_DIR/logs/hugegraph-server.log" ]; then
165+
tail -n 200 "$SERVER_DIR/logs/hugegraph-server.log"
166+
fi
167+
168+
- name: Stop RocksDB server
169+
if: always()
170+
run: |
171+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
172+
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
173+
if [ -f "$SERVER_DIR/bin/pid" ]; then
174+
$TRAVIS_DIR/stop-server.sh $SERVER_DIR || true
175+
fi

hugegraph-server/hugegraph-dist/src/assembly/travis/build-report.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,53 @@ BACKEND=$1
2121
JACOCO_PORT=$2
2222
JACOCO_REPORT_FILE=$3
2323

24+
TRAVIS_DIR=$(cd "$(dirname "$0")" && pwd)
25+
REPO_ROOT=$(cd "$TRAVIS_DIR/../../../../.." && pwd)
26+
27+
function command_available() {
28+
local cmd=$1
29+
[[ -x "$(command -v "$cmd")" ]]
30+
}
31+
32+
function download_to_dir() {
33+
local dir=$1
34+
local url=$2
35+
local file="$dir/$(basename "$url")"
36+
37+
mkdir -p "$dir"
38+
if command_available "curl"; then
39+
curl -fL "$url" -o "$file"
40+
elif command_available "wget"; then
41+
wget -P "$dir" "$url"
42+
else
43+
echo "Required curl or wget but they are unavailable"
44+
exit 1
45+
fi
46+
}
47+
2448
OPTION_CLASS_FILES_BACKEND="--classfiles hugegraph-$BACKEND/target/classes/org/apache/hugegraph"
2549
if [ "$BACKEND" == "memory" ]; then
2650
# hugegraph-memory is the same as hugegraph-core
2751
OPTION_CLASS_FILES_BACKEND=""
2852
fi
2953

30-
cd hugegraph-server/hugegraph-test
54+
case "$JACOCO_REPORT_FILE" in
55+
/*) REPORT_FILE=$JACOCO_REPORT_FILE ;;
56+
*) REPORT_FILE="$REPO_ROOT/$JACOCO_REPORT_FILE" ;;
57+
esac
58+
mkdir -p "$(dirname "$REPORT_FILE")"
59+
60+
cd "$REPO_ROOT/hugegraph-server/hugegraph-test"
3161
mvn jacoco:dump@pull-test-data -Dapp.host=localhost -Dapp.port=$JACOCO_PORT -Dskip.dump=false
32-
cd ../
62+
cd "$REPO_ROOT/hugegraph-server"
3363

3464
if [[ ! -e "${TRAVIS_DIR}/jacococli.jar" ]]; then
35-
wget -P "${TRAVIS_DIR}" https://github.com/apache/hugegraph-doc/raw/binary-1.0/dist/server/jacococli.jar
65+
download_to_dir "${TRAVIS_DIR}" \
66+
"https://github.com/apache/hugegraph-doc/raw/binary-1.0/dist/server/jacococli.jar"
3667
fi
3768

3869
java -jar $TRAVIS_DIR/jacococli.jar report hugegraph-test/target/jacoco-it.exec \
3970
--classfiles hugegraph-dist/target/classes/org/apache/hugegraph \
4071
--classfiles hugegraph-api/target/classes/org/apache/hugegraph \
4172
--classfiles hugegraph-core/target/classes/org/apache/hugegraph \
42-
${OPTION_CLASS_FILES_BACKEND} --xml "${JACOCO_REPORT_FILE}"
73+
${OPTION_CLASS_FILES_BACKEND} --xml "${REPORT_FILE}"

hugegraph-server/hugegraph-dist/src/assembly/travis/run-api-test.sh

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,42 @@ BACKEND=$1
2121
REPORT_DIR=$2
2222
REPORT_FILE=$REPORT_DIR/jacoco-api-test-for-raft.xml
2323

24-
TRAVIS_DIR=$(dirname $0)
24+
TRAVIS_DIR=$(cd "$(dirname "$0")" && pwd)
25+
REPO_ROOT=$(cd "$TRAVIS_DIR/../../../../.." && pwd)
26+
27+
function command_available() {
28+
local cmd=$1
29+
[[ -x "$(command -v "$cmd")" ]]
30+
}
31+
32+
function sed_in_place() {
33+
local expression=$1
34+
local file=$2
35+
36+
case "$(uname)" in
37+
Darwin) sed -i '' "$expression" "$file" ;;
38+
*) sed -i "$expression" "$file" ;;
39+
esac
40+
}
41+
42+
function download_to_dir() {
43+
local dir=$1
44+
local url=$2
45+
local file="$dir/$(basename "$url")"
46+
47+
mkdir -p "$dir"
48+
if command_available "curl"; then
49+
curl -fL "$url" -o "$file"
50+
elif command_available "wget"; then
51+
wget -P "$dir" "$url"
52+
else
53+
echo "Required curl or wget but they are unavailable"
54+
exit 1
55+
fi
56+
}
57+
58+
cd "$REPO_ROOT"
59+
2560
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
2661
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
2762
CONF=$SERVER_DIR/conf/graphs/hugegraph.properties
@@ -32,20 +67,22 @@ JACOCO_PORT=36320
3267
mvn package -Dmaven.test.skip=true -ntp
3368

3469
# add mysql dependency
35-
wget -P $SERVER_DIR/lib/ https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar
70+
download_to_dir "$SERVER_DIR/lib/" \
71+
"https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar"
3672

3773
if [[ ! -e "$SERVER_DIR/lib/ikanalyzer-2012_u6.jar" ]]; then
38-
wget -P $SERVER_DIR/lib/ https://raw.githubusercontent.com/apache/hugegraph-doc/ik_binary/dist/server/ikanalyzer-2012_u6.jar
74+
download_to_dir "$SERVER_DIR/lib/" \
75+
"https://raw.githubusercontent.com/apache/hugegraph-doc/ik_binary/dist/server/ikanalyzer-2012_u6.jar"
3976
fi
4077

4178
# config rest-server
42-
sed -i '/^#*auth\.authenticator=/d' $REST_SERVER_CONF
43-
sed -i '/^#*auth\.admin_token=/d' $REST_SERVER_CONF
79+
sed_in_place '/^#*auth\.authenticator=/d' "$REST_SERVER_CONF"
80+
sed_in_place '/^#*auth\.admin_token=/d' "$REST_SERVER_CONF"
4481
echo "auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator" >> $REST_SERVER_CONF
4582
echo "auth.admin_token=pa" >> $REST_SERVER_CONF
4683

4784
# config hugegraph.properties
48-
sed -i 's/gremlin.graph=.*/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/' $CONF
85+
sed_in_place 's/gremlin.graph=.*/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/' "$CONF"
4986

5087
# config gremlin-server
5188
echo "

hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
#
1818
set -ev
1919

20-
HOME_DIR=$(pwd)
21-
TRAVIS_DIR=$(dirname $0)
20+
TRAVIS_DIR=$(cd "$(dirname "$0")" && pwd)
2221
BASE_DIR=$1
2322
BACKEND=$2
2423
JACOCO_PORT=$3
2524

26-
JACOCO_DIR=${HOME_DIR}/${TRAVIS_DIR}
25+
JACOCO_DIR=${TRAVIS_DIR}
2726
JACOCO_JAR=${JACOCO_DIR}/jacocoagent.jar
2827

2928
BIN=$BASE_DIR/bin
@@ -33,27 +32,46 @@ GREMLIN_CONF=$BASE_DIR/conf/gremlin-server.yaml
3332

3433
. "${BIN}"/util.sh
3534

36-
declare -A backend_serializer_map=(["memory"]="text" \
37-
["hbase"]="hbase" \
38-
["rocksdb"]="binary" \
39-
["hstore"]="binary")
35+
function sed_in_place() {
36+
local expression=$1
37+
local file=$2
4038

41-
SERIALIZER=${backend_serializer_map[$BACKEND]}
39+
case "$(uname)" in
40+
Darwin) sed -i '' "$expression" "$file" ;;
41+
*) sed -i "$expression" "$file" ;;
42+
esac
43+
}
44+
45+
case "$BACKEND" in
46+
memory)
47+
SERIALIZER=text
48+
;;
49+
hbase)
50+
SERIALIZER=hbase
51+
;;
52+
rocksdb|hstore)
53+
SERIALIZER=binary
54+
;;
55+
*)
56+
echo "Unsupported backend: $BACKEND"
57+
exit 1
58+
;;
59+
esac
4260

4361
# Set backend and serializer
44-
sed -i "s/backend=.*/backend=$BACKEND/" $CONF
45-
sed -i "s/serializer=.*/serializer=$SERIALIZER/" $CONF
62+
write_property "$CONF" "backend" "$BACKEND"
63+
write_property "$CONF" "serializer" "$SERIALIZER"
4664

4765
# Set timeout for hbase
4866
if [ "$BACKEND" == "hbase" ]; then
49-
sed -i '$arestserver.request_timeout=200' $REST_CONF
50-
sed -i '$agremlinserver.timeout=200' $REST_CONF
51-
sed -i 's/evaluationTimeout.*/evaluationTimeout: 200000/' $GREMLIN_CONF
67+
echo "restserver.request_timeout=200" >> $REST_CONF
68+
echo "gremlinserver.timeout=200" >> $REST_CONF
69+
sed_in_place 's/evaluationTimeout.*/evaluationTimeout: 200000/' "$GREMLIN_CONF"
5270
fi
5371

5472
# Set usePD=true for hstore
5573
if [ "$BACKEND" == "hstore" ]; then
56-
sed -i '$ausePD=true' $REST_CONF
74+
echo "usePD=true" >> $REST_CONF
5775
fi
5876

5977
# Append schema.sync_deletion=true to config file
@@ -67,5 +85,14 @@ if [ -n "$JACOCO_PORT" ]; then
6785
JACOCO_OPTION="-javaagent:${JACOCO_JAR}=includes=*,port=${JACOCO_PORT},destfile=jacoco-it.exec,output=tcpserver"
6886
fi
6987

88+
SERVER_JAVA_OPTIONS="${SERVER_JAVA_OPTIONS:-}"
89+
if [ -n "$SERVER_JAVA_OPTIONS" ]; then
90+
if [ -n "$JACOCO_OPTION" ]; then
91+
JACOCO_OPTION="${JACOCO_OPTION} ${SERVER_JAVA_OPTIONS}"
92+
else
93+
JACOCO_OPTION="${SERVER_JAVA_OPTIONS}"
94+
fi
95+
fi
96+
7097
echo -e "pa" | $BIN/init-store.sh
7198
$BIN/start-hugegraph.sh -j "$JACOCO_OPTION" -t 60

0 commit comments

Comments
 (0)