Skip to content

Commit

Permalink
Build and release fs-storage JNI libraries and publish Java library
Browse files Browse the repository at this point in the history
  • Loading branch information
oluiscabral committed Nov 30, 2024
1 parent 66c9362 commit 74d10ff
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 58 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ jobs:
toolchain: nightly # nightly is required for fmt
components: rustfmt, clippy

- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false

- name: Check
run: cargo check

Expand All @@ -33,18 +38,15 @@ jobs:
cargo fmt --all -- --check
cargo clippy --workspace --bins -- -D warnings
- name: Build Debug
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

- name: Build Release
run: cargo build --verbose --release

- name: Run `ark-cli watch` test
run: ./integration/ark-cli-watch.sh

- name: Build Release
run: cargo build --verbose --release

- name: Install JDK
uses: actions/[email protected]
with:
Expand All @@ -68,15 +70,20 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build Release
run: cargo build --verbose --release
- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false

- name: Run tests
run: cargo test --workspace --verbose

- name: Run `ark-cli watch` test
run: ./integration/ark-cli-watch.sh

- name: Build Release
run: cargo build --verbose --release

- name: Install JDK
uses: actions/[email protected]
with:
Expand All @@ -100,14 +107,16 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build Release
run: cargo build --verbose --release
- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false

- name: Run tests
run: cargo test --workspace --verbose

- name: Run `ark-cli watch` test
run: ./integration/ark-cli-watch.sh
- name: Build Release
run: cargo build --verbose --release

- name: Install JDK
uses: actions/[email protected]
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android

- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false

- name: Run tests
run: cargo test --workspace --verbose

- name: Build Release
run: cargo build --verbose --release

- name: Install JDK
uses: actions/[email protected]
with:
distribution: "temurin"
java-version: "22"

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Java tests
run: gradle test
working-directory: ./java

- name: Install cargo-ndk
run: cargo install cargo-ndk

- name: Build fs-storage JNI libs
run: cargo ndk -o ./target/release/fs-storage/jniLibs --target aarch64-linux-android --target armv7-linux-androideabi --target i686-linux-android --target x86_64-linux-android build -p fs-storage --release

- name: Create JNI Libraries ZIP
run: |
cd target/release/fs-storage
zip -r ../../../jniLibs.zip jniLibs
cd -
- name: Release JNI Libraries ZIP
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "jniLibs.zip"

- name: Publish Java release
run: gradle publish
working-directory: ./java
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: true

- name: Run tests
run: cargo test --workspace --verbose --release

Expand All @@ -32,6 +37,11 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: true

- name: Run tests
run: cargo test --workspace --verbose --release

Expand All @@ -45,6 +55,11 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: true

- name: Run tests
run: cargo test --workspace --verbose --release

Expand All @@ -58,5 +73,10 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Set up Cargo Cache
uses: Swatinem/rust-cache@v2
with:
save-if: true

- name: Run tests
run: cargo test --workspace --verbose --release
27 changes: 0 additions & 27 deletions ark-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
# Ark-CLI

### Installation

To compile you will need openssl libraries and headers:

```shell
# macOS (Homebrew)
$ brew install openssl@3

# macOS (MacPorts)
$ sudo port install openssl

# macOS (pkgsrc)
$ sudo pkgin install openssl

# Arch Linux
$ sudo pacman -S pkg-config openssl

# Debian and Ubuntu
$ sudo apt-get install pkg-config libssl-dev

# Fedora
$ sudo dnf install pkg-config perl-FindBin openssl-devel

# Alpine Linux
$ apk add pkgconfig openssl-dev
```

### Usage

```shell
Expand Down
2 changes: 1 addition & 1 deletion data-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bench = false

[dependencies]
thiserror = "1"
reqwest = "0.11.11"
reqwest = { version = "0.11.11", features = [ "json", "rustls-tls" ], default-features = false }
serde_json = "1.0.82"
anyhow = "1"
url = { version = "2.2.2", features = ["serde"] }
2 changes: 1 addition & 1 deletion data-link/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ log = { version = "0.4.17", features = ["release_max_level_off"] }
serde_json = "1.0.82"
serde = { version = "1.0.138", features = ["derive"] }
url = { version = "2.2.2", features = ["serde"] }
reqwest = "0.11.11"
reqwest = { version = "0.11.11", features = [ "json", "rustls-tls" ], default-features = false }
scraper = "0.13.0"
tokio = { version = "1", features = ["full"] }

Expand Down
51 changes: 34 additions & 17 deletions java/lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
plugins {
// Apply the java-library plugin for API and implementation separation.
`java-library`
`maven-publish` // Apply the maven-publish plugin before java-library for publishing to GitHub Packages.
`java-library` // Apply the java-library plugin for API and implementation separation.
}

group = "dev.arkbuilders.core"
version = "1.0-SNAPSHOT"

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
mavenCentral() // Use Maven Central for resolving dependencies.
}

dependencies {
// Use JUnit Jupiter for testing.
testImplementation(libs.junit.jupiter)

testImplementation(libs.junit.jupiter) // Use JUnit Jupiter for testing.
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

// This dependency is exported to consumers, that is to say found on their compile classpath.
api(libs.commons.math3)

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation(libs.guava)
api(libs.commons.math3) // This dependency is exported to consumers, that is to say found on their compile classpath.
implementation(libs.guava) // This dependency is used internally, and not exposed to consumers on their own compile classpath.
}

// Apply a specific Java toolchain to ease working on different environments.
Expand All @@ -29,14 +25,35 @@ java {
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
// Set the JVM argument for the java.library.path (To import rust compiled library)
val rustLibPath = projectDir.resolve("../../target/release").absolutePath
val rustLibPath = projectDir.resolve("../../target/release").absolutePath // Set the JVM argument for the java.library.path (To import rust compiled library)
useJUnitPlatform() // Use JUnit Platform for unit tests.
jvmArgs = listOf("-Djava.library.path=$rustLibPath")
}

tasks.named<Javadoc>("javadoc") {
options.encoding = "UTF-8"
options.memberLevel = JavadocMemberLevel.PUBLIC
}

publishing {
// Define a Maven publication for the 'maven' repository
publications {
create<MavenPublication>("Maven") {
from(components["java"])
pom {
name.set("fs_storage")
description.set("File system storage bindings for writing key value pairs to disk.")
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ARK-Builders/ark-core")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

0 comments on commit 74d10ff

Please sign in to comment.