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 24, 2021
1 parent 0c51de5 commit af637db
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 5 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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:
fail-fast: false
matrix:
BACKEND: [memory, cassandra, scylladb, 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
2 changes: 2 additions & 0 deletions hugegraph-dist/src/assembly/travis/build-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -ev

BACKEND=$1

OPTION_CLASS_FILES_BACKEND="--classfiles hugegraph-$BACKEND/target/classes/com/baidu/hugegraph"
if [ "$BACKEND" == "memory" ]; then
# hugegraph-memory is the same as hugegraph-core
Expand Down
10 changes: 8 additions & 2 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 All @@ -19,10 +25,10 @@ case $BACKEND in
$TRAVIS_DIR/install-hbase.sh
;;
mysql)
$TRAVIS_DIR/install-mysql.sh
$TRAVIS_DIR/install-mysql-via-docker.sh
;;
postgresql)
$TRAVIS_DIR/install-postgresql.sh
$TRAVIS_DIR/install-postgresql-via-docker.sh
;;
*)
# don't need to install for other backends
Expand Down
16 changes: 16 additions & 0 deletions hugegraph-dist/src/assembly/travis/install-mysql-via-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -ev

TRAVIS_DIR=`dirname $0`

# Need speed up it
CONF=hugegraph-test/src/main/resources/hugegraph.properties
MYSQL_USERNAME=root
MYSQL_PASSWORD=123456
# Set MySQL configurations
sed -i "s/jdbc.username=.*/jdbc.username=$MYSQL_USERNAME/" $CONF
sed -i "s/jdbc.password=.*/jdbc.password=$MYSQL_PASSWORD/" $CONF

docker pull mysql:5.7
docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -ev

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

POSTGRESQL_DRIVER=org.postgresql.Driver
POSTGRESQL_URL=jdbc:postgresql://localhost:5432/
POSTGRESQL_USERNAME=postgres
POSTGRESQL_PASSWORD=123456

# Set PostgreSQL configurations
sed -i "s/jdbc.driver=.*/jdbc.driver=$POSTGRESQL_DRIVER/" $CONF
sed -i "s?jdbc.url=.*?jdbc.url=$POSTGRESQL_URL?" $CONF
sed -i "s/jdbc.username=.*/jdbc.username=$POSTGRESQL_USERNAME/" $CONF
sed -i "s/jdbc.password=.*/jdbc.password=$POSTGRESQL_PASSWORD/" $CONF

sudo service postgresql stop 9.2

docker pull postgres:9.6
docker volume create pgdata
docker run --rm -v pgdata:/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=123456 -d postgres:9.6
6 changes: 4 additions & 2 deletions 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,9 +28,9 @@ 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)
$TRAVIS_DIR/build-report.sh
$TRAVIS_DIR/build-report.sh $BACKEND
$TRAVIS_DIR/stop-server.sh
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
1 change: 1 addition & 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 Down

0 comments on commit af637db

Please sign in to comment.