From 6af1614cf19466941a09e9fca1ba6c28207c4347 Mon Sep 17 00:00:00 2001 From: Luis Cabral <58452540+oluiscabral@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:30:57 -0300 Subject: [PATCH 01/28] Build and release `fs-storage` JNI libraries and publish Java library --- .github/workflows/build.yml | 26 ++++++++++---- .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++++ .github/workflows/weekly.yml | 20 +++++++++++ ark-cli/README.md | 27 -------------- data-error/Cargo.toml | 2 +- data-link/Cargo.toml | 2 +- java/lib/build.gradle.kts | 51 +++++++++++++++++--------- 7 files changed, 142 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7701fb74..6f41aa0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -33,9 +38,6 @@ 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 @@ -68,12 +70,17 @@ 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: Build Release + run: cargo build --verbose --release + - name: Run `ark-cli watch` test run: ./integration/ark-cli-watch.sh @@ -100,12 +107,17 @@ 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: Build Release + run: cargo build --verbose --release + - name: Run `ark-cli watch` test run: ./integration/ark-cli-watch.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..214ebe95 --- /dev/null +++ b/.github/workflows/release.yml @@ -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/setup-java@v4.2.1 + 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 }} diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index 572b131d..308ea6fa 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/ark-cli/README.md b/ark-cli/README.md index 033aac80..58932874 100644 --- a/ark-cli/README.md +++ b/ark-cli/README.md @@ -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 diff --git a/data-error/Cargo.toml b/data-error/Cargo.toml index 63ac295d..5ad9127d 100644 --- a/data-error/Cargo.toml +++ b/data-error/Cargo.toml @@ -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"] } diff --git a/data-link/Cargo.toml b/data-link/Cargo.toml index 6821ceda..4cae70ce 100644 --- a/data-link/Cargo.toml +++ b/data-link/Cargo.toml @@ -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"] } diff --git a/java/lib/build.gradle.kts b/java/lib/build.gradle.kts index 96541a60..c40834ae 100644 --- a/java/lib/build.gradle.kts +++ b/java/lib/build.gradle.kts @@ -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. @@ -29,10 +25,8 @@ java { } tasks.named("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") } @@ -40,3 +34,26 @@ tasks.named("javadoc") { options.encoding = "UTF-8" options.memberLevel = JavadocMemberLevel.PUBLIC } + +publishing { + // Define a Maven publication for the 'maven' repository + publications { + create("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") + } + } + } +} From 571aab696e6023125087767bac71a87fb5434e69 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Mon, 2 Dec 2024 10:21:23 -0300 Subject: [PATCH 02/28] Create `cache.yml` workflow --- .github/workflows/cache.yml | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/cache.yml diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml new file mode 100644 index 00000000..c30d5675 --- /dev/null +++ b/.github/workflows/cache.yml @@ -0,0 +1,82 @@ +name: Cache build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + linux: + name: Linux + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - 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 + + windows: + name: Windows + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - 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 + + mac-intel: + name: MacOS Intel + runs-on: macos-14 + + steps: + - uses: actions/checkout@v4 + + - 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 + + mac-arm: + name: MacOS ARM + runs-on: macos-13-xlarge + + steps: + - uses: actions/checkout@v4 + + - 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 From 560fca717a8209b1cb0b42b3735a3e1a0e957322 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Tue, 10 Dec 2024 10:35:07 -0300 Subject: [PATCH 03/28] WIP - start transforming it into AAR --- java/build.gradle | 21 ++ java/gradle/libs.versions.toml | 15 +- java/lib/build.gradle | 96 +++++++++ java/lib/build.gradle.kts | 59 ------ .../dev/arkbuilders/core/FileStorageTest.java | 192 ------------------ java/local.properties | 8 + java/settings.gradle | 2 + java/settings.gradle.kts | 14 -- 8 files changed, 133 insertions(+), 274 deletions(-) create mode 100644 java/build.gradle create mode 100644 java/lib/build.gradle delete mode 100644 java/lib/build.gradle.kts delete mode 100644 java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java create mode 100644 java/local.properties create mode 100644 java/settings.gradle delete mode 100644 java/settings.gradle.kts diff --git a/java/build.gradle b/java/build.gradle new file mode 100644 index 00000000..82f9cce7 --- /dev/null +++ b/java/build.gradle @@ -0,0 +1,21 @@ +buildscript { + repositories { + google() + maven { url "https://plugins.gradle.org/m2/" } + gradlePluginPortal() + } + dependencies { + classpath libs.gradle + classpath libs.rust.android + classpath libs.axion.release.plugin + } +} + +allprojects { + repositories { + google() + gradlePluginPortal() + maven { url "https://jitpack.io"} + maven { url "https://plugins.gradle.org/m2/" } + } +} diff --git a/java/gradle/libs.versions.toml b/java/gradle/libs.versions.toml index 8f20ed0b..c86297d7 100644 --- a/java/gradle/libs.versions.toml +++ b/java/gradle/libs.versions.toml @@ -1,12 +1,9 @@ -# This file was generated by the Gradle 'init' task. -# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format - [versions] -commons-math3 = "3.6.1" -guava = "33.0.0-jre" -junit-jupiter = "5.10.2" +gradle = "8.1.4" +rustAndroid = "0.9.4" +axionReleasePlugin = "1.17.0" [libraries] -commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" } -guava = { module = "com.google.guava:guava", version.ref = "guava" } -junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } +gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } +rust-android = { module = "org.mozilla.rust-android-gradle:plugin", version.ref = "rustAndroid" } +axion-release-plugin = { module = "pl.allegro.tech.build:axion-release-plugin", version.ref = "axionReleasePlugin" } diff --git a/java/lib/build.gradle b/java/lib/build.gradle new file mode 100644 index 00000000..f447a4cd --- /dev/null +++ b/java/lib/build.gradle @@ -0,0 +1,96 @@ +apply plugin: 'maven-publish' +apply plugin: 'com.android.library' +apply plugin: 'pl.allegro.tech.build.axion-release' +apply plugin: 'org.mozilla.rust-android-gradle.rust-android' + +android { + ndkVersion "28.0.12433566" + namespace "dev.arkbuilders.core" + + defaultConfig { + minSdkVersion 26 + targetSdkVersion 35 + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + publishing { + singleVariant('release') { + withSourcesJar() + } + singleVariant('debug') { + withSourcesJar() + } + } +} + +cargo { + libname = "fs_storage" + module = "../fs-storage" + prebuiltToolchains = true + targets = ["arm64", "x86", "x86_64", "arm"] + profile = gradle.startParameter.taskNames.any { it.toLowerCase().contains("debug") } ? "debug" : "release" +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + + implementation 'androidx.core:core-ktx:1.15.0' + implementation 'org.apache.tika:tika-core:2.4.0' + implementation "com.google.dagger:dagger:2.50" + implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0' + implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14' + + def coilVersion = "2.4.0" + implementation "io.coil-kt:coil:$coilVersion" + implementation "io.coil-kt:coil-gif:$coilVersion" + implementation "io.coil-kt:coil-svg:$coilVersion" + implementation "io.coil-kt:coil-video:$coilVersion" + + testImplementation "junit:junit:4.13.2" + testImplementation "io.mockk:mockk:1.13.7" +} + +tasks.configureEach { task -> + if ((task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders')) { + task.dependsOn 'cargoBuild' + } +} + +def libVersion = scmVersion.version + +publishing { + publications { + release(MavenPublication) { + groupId = "dev.arkbuilders" + artifactId = "core" + version = libVersion + afterEvaluate { + from components.release + } + } + debug(MavenPublication) { + groupId = "dev.arkbuilders" + artifactId = "core-debug" + version = libVersion + afterEvaluate { + from components.debug + } + } + } + + repositories { + maven { + name = "GithubPackages" + url = "https://maven.pkg.github.com/ARK-Builders/ark-core" + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + + } +} \ No newline at end of file diff --git a/java/lib/build.gradle.kts b/java/lib/build.gradle.kts deleted file mode 100644 index c40834ae..00000000 --- a/java/lib/build.gradle.kts +++ /dev/null @@ -1,59 +0,0 @@ -plugins { - `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 { - mavenCentral() // Use Maven Central for resolving dependencies. -} - -dependencies { - testImplementation(libs.junit.jupiter) // Use JUnit Jupiter for testing. - testRuntimeOnly("org.junit.platform:junit-platform-launcher") - 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. -java { - toolchain { - languageVersion = JavaLanguageVersion.of(21) - } -} - -tasks.named("test") { - 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") { - options.encoding = "UTF-8" - options.memberLevel = JavadocMemberLevel.PUBLIC -} - -publishing { - // Define a Maven publication for the 'maven' repository - publications { - create("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") - } - } - } -} diff --git a/java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java b/java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java deleted file mode 100644 index 7b9cc284..00000000 --- a/java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java +++ /dev/null @@ -1,192 +0,0 @@ -package dev.arkbuilders.core; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import java.io.File; -import java.nio.file.Path; -import java.util.LinkedHashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class FileStorageTest { - FileStorage fileStorage = new FileStorage("test", "test.txt"); - - @TempDir - Path tempDir; - - @Test - public void testFileStorageWriteRead() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - - fileStorage.set("key1", "value1"); - fileStorage.set("key2", "value2"); - - fileStorage.remove("key1"); - fileStorage.writeFS(); - - @SuppressWarnings("unchecked") - LinkedHashMap data = (LinkedHashMap) fileStorage.readFS(); - assertEquals(1, data.size()); - assertEquals("value2", data.get("key2")); - } - - @Test - public void testFileStorageAutoDelete() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - - fileStorage.set("key1", "value1"); - fileStorage.set("key1", "value2"); - fileStorage.writeFS(); - - File file = storagePath.toFile(); - assertTrue(file.exists()); - - fileStorage.erase(); - assertFalse(file.exists()); - } - - @Test - public void testFileStorageNeedsSyncing() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - fileStorage.writeFS(); - assertEquals(FileStorage.SyncStatus.InSync, fileStorage.syncStatus()); - fileStorage.set("key1", "value1"); - assertEquals(FileStorage.SyncStatus.StorageStale, fileStorage.syncStatus()); - fileStorage.writeFS(); - assertEquals(FileStorage.SyncStatus.InSync, fileStorage.syncStatus()); - } - - @Test - public void testFileStorageMonoidCombine() { - Path storagePath1 = tempDir.resolve("test1.txt"); - Path storagePath2 = tempDir.resolve("test2.txt"); - FileStorage fileStorage1 = new FileStorage("test1", storagePath1.toString()); - FileStorage fileStorage2 = new FileStorage("test2", storagePath2.toString()); - - fileStorage1.set("key1", "2"); - fileStorage1.set("key2", "6"); - - fileStorage2.set("key1", "3"); - fileStorage2.set("key3", "9"); - - fileStorage1.merge(fileStorage2); - fileStorage1.writeFS(); - - @SuppressWarnings("unchecked") - LinkedHashMap data = (LinkedHashMap) fileStorage1.readFS(); - assertEquals(3, data.size()); - assertEquals("23", data.get("key1")); - assertEquals("6", data.get("key2")); - assertEquals("9", data.get("key3")); - } - - @Test - public void testFileStorageMainScenario() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - - fileStorage.set("key", "value"); - fileStorage.set("key", "value1"); - fileStorage.set("key1", "value"); - - fileStorage.remove("key"); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - fileStorage.writeFS(); - - @SuppressWarnings("unchecked") - LinkedHashMap data = (LinkedHashMap) fileStorage.readFS(); - assertEquals(1, data.size()); - assertEquals("value", data.get("key1")); - - fileStorage.erase(); - File file = storagePath.toFile(); - assertFalse(file.exists()); - } - - @Test - public void testFileStorageGet() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - - fileStorage.set("key", "value"); - fileStorage.set("key", "value1"); - fileStorage.set("key1", "value"); - - assertEquals("value1", fileStorage.get("key")); - assertEquals("value", fileStorage.get("key1")); - } - - @Test - public void testBTreeMapIterator(){ - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - - fileStorage.set("key", "value"); - fileStorage.set("key", "value1"); - fileStorage.set("key1", "value"); - - fileStorage.writeFS(); - - @SuppressWarnings("unchecked") - LinkedHashMap data = (LinkedHashMap) fileStorage.readFS(); - - BTreeMapIterator bTreeMapIterator = fileStorage.iterator(); - Map iteratorData = new LinkedHashMap<>(); - while(bTreeMapIterator.hasNext()){ - Map.Entry entry = bTreeMapIterator.next(); - iteratorData.put(entry.getKey(), entry.getValue()); - } - assertEquals(data, iteratorData); - } - - @Test - public void testRemoveException() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - Exception exception = assertThrows(RuntimeException.class, () -> fileStorage.remove("invalid_id")); - assertTrue(exception.getMessage().matches("Storage error.*")); - } - - @Test - public void testSyncException() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - Exception exception = assertThrows(RuntimeException.class, () -> fileStorage.sync()); - assertTrue(exception.getMessage().matches("IO error.*")); - } - - @Test - public void testCreateException() { - Path storagePath = tempDir.resolve(""); - Exception exception = assertThrows(RuntimeException.class, () -> new FileStorage("", storagePath.toString())); - assertTrue(exception.getMessage().matches("IO error.*")); - } - - @Test - public void testEraseException() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - Exception exception = assertThrows(RuntimeException.class, () -> fileStorage.erase()); - assertTrue(exception.getMessage().matches("Storage error.*")); - } - - @Test - public void testReadException() { - Path storagePath = tempDir.resolve("test.txt"); - FileStorage fileStorage = new FileStorage("test", storagePath.toString()); - Exception exception = assertThrows(RuntimeException.class, () -> fileStorage.readFS()); - assertTrue(exception.getMessage().matches("Storage error.*")); - } -} \ No newline at end of file diff --git a/java/local.properties b/java/local.properties new file mode 100644 index 00000000..61ec5043 --- /dev/null +++ b/java/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Tue Dec 10 10:08:23 BRT 2024 +sdk.dir=/home/oluiscabral/Android/Sdk diff --git a/java/settings.gradle b/java/settings.gradle new file mode 100644 index 00000000..0c416e9e --- /dev/null +++ b/java/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = "ark" +include("lib") diff --git a/java/settings.gradle.kts b/java/settings.gradle.kts deleted file mode 100644 index 2a9d8c0c..00000000 --- a/java/settings.gradle.kts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.8/userguide/multi_project_builds.html in the Gradle documentation. - */ - -plugins { - // Apply the foojay-resolver plugin to allow automatic download of JDKs - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" -} - -rootProject.name = "ark" -include("lib") From 8ccb90eb6ce0eb01bc3f4d35048ce1b02a54da8f Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 18:08:19 -0300 Subject: [PATCH 04/28] WIP - set up library as AAR --- java/build.gradle | 4 +-- java/gradle/libs.versions.toml | 2 +- java/gradle/wrapper/gradle-wrapper.properties | 3 +- java/lib/build.gradle | 33 +++---------------- java/settings.gradle | 3 ++ 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/java/build.gradle b/java/build.gradle index 82f9cce7..761e59d2 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -1,8 +1,8 @@ buildscript { repositories { google() - maven { url "https://plugins.gradle.org/m2/" } gradlePluginPortal() + maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath libs.gradle @@ -15,7 +15,7 @@ allprojects { repositories { google() gradlePluginPortal() - maven { url "https://jitpack.io"} + maven { url "https://jitpack.io" } maven { url "https://plugins.gradle.org/m2/" } } } diff --git a/java/gradle/libs.versions.toml b/java/gradle/libs.versions.toml index c86297d7..b1eca0b8 100644 --- a/java/gradle/libs.versions.toml +++ b/java/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -gradle = "8.1.4" +gradle = "8.7.3" rustAndroid = "0.9.4" axionReleasePlugin = "1.17.0" diff --git a/java/gradle/wrapper/gradle-wrapper.properties b/java/gradle/wrapper/gradle-wrapper.properties index a4413138..adddce53 100644 --- a/java/gradle/wrapper/gradle-wrapper.properties +++ b/java/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ +#Tue Dec 10 11:20:11 BRT 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/java/lib/build.gradle b/java/lib/build.gradle index f447a4cd..8a4896b5 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -6,17 +6,11 @@ apply plugin: 'org.mozilla.rust-android-gradle.rust-android' android { ndkVersion "28.0.12433566" namespace "dev.arkbuilders.core" - defaultConfig { + compileSdk 35 minSdkVersion 26 targetSdkVersion 35 } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - publishing { singleVariant('release') { withSourcesJar() @@ -29,30 +23,14 @@ android { cargo { libname = "fs_storage" - module = "../fs-storage" + module = "../../fs-storage" prebuiltToolchains = true + targetDirectory = "../../target" targets = ["arm64", "x86", "x86_64", "arm"] profile = gradle.startParameter.taskNames.any { it.toLowerCase().contains("debug") } ? "debug" : "release" } -dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - - implementation 'androidx.core:core-ktx:1.15.0' - implementation 'org.apache.tika:tika-core:2.4.0' - implementation "com.google.dagger:dagger:2.50" - implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0' - implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14' - - def coilVersion = "2.4.0" - implementation "io.coil-kt:coil:$coilVersion" - implementation "io.coil-kt:coil-gif:$coilVersion" - implementation "io.coil-kt:coil-svg:$coilVersion" - implementation "io.coil-kt:coil-video:$coilVersion" - - testImplementation "junit:junit:4.13.2" - testImplementation "io.mockk:mockk:1.13.7" -} +dependencies {} tasks.configureEach { task -> if ((task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders')) { @@ -61,7 +39,6 @@ tasks.configureEach { task -> } def libVersion = scmVersion.version - publishing { publications { release(MavenPublication) { @@ -81,7 +58,6 @@ publishing { } } } - repositories { maven { name = "GithubPackages" @@ -91,6 +67,5 @@ publishing { password = System.getenv("GITHUB_TOKEN") } } - } } \ No newline at end of file diff --git a/java/settings.gradle b/java/settings.gradle index 0c416e9e..d60eb739 100644 --- a/java/settings.gradle +++ b/java/settings.gradle @@ -1,2 +1,5 @@ +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} rootProject.name = "ark" include("lib") From 0a76e967b84058751dfa0ebd6f01d950ee0cfd36 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 21:06:29 -0300 Subject: [PATCH 05/28] Finish AAR setup --- java/gradle/libs.versions.toml | 3 + java/lib/build.gradle | 58 ++++-- .../dev/arkbuilders/core/FileStorageTest.java | 193 ++++++++++++++++++ 3 files changed, 237 insertions(+), 17 deletions(-) create mode 100644 java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java diff --git a/java/gradle/libs.versions.toml b/java/gradle/libs.versions.toml index b1eca0b8..b6c31875 100644 --- a/java/gradle/libs.versions.toml +++ b/java/gradle/libs.versions.toml @@ -1,9 +1,12 @@ [versions] gradle = "8.7.3" rustAndroid = "0.9.4" +junitJupiterApi = "5.11.3" axionReleasePlugin = "1.17.0" [libraries] gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } rust-android = { module = "org.mozilla.rust-android-gradle:plugin", version.ref = "rustAndroid" } +junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junitJupiterApi" } +junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiterApi" } axion-release-plugin = { module = "pl.allegro.tech.build:axion-release-plugin", version.ref = "axionReleasePlugin" } diff --git a/java/lib/build.gradle b/java/lib/build.gradle index 8a4896b5..80a06455 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -4,8 +4,8 @@ apply plugin: 'pl.allegro.tech.build.axion-release' apply plugin: 'org.mozilla.rust-android-gradle.rust-android' android { - ndkVersion "28.0.12433566" - namespace "dev.arkbuilders.core" + ndkVersion '28.0.12433566' + namespace 'dev.arkbuilders.core' defaultConfig { compileSdk 35 minSdkVersion 26 @@ -22,18 +22,42 @@ android { } cargo { - libname = "fs_storage" - module = "../../fs-storage" + libname = 'fs_storage' + module = '../../fs-storage' prebuiltToolchains = true - targetDirectory = "../../target" - targets = ["arm64", "x86", "x86_64", "arm"] - profile = gradle.startParameter.taskNames.any { it.toLowerCase().contains("debug") } ? "debug" : "release" + targetDirectory = '../../target' + targets = ['arm64', 'x86', 'x86_64', 'arm'] + profile = gradle.startParameter.taskNames.any { it.containsIgnoreCase('debug') } ? 'debug' : 'release' } -dependencies {} +dependencies { + testImplementation(libs.junit.jupiter.api) + testImplementation(libs.junit.jupiter.engine) +} + +tasks.register('buildRustDebug', Exec) { + workingDir '../../fs-storage' + commandLine 'cargo', 'build' +} + +tasks.register('buildRustRelease', Exec) { + workingDir '../../fs-storage' + commandLine 'cargo', 'build', '--release' +} + +tasks.withType(Test).configureEach { it -> + useJUnitPlatform() + if (it.name.containsIgnoreCase('debug')) { + it.dependsOn 'buildRustDebug' + systemProperty('java.library.path', projectDir.toPath().resolve('../../target/debug').toString()) + } else if (it.name.containsIgnoreCase('release')) { + it.dependsOn 'buildRustRelease' + systemProperty('java.library.path', projectDir.toPath().resolve('../../target/release').toString()) + } +} tasks.configureEach { task -> - if ((task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders')) { + if (task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders') { task.dependsOn 'cargoBuild' } } @@ -42,16 +66,16 @@ def libVersion = scmVersion.version publishing { publications { release(MavenPublication) { - groupId = "dev.arkbuilders" - artifactId = "core" + groupId = 'dev.arkbuilders' + artifactId = 'core' version = libVersion afterEvaluate { from components.release } } debug(MavenPublication) { - groupId = "dev.arkbuilders" - artifactId = "core-debug" + groupId = 'dev.arkbuilders' + artifactId = 'core-debug' version = libVersion afterEvaluate { from components.debug @@ -60,11 +84,11 @@ publishing { } repositories { maven { - name = "GithubPackages" - url = "https://maven.pkg.github.com/ARK-Builders/ark-core" + name = 'GithubPackages' + url = 'https://maven.pkg.github.com/ARK-Builders/ark-core' credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") + username = System.getenv('GITHUB_ACTOR') + password = System.getenv('GITHUB_TOKEN') } } } diff --git a/java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java b/java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java new file mode 100644 index 00000000..bf386d11 --- /dev/null +++ b/java/lib/src/test/java/dev/arkbuilders/core/FileStorageTest.java @@ -0,0 +1,193 @@ +package dev.arkbuilders.core; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import java.io.File; +import java.nio.file.Path; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +public class FileStorageTest { + @TempDir + Path tempDir; + + @Test + public void testFileStorageWriteRead() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + + fileStorage.set("key1", "value1"); + fileStorage.set("key2", "value2"); + + fileStorage.remove("key1"); + fileStorage.writeFS(); + + @SuppressWarnings("unchecked") + LinkedHashMap data = (LinkedHashMap) fileStorage.readFS(); + assertEquals(1, data.size()); + assertEquals("value2", data.get("key2")); + } + + @Test + public void testFileStorageAutoDelete() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + + fileStorage.set("key1", "value1"); + fileStorage.set("key1", "value2"); + fileStorage.writeFS(); + + File file = storagePath.toFile(); + assertTrue(file.exists()); + + fileStorage.erase(); + assertFalse(file.exists()); + } + + @Test + public void testFileStorageNeedsSyncing() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + fileStorage.writeFS(); + assertEquals(FileStorage.SyncStatus.InSync, fileStorage.syncStatus()); + fileStorage.set("key1", "value1"); + assertEquals(FileStorage.SyncStatus.StorageStale, fileStorage.syncStatus()); + fileStorage.writeFS(); + assertEquals(FileStorage.SyncStatus.InSync, fileStorage.syncStatus()); + } + + @Test + public void testFileStorageMonoidCombine() { + Path storagePath1 = tempDir.resolve("test1.txt"); + Path storagePath2 = tempDir.resolve("test2.txt"); + FileStorage fileStorage1 = new FileStorage("test1", storagePath1.toString()); + FileStorage fileStorage2 = new FileStorage("test2", storagePath2.toString()); + + fileStorage1.set("key1", "2"); + fileStorage1.set("key2", "6"); + + fileStorage2.set("key1", "3"); + fileStorage2.set("key3", "9"); + + fileStorage1.merge(fileStorage2); + fileStorage1.writeFS(); + + @SuppressWarnings("unchecked") + LinkedHashMap data = (LinkedHashMap) fileStorage1.readFS(); + assertEquals(3, data.size()); + assertEquals("23", data.get("key1")); + assertEquals("6", data.get("key2")); + assertEquals("9", data.get("key3")); + } + + @Test + public void testFileStorageMainScenario() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + + fileStorage.set("key", "value"); + fileStorage.set("key", "value1"); + fileStorage.set("key1", "value"); + + fileStorage.remove("key"); + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + fileStorage.writeFS(); + + @SuppressWarnings("unchecked") + LinkedHashMap data = (LinkedHashMap) fileStorage.readFS(); + assertEquals(1, data.size()); + assertEquals("value", data.get("key1")); + + fileStorage.erase(); + File file = storagePath.toFile(); + assertFalse(file.exists()); + } + + @Test + public void testFileStorageGet() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + + fileStorage.set("key", "value"); + fileStorage.set("key", "value1"); + fileStorage.set("key1", "value"); + + assertEquals("value1", fileStorage.get("key")); + assertEquals("value", fileStorage.get("key1")); + } + + @Test + public void testBTreeMapIterator() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + + fileStorage.set("key", "value"); + fileStorage.set("key", "value1"); + fileStorage.set("key1", "value"); + + fileStorage.writeFS(); + + @SuppressWarnings("unchecked") + LinkedHashMap data = (LinkedHashMap) fileStorage.readFS(); + + BTreeMapIterator bTreeMapIterator = fileStorage.iterator(); + Map iteratorData = new LinkedHashMap<>(); + while (bTreeMapIterator.hasNext()) { + Map.Entry entry = bTreeMapIterator.next(); + iteratorData.put(entry.getKey(), entry.getValue()); + } + assertEquals(data, iteratorData); + } + + @Test + public void testRemoveException() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + Exception exception = assertThrows(RuntimeException.class, () -> fileStorage.remove("invalid_id")); + assertTrue(Objects.requireNonNull(exception.getMessage()).matches("Storage error.*")); + } + + @Test + public void testSyncException() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + Exception exception = assertThrows(RuntimeException.class, fileStorage::sync); + assertTrue(Objects.requireNonNull(exception.getMessage()).matches("IO error.*")); + } + + @Test + public void testCreateException() { + Path storagePath = tempDir.resolve(""); + Exception exception = assertThrows(RuntimeException.class, () -> new FileStorage("", storagePath.toString())); + assertTrue(Objects.requireNonNull(exception.getMessage()).matches("IO error.*")); + } + + @Test + public void testEraseException() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + Exception exception = assertThrows(RuntimeException.class, fileStorage::erase); + assertTrue(Objects.requireNonNull(exception.getMessage()).matches("Storage error.*")); + } + + @Test + public void testReadException() { + Path storagePath = tempDir.resolve("test.txt"); + FileStorage fileStorage = new FileStorage("test", storagePath.toString()); + Exception exception = assertThrows(RuntimeException.class, fileStorage::readFS); + assertTrue(Objects.requireNonNull(exception.getMessage()).matches("Storage error.*")); + } +} \ No newline at end of file From 475a94e60c467270ffde06df8a2cc09df9a3955a Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 21:33:08 -0300 Subject: [PATCH 06/28] Set up NDK to GitHub Actions --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f41aa0c..9d1fa939 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,6 +56,13 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r26d + link-to-sdk: true + - name: Java tests run: gradle test working-directory: ./java @@ -93,6 +100,13 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r26d + link-to-sdk: true + - name: Java tests run: gradle test working-directory: ./java @@ -130,6 +144,13 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r26d + link-to-sdk: true + - name: Java tests run: gradle test working-directory: ./java From f5f442083723e46e63aea23b077bbd738b1a2a05 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 21:39:45 -0300 Subject: [PATCH 07/28] Fix `Set up NDK` step --- .github/workflows/build.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d1fa939..16558ec1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,10 +58,9 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@v1 - id: setup-ndk - with: - ndk-version: r26d - link-to-sdk: true + with: + ndk-version: r26d + link-to-sdk: true - name: Java tests run: gradle test @@ -102,10 +101,9 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@v1 - id: setup-ndk - with: - ndk-version: r26d - link-to-sdk: true + with: + ndk-version: r26d + link-to-sdk: true - name: Java tests run: gradle test @@ -146,10 +144,9 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@v1 - id: setup-ndk - with: - ndk-version: r26d - link-to-sdk: true + with: + ndk-version: r26d + link-to-sdk: true - name: Java tests run: gradle test From 85a00cac9b5341bdfeda367b8705de01ae825783 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 21:56:27 -0300 Subject: [PATCH 08/28] Set up Android SDK --- .github/workflows/build.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16558ec1..5c0b3489 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,10 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - - name: Set up NDK + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + + - name: Set up Android NDK uses: nttld/setup-ndk@v1 with: ndk-version: r26d @@ -99,7 +102,10 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - - name: Set up NDK + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + + - name: Set up Android NDK uses: nttld/setup-ndk@v1 with: ndk-version: r26d @@ -142,7 +148,10 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - - name: Set up NDK + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + + - name: Set up Android NDK uses: nttld/setup-ndk@v1 with: ndk-version: r26d From 57a28c1b53a0eec65659e6f35a86dbc6838d8608 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 22:06:53 -0300 Subject: [PATCH 09/28] Set `ANDROID_NDK_HOME` env var --- .github/workflows/build.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c0b3489..696c2469 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,10 +56,8 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - - name: Set up Android SDK - uses: android-actions/setup-android@v3 - - name: Set up Android NDK + id: setup-ndk uses: nttld/setup-ndk@v1 with: ndk-version: r26d @@ -68,6 +66,8 @@ jobs: - name: Java tests run: gradle test working-directory: ./java + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} windows: name: Test on Windows @@ -102,10 +102,8 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - - name: Set up Android SDK - uses: android-actions/setup-android@v3 - - name: Set up Android NDK + id: setup-ndk uses: nttld/setup-ndk@v1 with: ndk-version: r26d @@ -114,6 +112,8 @@ jobs: - name: Java tests run: gradle test working-directory: ./java + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} mac-intel: name: Test on macOS Intel @@ -148,10 +148,8 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - - name: Set up Android SDK - uses: android-actions/setup-android@v3 - - name: Set up Android NDK + id: setup-ndk uses: nttld/setup-ndk@v1 with: ndk-version: r26d @@ -160,3 +158,5 @@ jobs: - name: Java tests run: gradle test working-directory: ./java + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} From 06db31bc789dff323e56056f62c22632bf72c3af Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 22:19:44 -0300 Subject: [PATCH 10/28] Set specific ndk version --- .github/workflows/build.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 696c2469..db3874c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,8 +60,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@v1 with: - ndk-version: r26d - link-to-sdk: true + ndk-version: 28.0.12433566 - name: Java tests run: gradle test @@ -106,8 +105,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@v1 with: - ndk-version: r26d - link-to-sdk: true + ndk-version: 28.0.12433566 - name: Java tests run: gradle test @@ -152,8 +150,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@v1 with: - ndk-version: r26d - link-to-sdk: true + ndk-version: 28.0.12433566 - name: Java tests run: gradle test From 673041851842f264f0e2a4b783c68b2546b9c0a7 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 22:28:36 -0300 Subject: [PATCH 11/28] Fix NDK version --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db3874c8..ee0eb2cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@v1 with: - ndk-version: 28.0.12433566 + ndk-version: r28-beta1 - name: Java tests run: gradle test @@ -105,7 +105,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@v1 with: - ndk-version: 28.0.12433566 + ndk-version: r28-beta1 - name: Java tests run: gradle test @@ -150,7 +150,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@v1 with: - ndk-version: 28.0.12433566 + ndk-version: r28-beta1 - name: Java tests run: gradle test From 68f478fb21cf621daa5e870c5eb55559e0f6ebf9 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 22:50:52 -0300 Subject: [PATCH 12/28] Bring back Android SDK setup --- .github/workflows/build.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee0eb2cc..ee96394c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,17 +56,18 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + - name: Set up Android NDK - id: setup-ndk uses: nttld/setup-ndk@v1 with: + link-to-sdk: true ndk-version: r28-beta1 - name: Java tests run: gradle test working-directory: ./java - env: - ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} windows: name: Test on Windows @@ -101,17 +102,18 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + - name: Set up Android NDK - id: setup-ndk uses: nttld/setup-ndk@v1 with: + link-to-sdk: true ndk-version: r28-beta1 - name: Java tests run: gradle test working-directory: ./java - env: - ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} mac-intel: name: Test on macOS Intel @@ -146,14 +148,15 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + - name: Set up Android NDK - id: setup-ndk uses: nttld/setup-ndk@v1 with: + link-to-sdk: true ndk-version: r28-beta1 - name: Java tests run: gradle test working-directory: ./java - env: - ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} From c80086bde709326e9894c93f510017151c90d1db Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 23:09:53 -0300 Subject: [PATCH 13/28] Final touches on AAR build and release workflow --- .github/workflows/build.yml | 8 -------- .github/workflows/release.yml | 29 +++++++++-------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee96394c..4125fc9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,9 +21,6 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly # nightly is required for fmt - components: rustfmt, clippy - name: Set up Cargo Cache uses: Swatinem/rust-cache@v2 @@ -33,11 +30,6 @@ jobs: - name: Check run: cargo check - - name: Format - run: | - cargo fmt --all -- --check - cargo clippy --workspace --bins -- -D warnings - - name: Run tests run: cargo test --verbose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 214ebe95..23a87032 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,8 +15,6 @@ jobs: - 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 @@ -38,28 +36,19 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + + - name: Set up Android NDK + uses: nttld/setup-ndk@v1 + with: + link-to-sdk: true + ndk-version: r28-beta1 + - 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 From 2e77dfe1a67331bcff122c72e572aa770e710d12 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Wed, 11 Dec 2024 23:24:50 -0300 Subject: [PATCH 14/28] Fix: speedup `build.yml` and add targets to `release.yml` --- .github/workflows/build.yml | 3 --- .github/workflows/release.yml | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4125fc9e..8ad3d426 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,9 +27,6 @@ jobs: with: save-if: false - - name: Check - run: cargo check - - name: Run tests run: cargo test --verbose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23a87032..81ec5e3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,8 @@ jobs: - 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 @@ -24,9 +26,6 @@ jobs: - name: Run tests run: cargo test --workspace --verbose - - name: Build Release - run: cargo build --verbose --release - - name: Install JDK uses: actions/setup-java@v4.2.1 with: From 3c572a6bb5990e9042b933465fbaaa96056207ef Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Thu, 12 Dec 2024 08:08:27 -0300 Subject: [PATCH 15/28] Define `GITHUB_ACTOR` as well --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 81ec5e3e..985681e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,4 +52,5 @@ jobs: run: gradle publish working-directory: ./java env: + GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5cec42497f7da4b339fb643fb6af6c09dc312081 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Thu, 12 Dec 2024 08:30:50 -0300 Subject: [PATCH 16/28] Wrap GitHubPackages URI in `uri(string)` --- java/lib/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/lib/build.gradle b/java/lib/build.gradle index 80a06455..472e90f2 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -85,11 +85,11 @@ publishing { repositories { maven { name = 'GithubPackages' - url = 'https://maven.pkg.github.com/ARK-Builders/ark-core' + url = uri('https://maven.pkg.github.com/ARK-Builders/ark-core') credentials { username = System.getenv('GITHUB_ACTOR') password = System.getenv('GITHUB_TOKEN') } } } -} \ No newline at end of file +} From b6c4d2c85f92bf11b09f6a0361d3d36cf5c83c5b Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Thu, 12 Dec 2024 08:50:56 -0300 Subject: [PATCH 17/28] Copy old `publications` From: https://github.com/ARK-Builders/ark-core/blob/23567aeb6b1184cd004ab7419b8e1895be618024/java/lib/build.gradle.kts --- java/lib/build.gradle | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/java/lib/build.gradle b/java/lib/build.gradle index 472e90f2..2ac522a4 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -3,6 +3,9 @@ apply plugin: 'com.android.library' apply plugin: 'pl.allegro.tech.build.axion-release' apply plugin: 'org.mozilla.rust-android-gradle.rust-android' +version = scmVersion.version +group = "dev.arkbuilders.core" + android { ndkVersion '28.0.12433566' namespace 'dev.arkbuilders.core' @@ -62,25 +65,13 @@ tasks.configureEach { task -> } } -def libVersion = scmVersion.version publishing { publications { - release(MavenPublication) { - groupId = 'dev.arkbuilders' - artifactId = 'core' - version = libVersion + Maven(MavenPublication) { afterEvaluate { from components.release } } - debug(MavenPublication) { - groupId = 'dev.arkbuilders' - artifactId = 'core-debug' - version = libVersion - afterEvaluate { - from components.debug - } - } } repositories { maven { From 5b1ea611503d44659ecd6fdf2a4a35d75b1e2f38 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Thu, 12 Dec 2024 09:14:35 -0300 Subject: [PATCH 18/28] Update permissions and publications --- .github/workflows/release.yml | 6 +++--- java/lib/build.gradle | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 985681e1..816e5548 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,10 +6,11 @@ on: - "*" jobs: - build: + release: runs-on: ubuntu-latest permissions: - contents: write + contents: read + packages: write steps: - uses: actions/checkout@v4 @@ -52,5 +53,4 @@ jobs: run: gradle publish working-directory: ./java env: - GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/java/lib/build.gradle b/java/lib/build.gradle index 2ac522a4..ebe4aa04 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -3,9 +3,6 @@ apply plugin: 'com.android.library' apply plugin: 'pl.allegro.tech.build.axion-release' apply plugin: 'org.mozilla.rust-android-gradle.rust-android' -version = scmVersion.version -group = "dev.arkbuilders.core" - android { ndkVersion '28.0.12433566' namespace 'dev.arkbuilders.core' @@ -65,9 +62,13 @@ tasks.configureEach { task -> } } +def libVersion = scmVersion.version publishing { publications { - Maven(MavenPublication) { + release(MavenPublication) { + groupId = 'dev.arkbuilders' + artifactId = 'core' + version = libVersion afterEvaluate { from components.release } From 229b48f7e35a4d9f715d01bf6120f17b0a7bea62 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Thu, 12 Dec 2024 09:34:01 -0300 Subject: [PATCH 19/28] Use tag name as version and clean publication --- .github/workflows/release.yml | 1 + java/build.gradle | 1 - java/gradle/libs.versions.toml | 2 -- java/lib/build.gradle | 6 ++---- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 816e5548..0ebcb24e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,4 +53,5 @@ jobs: run: gradle publish working-directory: ./java env: + RELEASE_VERSION: ${{ github.ref_name }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/java/build.gradle b/java/build.gradle index 761e59d2..448748b2 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -7,7 +7,6 @@ buildscript { dependencies { classpath libs.gradle classpath libs.rust.android - classpath libs.axion.release.plugin } } diff --git a/java/gradle/libs.versions.toml b/java/gradle/libs.versions.toml index b6c31875..d41e224a 100644 --- a/java/gradle/libs.versions.toml +++ b/java/gradle/libs.versions.toml @@ -2,11 +2,9 @@ gradle = "8.7.3" rustAndroid = "0.9.4" junitJupiterApi = "5.11.3" -axionReleasePlugin = "1.17.0" [libraries] gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } rust-android = { module = "org.mozilla.rust-android-gradle:plugin", version.ref = "rustAndroid" } junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junitJupiterApi" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiterApi" } -axion-release-plugin = { module = "pl.allegro.tech.build:axion-release-plugin", version.ref = "axionReleasePlugin" } diff --git a/java/lib/build.gradle b/java/lib/build.gradle index ebe4aa04..2753e99b 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'maven-publish' apply plugin: 'com.android.library' -apply plugin: 'pl.allegro.tech.build.axion-release' apply plugin: 'org.mozilla.rust-android-gradle.rust-android' android { @@ -62,13 +61,12 @@ tasks.configureEach { task -> } } -def libVersion = scmVersion.version publishing { publications { release(MavenPublication) { - groupId = 'dev.arkbuilders' artifactId = 'core' - version = libVersion + groupId = 'dev.arkbuilders' + version = System.getenv('RELEASE_VERSION') afterEvaluate { from components.release } From 78d058d17a0a2eb1674fd417a2e84d32ed8dd66d Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 09:47:27 -0300 Subject: [PATCH 20/28] Remove local configuration --- java/.gitignore | 3 ++- java/local.properties | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 java/local.properties diff --git a/java/.gitignore b/java/.gitignore index f6d64d1f..730cf68f 100644 --- a/java/.gitignore +++ b/java/.gitignore @@ -1,6 +1,7 @@ # Ignore Gradle project-specific cache directory .gradle +.local.properties # Ignore Gradle build output directory build -*.log \ No newline at end of file +*.log diff --git a/java/local.properties b/java/local.properties deleted file mode 100644 index 61ec5043..00000000 --- a/java/local.properties +++ /dev/null @@ -1,8 +0,0 @@ -## This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Tue Dec 10 10:08:23 BRT 2024 -sdk.dir=/home/oluiscabral/Android/Sdk From 7e2bd8bdcacaae9a63cfb4c7a7bb65f79583176e Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 20:01:37 -0300 Subject: [PATCH 21/28] add `rustfmt` formatting check --- .github/workflows/build.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ad3d426..a2adc614 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,21 @@ env: CARGO_TERM_COLOR: always jobs: + format: + name: Code Formatting Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Nightly Rust with rustfmt + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + components: rustfmt + + - name: Run rustfmt + run: cargo fmt --all -- --check + linux: name: Build on Linux runs-on: ubuntu-latest From 54d966591cbf77b0caa0fa16c6fa74291ff72af0 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 20:36:35 -0300 Subject: [PATCH 22/28] Try using regex as released tag evaluator --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ebcb24e..a7192c60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - "*" + - ^v\d+(?:\.\d+){2}$ jobs: release: @@ -53,5 +53,5 @@ jobs: run: gradle publish working-directory: ./java env: - RELEASE_VERSION: ${{ github.ref_name }} + RELEASE_VERSION: ${{ github.ref_name:1 }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 736a206ad07628f1222e816bc46e8cb636bc1b67 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 20:56:15 -0300 Subject: [PATCH 23/28] Try new release regex condition --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7192c60..4d490e6e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - ^v\d+(?:\.\d+){2}$ + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: release: From ceef1353ee2f19c560361e3c885081f820b467bb Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 21:00:13 -0300 Subject: [PATCH 24/28] Fix: Properly remove first character of released tag --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d490e6e..f93bb707 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,5 +53,5 @@ jobs: run: gradle publish working-directory: ./java env: - RELEASE_VERSION: ${{ github.ref_name:1 }} + RELEASE_VERSION: ${{ github.ref_name[1] }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9cd65f39d2e0f07a1db87ea4d6183559993ef007 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 21:22:43 -0300 Subject: [PATCH 25/28] Fix: Try using `GITHUB_REF_NAME` to remove first char of released tag --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f93bb707..1ccd9bd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' + - "v[0-9]+.[0-9]+.[0-9]+" jobs: release: @@ -53,5 +53,5 @@ jobs: run: gradle publish working-directory: ./java env: - RELEASE_VERSION: ${{ github.ref_name[1] }} + RELEASE_VERSION: ${GITHUB_REF_NAME:1} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0c1fa092d804a335f0b02ad8f73cd01fbdbaf7a9 Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Sat, 14 Dec 2024 21:47:40 -0300 Subject: [PATCH 26/28] Fix: export `RELEASE_VERSION` instead of setting it as `env` in yml --- .github/workflows/release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ccd9bd9..1e6b8590 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,8 +50,9 @@ jobs: working-directory: ./java - name: Publish Java release - run: gradle publish + run: | + export RELEASE_VERSION=$(echo "${{ github.ref_name }}" | cut -c2-) + gradle publish working-directory: ./java env: - RELEASE_VERSION: ${GITHUB_REF_NAME:1} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 61cd3f558dbf82b00fb39431b60ea65e5bf6366c Mon Sep 17 00:00:00 2001 From: oluiscabral Date: Mon, 16 Dec 2024 08:44:53 -0300 Subject: [PATCH 27/28] Update Android NDK and `java/README.md` instructions --- .github/workflows/build.yml | 6 +++--- .github/workflows/release.yml | 2 +- java/README.md | 19 +++++-------------- java/lib/build.gradle | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2adc614..d7d5311f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,7 +67,7 @@ jobs: uses: nttld/setup-ndk@v1 with: link-to-sdk: true - ndk-version: r28-beta1 + ndk-version: r28-beta2 - name: Java tests run: gradle test @@ -113,7 +113,7 @@ jobs: uses: nttld/setup-ndk@v1 with: link-to-sdk: true - ndk-version: r28-beta1 + ndk-version: r28-beta2 - name: Java tests run: gradle test @@ -159,7 +159,7 @@ jobs: uses: nttld/setup-ndk@v1 with: link-to-sdk: true - ndk-version: r28-beta1 + ndk-version: r28-beta2 - name: Java tests run: gradle test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e6b8590..f312ef2d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: uses: nttld/setup-ndk@v1 with: link-to-sdk: true - ndk-version: r28-beta1 + ndk-version: r28-beta2 - name: Java tests run: gradle test diff --git a/java/README.md b/java/README.md index 44c50984..a88e7112 100644 --- a/java/README.md +++ b/java/README.md @@ -12,19 +12,20 @@ To build the bindings and set up the environment, follow these steps: ### Prerequisites +- Ensure you have Gradle installed. You can install it from [Gradle](https://gradle.org/install/_) - Ensure you have the Rust toolchain installed. You can install it from [rustup](https://rustup.rs/). - Ensure you have a JDK installed. You can download it from [AdoptOpenJDK](https://adoptopenjdk.net/). -- Ensure you have Gradle installed. You can install it from [Gradle](https://gradle.org/install/_) +- Ensure you have Android NDK version `28.0.12674087` installed. You can install it from [NDK](https://github.com/android/ndk/releases/tag/r28-rc1) ### Steps -1. **Build the Rust Library:** Run the following command to compile the Rust code and generate the dynamic library: +1. **Add Android Architecture Targets:** Run the following command to add support for different Android OS architectures: ```sh -cargo build --release +rustup add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android ``` -This will compile the Rust code and generate the dynamic library in the `target/release` directory. +This will make possible to compile the Rust code for different Android OS architectures. 2. **Build the Java Project:** To compile build the project, run: @@ -34,16 +35,6 @@ This will compile the Rust code and generate the dynamic library in the `target/ This will compile the Java code and generate the JAR file in the `lib/build/libs` directory. This will also run the unit tests. -## Documentation - -To generate the Javadoc documentation, run: - -```sh -./gradlew javadoc -``` - -The documentation will be generated in the `lib/build/docs/javadoc` directory. - ## Cleaning the Build To clean the build, run: diff --git a/java/lib/build.gradle b/java/lib/build.gradle index 2753e99b..a60aa658 100644 --- a/java/lib/build.gradle +++ b/java/lib/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.library' apply plugin: 'org.mozilla.rust-android-gradle.rust-android' android { - ndkVersion '28.0.12433566' + ndkVersion '28.0.12674087' namespace 'dev.arkbuilders.core' defaultConfig { compileSdk 35 From 14b2fff48b4c49c8bbd3b8b4878dde872482667d Mon Sep 17 00:00:00 2001 From: Tarek Elsayed <60650661+tareknaser@users.noreply.github.com> Date: Sat, 4 Jan 2025 19:41:41 +0200 Subject: [PATCH 28/28] CI Workflow Refactor (#96) * refactor(CI): move Java bindings into a separate job * chore(CI): remove old benchmark workflow and integrate into build process * refactor(CI): consolidate OS jobs into a single build-and-test job --- Signed-off-by: Tarek --- .github/workflows/benchmark.yml | 20 ----- .github/workflows/build.yml | 126 ++++++++++---------------------- .github/workflows/weekly.yml | 65 ++-------------- 3 files changed, 45 insertions(+), 166 deletions(-) delete mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index d57fc7e4..00000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Run benchmarks - -on: - pull_request: - branches: - - main - -jobs: - run_benchmarks: - name: Run Benchmarks - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Run Criterion - uses: boa-dev/criterion-compare-action@v3 - with: - branchName: ${{ github.base_ref }} - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d7d5311f..5d0bc6a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Verify build +name: Verify Build on: push: @@ -17,7 +17,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Nightly Rust with rustfmt uses: dtolnay/rust-toolchain@stable with: @@ -27,75 +26,56 @@ jobs: - name: Run rustfmt run: cargo fmt --all -- --check - linux: - name: Build on Linux - runs-on: ubuntu-latest + build-and-test: + name: Build and Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + # We also run on macOS arm in the weekly workflow. + os: [ubuntu-latest, windows-latest, macos-14] steps: - uses: actions/checkout@v4 - - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Set up Cargo Cache uses: Swatinem/rust-cache@v2 with: save-if: false - name: Run tests - run: cargo test --verbose + run: cargo test --workspace --verbose - name: Build Release run: cargo build --verbose --release + # `ark-cli-watch.sh` script tests the functionality of `ark-cli watch`, + # which monitors a directory for file changes using a filesystem watcher and updates the index file. + # We need to run it on each platform to ensure it works across all OSes. - name: Run `ark-cli watch` test run: ./integration/ark-cli-watch.sh - - name: Install JDK - uses: actions/setup-java@v4.2.1 + - name: Upload Release Build + uses: actions/upload-artifact@v3 with: - distribution: "temurin" - java-version: "22" - - - name: Set up Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Set up Android SDK - uses: android-actions/setup-android@v3 + name: release-build-${{ matrix.os }} + path: target/release/ - - name: Set up Android NDK - uses: nttld/setup-ndk@v1 - with: - link-to-sdk: true - ndk-version: r28-beta2 - - - name: Java tests - run: gradle test - working-directory: ./java - - windows: - name: Test on Windows - runs-on: windows-latest + java-bindings: + name: Java Bindings + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-14] + needs: build-and-test steps: - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Set up Cargo Cache - uses: Swatinem/rust-cache@v2 + - name: Download Build Artifacts + uses: actions/download-artifact@v3 with: - save-if: false - - - name: Run tests - run: cargo test --workspace --verbose - - - name: Build Release - run: cargo build --verbose --release - - - name: Run `ark-cli watch` test - run: ./integration/ark-cli-watch.sh + name: release-build-${{ matrix.os }} + path: ./release - name: Install JDK uses: actions/setup-java@v4.2.1 @@ -115,52 +95,22 @@ jobs: link-to-sdk: true ndk-version: r28-beta2 - - name: Java tests + - name: Run Java Tests run: gradle test working-directory: ./java - mac-intel: - name: Test on macOS Intel - runs-on: macos-14 + benchmarks: + name: Run Benchmarks + runs-on: ubuntu-latest + needs: java-bindings + # We only want to run benchmarks in case of a pull request + if: ${{ github.event_name == 'pull_request' }} steps: - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - 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: Run `ark-cli watch` test - run: ./integration/ark-cli-watch.sh - - - name: Install JDK - uses: actions/setup-java@v4.2.1 + - name: Run Criterion + uses: boa-dev/criterion-compare-action@v3 with: - distribution: "temurin" - java-version: "22" - - - name: Set up Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Set up Android SDK - uses: android-actions/setup-android@v3 - - - name: Set up Android NDK - uses: nttld/setup-ndk@v1 - with: - link-to-sdk: true - ndk-version: r28-beta2 - - - name: Java tests - run: gradle test - working-directory: ./java + branchName: ${{ github.base_ref }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index 308ea6fa..484605ec 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -1,4 +1,4 @@ -name: Weekly testing +name: Weekly Testing on: push: @@ -9,63 +9,12 @@ on: - cron: "0 0 * * 0" jobs: - linux: - name: Linux - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - 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 - - windows: - name: Windows - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - - - 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 - - mac-intel: - name: MacOS Intel - runs-on: macos-14 - - steps: - - uses: actions/checkout@v4 - - - 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 - - mac-arm: - name: MacOS ARM - runs-on: macos-13-xlarge + build-and-test: + name: Build and Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-14, macos-13-xlarge] steps: - uses: actions/checkout@v4