Skip to content
Permalink
Browse files
chore: use github action to run ci (#128)
  • Loading branch information
Linary committed Jun 24, 2021
1 parent 9d1ab59 commit 1fa5d8f1147a9ca2b4a31826d2fc000decfc315b
Showing 4 changed files with 87 additions and 16 deletions.
@@ -0,0 +1,58 @@
name: hugegraph-client ci

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

jobs:
build:
runs-on: ubuntu-16.04
env:
TRAVIS_DIR: assembly/travis
COMMIT_ID: 23e3c31a5445cd472e16c6a625a119ca0ab4b04d
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-hugegraph-from-source.sh $COMMIT_ID | grep -v "Downloading\|Downloaded"
- name: Run test
run: |
mvn test -Dtest=UnitTestSuite
mvn test -Dtest=ApiTestSuite
mvn test -Dtest=FuncTestSuite
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.0.2
with:
token: ${{secrets.CODECOV_TOKEN}}
file: target/jacoco.xml
@@ -3,12 +3,11 @@
set -ev

if [[ $# -ne 1 ]]; then
echo "Must pass base branch name of pull request"
echo "Must pass commit id of hugegraph repo"
exit 1
fi

CLIENT_BRANCH=$1
HUGEGRAPH_BRANCH=${CLIENT_BRANCH}
COMMIT_ID=$1
HUGEGRAPH_GIT_URL="https://github.com/hugegraph/hugegraph.git"

git clone --depth 100 ${HUGEGRAPH_GIT_URL}
@@ -97,7 +97,7 @@ private void initManagers(RestClient client, String graph) {
private void checkServerApiVersion() {
VersionUtil.Version apiVersion = VersionUtil.Version.of(
this.version.getApiVersion());
VersionUtil.check(apiVersion, "0.38", "0.62",
VersionUtil.check(apiVersion, "0.38", "0.63",
"hugegraph-api in server");
this.client.apiVersion(apiVersion);
}
@@ -108,7 +108,7 @@ public void testPersonalRank() {
"d", 0.08959757100230095D,
"b", 0.04589958822642998D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);
}

@Test
@@ -124,7 +124,7 @@ public void testPersonalRankWithWithLabel() {
"B", 0.2065750574989044D,
"C", 0.09839507219265439D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);

builder = PersonalRankAPI.Request.builder();
builder.source("A").label("like").alpha(0.9).maxDepth(50)
@@ -136,7 +136,7 @@ public void testPersonalRankWithWithLabel() {
"d", 0.08959757100230095D,
"b", 0.04589958822642998D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);
}

@Test
@@ -153,7 +153,7 @@ public void testPersonalRankWithOtherAlpha() {
"b", 0.0D,
"d", 0.0D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);
}

@Test
@@ -166,25 +166,25 @@ public void testPersonalRankWithDegree() {

// Removed root and direct neighbors of root
Map<Object, Double> ranks = personalRankAPI.post(request);
Assert.assertEquals(ImmutableMap.of(), ranks);
assertDoublesEquals(ImmutableMap.of(), ranks);

builder.source("A").label("like").alpha(0.9).degree(1).maxDepth(2);
request = builder.build();

ranks = personalRankAPI.post(request);
Assert.assertEquals(ImmutableMap.of(), ranks);
assertDoublesEquals(ImmutableMap.of(), ranks);

builder.source("A").label("like").alpha(0.9).degree(2).maxDepth(1);
request = builder.build();

ranks = personalRankAPI.post(request);
Assert.assertEquals(ImmutableMap.of(), ranks);
assertDoublesEquals(ImmutableMap.of(), ranks);

builder.source("A").label("like").alpha(0.9).degree(2).maxDepth(2);
request = builder.build();

ranks = personalRankAPI.post(request);
Assert.assertEquals(ImmutableMap.of("B", 0.405D), ranks);
assertDoublesEquals(ImmutableMap.of("B", 0.405D), ranks);
}

@Test
@@ -200,7 +200,7 @@ public void testPersonalRankWithLimit() {
"C", 0.09839507219265439D,
"d", 0.08959757100230095D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);
}

@Test
@@ -217,7 +217,7 @@ public void testPersonalRankWithMaxDepth() {
"d", 0.07581065434649958D,
"b", 0.03900612828909826D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);
}

@Test
@@ -234,7 +234,7 @@ public void testPersonalRankWithUnsorted() {
"C", 0.09839507219265439D,
"d", 0.08959757100230095D
);
Assert.assertEquals(expectedRanks, ranks);
assertDoublesEquals(expectedRanks, ranks);
}

@Test
@@ -248,7 +248,7 @@ public void testPersonalRankWithIsolatedVertex() {
PersonalRankAPI.Request request = builder.build();

Map<Object, Double> ranks = personalRankAPI.post(request);
Assert.assertEquals(ImmutableMap.of(), ranks);
assertDoublesEquals(ImmutableMap.of(), ranks);

graph().removeVertex(isolate.id());
}
@@ -307,4 +307,18 @@ public void testPersonalRankWithInvalidParams() {
builder.maxDepth(51);
});
}

private static void assertDoublesEquals(Map<Object, Double> expects,
Map<Object, Double> actuals) {
Assert.assertEquals(expects.size(), actuals.size());
Assert.assertTrue(expects.keySet().containsAll(actuals.keySet()));
for (Object expectKey : expects.keySet()) {
Double expectValue = expects.get(expectKey);
Double actualValue = actuals.get(expectKey);
Assert.assertTrue(String.format("expected %s, actual %s",
expectValue, actualValue),
Math.abs(expectValue - actualValue) <
Math.pow(1, -10));
}
}
}

0 comments on commit 1fa5d8f

Please sign in to comment.