Skip to content

Commit

Permalink
Use github action to run ci
Browse files Browse the repository at this point in the history
Change-Id: Ic77c4ee09f3375252b611c8f3e282a5be5499dcd
  • Loading branch information
Linary committed Jun 23, 2021
1 parent 0c51de5 commit 9b8441a
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 20 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: hugegraph ci

on:
push:
branches:
- master
- /^release-.*$/
- /^test-.*$/
pull_request:
branches:
- master
- /^release-.*$/
- /^test-.*$/

jobs:
build:
runs-on: ubuntu-16.04
env:
TRAVIS_DIR: hugegraph-dist/src/assembly/travis
strategy:
matrix:
BACKEND: [memory, cassandra, scylladb, mysql, hbase, rocksdb]
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: Compile
run: |
mvn compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
- name: Prepare env and service
run: |
$TRAVIS_DIR/install-backend.sh ${{ matrix.BACKEND }}
- name: Run test
run: |
mvn test -P core-test,${{ matrix.BACKEND }}
$TRAVIS_DIR/run-api-test.sh ${{ matrix.BACKEND }}
$TRAVIS_DIR/run-unit-test.sh ${{ matrix.BACKEND }}
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
file: target/site/jacoco/jacoco.xml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private static Vertex getVertex(HugeGraph graph,
throw new IllegalArgumentException(String.format(
"Invalid vertex id '%s'", id));
}
if (!vertex.label().equals(label)) {
if (label != null && !vertex.label().equals(label)) {
throw new IllegalArgumentException(String.format(
"The label of vertex '%s' is unmatched, users expect " +
"label '%s', actual label stored is '%s'",
Expand Down
6 changes: 6 additions & 0 deletions hugegraph-dist/src/assembly/travis/install-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -ev

if [[ $# -ne 1 ]]; then
echo "Must pass BACKEND type of hugegraph"
exit 1
fi

BACKEND=$1
TRAVIS_DIR=`dirname $0`

if [ ! -d $HOME/downloads ]; then
Expand Down
46 changes: 28 additions & 18 deletions hugegraph-dist/src/assembly/travis/install-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
set -ev

TRAVIS_DIR=`dirname $0`
#MYSQL_DOWNLOAD_ADDRESS="http://dev.MySQL.com/get/Downloads"
#MYSQL_VERSION="MySQL-5.7"
#MYSQL_PACKAGE="mysql-5.7.11-Linux-glibc2.5-x86_64"
#MYSQL_TAR="${MYSQL_PACKAGE}.tar.gz"

if [ -d /var/lib/mysql ]; then
# Reference from https://github.com/mozilla/treeherder/blob/master/bin/travis-setup.sh
# Using tmpfs for the MySQL data directory reduces travis test runtime by 6x
sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
sudo mv /var/lib/mysql /mnt/ramdisk
sudo ln -s /mnt/ramdisk/mysql /var/lib/mysql
sudo cp $TRAVIS_DIR/mysql.cnf /etc/mysql/conf.d/mysql.cnf
sudo service mysql restart
else
echo "Please install mysql firstly."
exit 1
fi

TRAVIS_DIR=`dirname $0`
CONF=hugegraph-test/src/main/resources/hugegraph.properties

MYSQL_USERNAME=root
MYSQL_PASSWORD=root

# Set MySQL configurations
sed -i "s/jdbc.username=.*/jdbc.username=$MYSQL_USERNAME/" $CONF
sed -i "s/jdbc.password=.*/jdbc.password=$MYSQL_PASSWORD/" $CONF

sudo /etc/init.d/mysql start

#mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASS }}

#if [ -d /var/lib/mysql ]; then
# # Reference from https://github.com/mozilla/treeherder/blob/master/bin/travis-setup.sh
# # Using tmpfs for the MySQL data directory reduces travis test runtime by 6x
# sudo mkdir /mnt/ramdisk
# sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
# sudo mv /var/lib/mysql /mnt/ramdisk
# sudo ln -s /mnt/ramdisk/mysql /var/lib/mysql
# sudo cp $TRAVIS_DIR/mysql.cnf /etc/mysql/conf.d/mysql.cnf
# sudo service mysql restart
#else
# echo "Please install mysql firstly."
# exit 1
#fi
4 changes: 3 additions & 1 deletion hugegraph-dist/src/assembly/travis/run-api-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -ev

BACKEND=$1

TRAVIS_DIR=`dirname $0`
VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
SERVER_DIR=hugegraph-$VERSION
Expand All @@ -26,7 +28,7 @@ authentication: {
config: {tokens: conf/rest-server.properties}
}" >> $GREMLIN_SERVER_CONF

$TRAVIS_DIR/start-server.sh $SERVER_DIR || (cat $SERVER_DIR/logs/hugegraph-server.log && exit 1)
$TRAVIS_DIR/start-server.sh $SERVER_DIR $BACKEND || (cat $SERVER_DIR/logs/hugegraph-server.log && exit 1)

# run api-test
mvn test -P api-test,$BACKEND || (cat $SERVER_DIR/logs/hugegraph-server.log && exit 1)
Expand Down
2 changes: 2 additions & 0 deletions hugegraph-dist/src/assembly/travis/run-unit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -ev

BACKEND=$1

if [[ "$BACKEND" == "memory" ]]; then
mvn test -P unit-test
fi
3 changes: 3 additions & 0 deletions hugegraph-dist/src/assembly/travis/start-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -ev
HOME_DIR=`pwd`
TRAVIS_DIR=`dirname $0`
BASE_DIR=$1
BACKEND=$2
BIN=$BASE_DIR/bin
CONF=$BASE_DIR/conf/hugegraph.properties
REST_CONF=$BASE_DIR/conf/rest-server.properties
Expand All @@ -15,6 +16,8 @@ declare -A backend_serializer_map=(["memory"]="text" ["cassandra"]="cassandra" \
["hbase"]="hbase" ["rocksdb"]="binary" \
["postgresql"]="postgresql")

echo ${BACKEND}

SERIALIZER=${backend_serializer_map[$BACKEND]}

# Set backend and serializer
Expand Down

0 comments on commit 9b8441a

Please sign in to comment.