Skip to content

Commit dfad0c2

Browse files
authored
Merge pull request #5 from RelationalAI/hnr-maven-github-workflow
Github workflow to build the SDK
2 parents 574c5a3 + 2d1ad81 commit dfad0c2

File tree

12 files changed

+232
-5
lines changed

12 files changed

+232
-5
lines changed

.github/workflows/maven-build.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: build/test
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up JDK 11
12+
uses: actions/setup-java@v2
13+
with:
14+
java-version: '11'
15+
distribution: 'adopt'
16+
- name: Build with Maven
17+
env:
18+
CLIENT_ID: ${{ secrets.CLIENT_ID }}
19+
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
20+
CLIENT_CREDENTIALS_URL: ${{ secrets.CLIENT_CREDENTIALS_URL }}
21+
run: mvn clean install
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: javadoc
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-java@v1
16+
with:
17+
java-version: 11
18+
java-package: jdk+fx
19+
- name: Generate Javadoc
20+
run: |
21+
mvn clean install -DskipTests
22+
mvn javadoc:javadoc
23+
- name: Deploy 🚀
24+
uses: JamesIves/[email protected]
25+
with:
26+
branch: gh-pages
27+
folder: rai-sdk/target/site/apidocs
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: publish
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
packages: write
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-java@v2
14+
with:
15+
java-version: '11'
16+
distribution: 'adopt'
17+
- name: Publish package
18+
run: mvn --batch-mode deploy -DskipTests
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# General
2+
3+
| Workflow | Status |
4+
| --------------------------- | ---------------------------------------------------------------------- |
5+
| Continuous Integration (CI) | ![build](https://github.com/RelationalAI/rai-sdk-java/actions/workflows/maven-build.yaml/badge.svg) |
6+
| Publish to GitHub packages | ![publish](https://github.com/RelationalAI/rai-sdk-java/actions/workflows/maven-publish.yaml/badge.svg) |
7+
| Generate java documentation | ![javadoc](https://github.com/RelationalAI/rai-sdk-java/actions/workflows/maven-javadoc.yaml/badge.svg) |
8+
9+
110
# The RelationalAI Software Development Kit for Java
211

312
The RelationalAI (RAI) SDK for Java enables developers to access the RAI REST
@@ -70,6 +79,50 @@ https://console.relationalai.com/login
7079

7180
You can copy `config.spec` from the root of this repo and modify as needed.
7281

82+
### Using the SDK as a maven dependency
83+
84+
In order to use the `rai-sdk-java`, you need add this dependency to your project's POM:
85+
86+
<dependency>
87+
<groupId>com.relationalai</groupId>
88+
<artifactId>rai-sdk</artifactId>
89+
<version>0.0.1</version>
90+
</dependency>
91+
92+
You need also to point maven to the SDK GitHub packages repository in the project's POM:
93+
94+
<repositories>
95+
<repository>
96+
<id>github</id>
97+
<name>The RelationalAI SDK for Apache Maven</name>
98+
<url>https://maven.pkg.github.com/RelationalAI/rai-sdk-java</url>
99+
</repository>
100+
</repositories>
101+
102+
The registry access is available through GiHub api which is protected. You have to add GitHub credentials to `$HOME/.m2/settings.xml`:
103+
104+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
105+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
106+
<localRepository/>
107+
...
108+
<servers>
109+
<server>
110+
<id>github</id>
111+
<username>GITHUB_USERNAME</username>
112+
<password>GITHUB_ACCESS_TOKEN</password>
113+
</server>
114+
</servers>
115+
...
116+
</settings>
117+
118+
`GITHUB_USERNAME` is your GitHub login name.
119+
120+
`GITHUB_ACCESS_TOKEN` is a generated GitHub personal access token:
121+
122+
*GitHub > Settings > Developer Settings > Personal access tokens > Generate new token.*
123+
124+
The token needs at least the read:packages scope.
125+
73126
## Examples
74127

75128
The SDK contain examples for every API, and various other SDK features. These
@@ -90,6 +143,10 @@ individual examples, eg:
90143
cd ./rai-sdk/examples
91144
./run GetDatabase sdk-test
92145

146+
## Javadocs
147+
148+
Javadocs for `rai-sdk` are available [here](https://musical-winner-94955c55.pages.github.io/com/relationalai/package-summary.html).
149+
93150
## Support
94151

95152
You can reach the RAI developer support team at `[email protected]`

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@
7676
</pluginManagement>
7777
</build>
7878

79+
<distributionManagement>
80+
<repository>
81+
<id>github</id>
82+
<name>GitHub Packages</name>
83+
<url>https://maven.pkg.github.com/RelationalAI/rai-sdk-java</url>
84+
</repository>
85+
</distributionManagement>
86+
7987
<licenses>
8088
<license>
8189
<name>Apache License, Version 2.0</name>

rai-sdk/src/test/java/com/relationalai/DatabaseTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.junit.jupiter.api.Assertions.assertNull;
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
2323
import java.io.IOException;
24+
25+
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.Test;
2527
import org.junit.jupiter.api.TestInstance;
2628
import org.junit.jupiter.api.TestInstance.Lifecycle;
@@ -190,8 +192,19 @@ void testDatabase() throws HttpError, InterruptedException, IOException {
190192
// Cleanup
191193
var deleteRsp = client.deleteDatabase(databaseCloneName);
192194
assertEquals(databaseCloneName, deleteRsp.name);
195+
}
193196

194-
deleteRsp = client.deleteDatabase(databaseName);
197+
@AfterAll void tearDown() throws IOException, HttpError, InterruptedException {
198+
var client = createClient();
199+
200+
var deleteRsp = client.deleteDatabase(databaseName);
195201
assertEquals(databaseName, deleteRsp.name);
202+
203+
try {
204+
// deleteEngineWait terminates its polling loop with a 404
205+
client.deleteEngineWait(engineName);
206+
} catch (HttpError e) {
207+
assertEquals(e.statusCode, 404);
208+
}
196209
}
197210
}

rai-sdk/src/test/java/com/relationalai/ExecuteTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import java.io.IOException;
22+
23+
import org.junit.jupiter.api.AfterAll;
2224
import org.junit.jupiter.api.Test;
2325
import org.junit.jupiter.api.TestInstance;
2426
import org.junit.jupiter.api.TestInstance.Lifecycle;
@@ -50,4 +52,16 @@ public class ExecuteTest extends UnitTest {
5052
{1., 16., 81., 256., 625.}};
5153
assertArrayEquals(expected, columns);
5254
}
55+
56+
@AfterAll void tearDown() throws IOException, HttpError, InterruptedException {
57+
var client = createClient();
58+
var deleteRsp = client.deleteDatabase(databaseName);
59+
assertEquals(databaseName, deleteRsp.name);
60+
try {
61+
// deleteEngineWait terminates its polling loop with a 404
62+
client.deleteEngineWait(engineName);
63+
} catch (HttpError e) {
64+
assertEquals(e.statusCode, 404);
65+
}
66+
}
5367
}

rai-sdk/src/test/java/com/relationalai/LoadCsvTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.junit.jupiter.api.Assertions.assertNotNull;
2222
import java.io.IOException;
2323
import java.util.HashMap;
24+
25+
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.Test;
2527
import org.junit.jupiter.api.TestInstance;
2628
import org.junit.jupiter.api.TestInstance.Lifecycle;
@@ -256,4 +258,17 @@ public class LoadCsvTest extends UnitTest {
256258
assertEquals(1, rel.relKey.values.length);
257259
assertEquals("String", rel.relKey.values[0]);
258260
}
261+
262+
@AfterAll
263+
void tearDown() throws IOException, HttpError, InterruptedException {
264+
var client = createClient();
265+
var deleteRsp = client.deleteDatabase(databaseName);
266+
assertEquals(databaseName, deleteRsp.name);
267+
try {
268+
// deleteEngineWait terminates its polling loop with a 404
269+
client.deleteEngineWait(engineName);
270+
} catch (HttpError e) {
271+
assertEquals(e.statusCode, 404);
272+
}
273+
}
259274
}

rai-sdk/src/test/java/com/relationalai/LoadJsonTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import static org.junit.jupiter.api.Assertions.assertNotNull;
2222
import java.io.IOException;
23+
24+
import org.junit.jupiter.api.AfterAll;
2325
import org.junit.jupiter.api.Test;
2426
import org.junit.jupiter.api.TestInstance;
2527
import org.junit.jupiter.api.TestInstance.Lifecycle;
@@ -67,4 +69,17 @@ public class LoadJsonTest extends UnitTest {
6769
assertEquals(2, rel.columns.length);
6870
assertArrayEquals(new Object[][] {{1., 2.}, {"dog", "rabbit"}}, rel.columns);
6971
}
72+
73+
@AfterAll
74+
void tearDown() throws IOException, HttpError, InterruptedException {
75+
var client = createClient();
76+
var deleteRsp = client.deleteDatabase(databaseName);
77+
assertEquals(databaseName, deleteRsp.name);
78+
try {
79+
// deleteEngineWait terminates its polling loop with a 404
80+
client.deleteEngineWait(engineName);
81+
} catch (HttpError e) {
82+
assertEquals(e.statusCode, 404);
83+
}
84+
}
7085
}

rai-sdk/src/test/java/com/relationalai/ModelsTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.junit.jupiter.api.Assertions.assertNull;
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
2323
import java.io.IOException;
24+
25+
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.Test;
2527
import org.junit.jupiter.api.TestInstance;
2628
import org.junit.jupiter.api.TestInstance.Lifecycle;
@@ -72,4 +74,17 @@ public class ModelsTest extends UnitTest {
7274
model = find(models, item -> item.name.equals("test_model"));
7375
assertNull(model);
7476
}
77+
78+
@AfterAll
79+
void tearDown() throws IOException, HttpError, InterruptedException {
80+
var client = createClient();
81+
var deleteRsp = client.deleteDatabase(databaseName);
82+
assertEquals(databaseName, deleteRsp.name);
83+
try {
84+
// deleteEngineWait terminates its polling loop with a 404
85+
client.deleteEngineWait(engineName);
86+
} catch (HttpError e) {
87+
assertEquals(e.statusCode, 404);
88+
}
89+
}
7590
}

0 commit comments

Comments
 (0)