From 16b7f257d625c5f4a41265fe6f7c7acfa677a755 Mon Sep 17 00:00:00 2001 From: Ahmed Moussa Date: Fri, 31 May 2024 14:02:31 +0300 Subject: [PATCH] ci: Re-enable CI for KMP Signed-off-by: Ahmed Moussa --- .github/workflows/pull-request.yml | 9 +- .github/workflows/release.yml | 149 +++++++++--------- .../anoncred-wrapper-rust/build.gradle.kts | 49 +----- 3 files changed, 77 insertions(+), 130 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fe1a1749..00637d96 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -14,11 +14,11 @@ env: ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }} ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} -on: [pull_request] +on: [ pull_request ] jobs: build: - runs-on: macos-latest + runs-on: macos-13 steps: - name: "Checkout the repo" uses: actions/checkout@v4 @@ -40,11 +40,6 @@ jobs: working-directory: ./anoncred-kmm run: ./gradlew ktlintCheck - - name: "Install Homebrew" - run: > - /bin/bash -c "$(curl -fsSL - https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - - name: "Install autoconf, automake, libtool" run: | brew install autoconf automake libtool diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d20da31c..b0f23393 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,7 +46,7 @@ jobs: with: commit_message: "chore: prepare release ${{github.event.inputs.tag}}" tagging_message: ${{github.event.inputs.tag}} - + - name: Upload library artifacts uses: actions/upload-artifact@v3 with: @@ -65,82 +65,8 @@ jobs: file: uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip asset_name: "libanoncreds.xcframework.zip" -# build-kmp: -# name: "Build KMP" -# runs-on: macos-latest -# steps: -# - name: Checkout the repo -# uses: actions/checkout@v3 -# with: -# submodules: recursive -# token: ${{ secrets.ATALA_GITHUB_TOKEN }} -# fetch-depth: 0 -# -# - name: "Install Java ${{ env.JAVA_VERSION }}" -# uses: actions/setup-java@v3 -# with: -# java-version: "${{ env.JAVA_VERSION }}" -# distribution: zulu -# -# - name: Install Homebrew -# run: > -# /bin/bash -c "$(curl -fsSL -# https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -# -# - name: "Install autoconf, automake, libtool" -# run: | -# brew install autoconf automake libtool -# -# - name: "Install Mac ToolChain" -# run: | -# brew tap messense/macos-cross-toolchains -# -# - name: "Install Linux GNU for x86_64" -# run: | -# rm '/usr/local/bin/2to3' -# rm '/usr/local/bin/2to3-3.11' -# rm '/usr/local/bin/2to3-3.12' -# rm '/usr/local/bin/python3' -# rm '/usr/local/bin/python3.11' -# rm '/usr/local/bin/python3.12' -# rm '/usr/local/bin/idle3' -# rm '/usr/local/bin/idle3.11' -# rm '/usr/local/bin/idle3.12' -# rm '/usr/local/bin/pydoc3' -# rm '/usr/local/bin/pydoc3.11' -# rm '/usr/local/bin/pydoc3.12' -# rm '/usr/local/bin/python3-config' -# rm '/usr/local/bin/python3.11-config' -# rm '/usr/local/bin/python3.12-config' -# rm -r '/usr/local/lib/node_modules' -# brew install --overwrite x86_64-unknown-linux-gnu -# -# - name: "Install Linux GNU for aarch64" -# run: | -# brew install --overwrite aarch64-unknown-linux-gnu -# -# - name: "Install Rust Targets" -# run: | -# rustup target add armv7-linux-androideabi -# rustup target add i686-linux-android -# rustup target add aarch64-linux-android -# rustup target add x86_64-linux-android -# rustup target add aarch64-apple-darwin -# rustup target add x86_64-apple-darwin -# rustup target add aarch64-unknown-linux-gnu -# rustup target add x86_64-unknown-linux-gnu -# -# - name: "Install Rust Cargo NDK" -# run: | -# cargo install cargo-ndk -# -# - name: "Publish to GitHub Maven" -# working-directory: ./anoncred-kmm -# run: | -# ./gradlew :anoncreds-kmp:publishAllPublicationsToGitHubPackagesRepository - build-release: - needs: [build-swift-package] + needs: [ build-swift-package ] name: Build Library strategy: @@ -203,7 +129,7 @@ jobs: run: | cd uniffi cargo build --release --target ${{matrix.target}} - + - name: Upload library artifacts uses: actions/upload-artifact@v3 with: @@ -229,3 +155,72 @@ jobs: tag: ${{github.event.inputs.tag}} file: library-${{ matrix.architecture }}.tar.gz asset_name: "library-${{ matrix.architecture }}-${{ github.sha }}.tar.gz" + + build-kmp: + name: "Build KMP" + runs-on: macos-13 + steps: + - name: Checkout the repo + uses: actions/checkout@v4 + with: + submodules: recursive + token: ${{ secrets.ATALA_GITHUB_TOKEN }} + fetch-depth: 0 + + - name: "Install Java ${{ env.JAVA_VERSION }}" + uses: actions/setup-java@v4 + with: + java-version: "${{ env.JAVA_VERSION }}" + distribution: zulu + + - name: "Install autoconf, automake, libtool" + run: | + brew install autoconf automake libtool + + - name: "Install Mac ToolChain" + run: | + brew tap messense/macos-cross-toolchains + + - name: "Install Linux GNU for x86_64" + run: | + rm '/usr/local/bin/2to3' + rm '/usr/local/bin/2to3-3.11' + rm '/usr/local/bin/2to3-3.12' + rm '/usr/local/bin/python3' + rm '/usr/local/bin/python3.11' + rm '/usr/local/bin/python3.12' + rm '/usr/local/bin/idle3' + rm '/usr/local/bin/idle3.11' + rm '/usr/local/bin/idle3.12' + rm '/usr/local/bin/pydoc3' + rm '/usr/local/bin/pydoc3.11' + rm '/usr/local/bin/pydoc3.12' + rm '/usr/local/bin/python3-config' + rm '/usr/local/bin/python3.11-config' + rm '/usr/local/bin/python3.12-config' + rm -r '/usr/local/lib/node_modules' + brew install --overwrite x86_64-unknown-linux-gnu + + - name: "Install Linux GNU for aarch64" + run: | + brew install --overwrite aarch64-unknown-linux-gnu + + - name: "Install Rust Targets" + run: | + rustup target add armv7-linux-androideabi + rustup target add i686-linux-android + rustup target add aarch64-linux-android + rustup target add x86_64-linux-android + rustup target add aarch64-apple-darwin + rustup target add x86_64-apple-darwin + rustup target add aarch64-unknown-linux-gnu + rustup target add x86_64-unknown-linux-gnu + + - name: "Install Rust Cargo NDK" + run: | + cargo install cargo-ndk + + - name: "Publish to GitHub Maven" + working-directory: ./anoncred-kmm + run: | + ./gradlew :anoncreds-kmp:publishAllPublicationsToSonatypeRepository diff --git a/anoncred-kmm/anoncred-wrapper-rust/build.gradle.kts b/anoncred-kmm/anoncred-wrapper-rust/build.gradle.kts index a01216d9..2a5652b0 100644 --- a/anoncred-kmm/anoncred-wrapper-rust/build.gradle.kts +++ b/anoncred-kmm/anoncred-wrapper-rust/build.gradle.kts @@ -41,17 +41,6 @@ fun Project.execWithOutput(spec: ExecSpec.() -> Unit): String { } } -/* -fun Project.commandLineWithOutput(vararg commands: String) { - val pb = ProcessBuilder() -} -*/ - -// TODO: Replace commandLine with -// val pb = ProcessBuilder("brew", "--version") -// pb.start().waitFor() -// println(pb.output) - /** * Delete the generated `Target` folder that is being generated by Rust Cargo */ @@ -67,26 +56,6 @@ tasks.matching { it.name == "clean" }.all { dependsOn(rustClean) } -/** - * Building the original Rust anoncreds lib - * @note no longer needed. - */ -val buildAnoncredsLib by tasks.register("buildAnoncredsLib") { - group = "rust" - description = "Building the original Rust anoncreds lib" - onlyIf { - rootDir - .resolve("target") - .resolve("release") - .exists() - .not() - } - workingDir = rootDir.parentFile - inputs.files(rootDir.parentFile.resolve("Cargo.toml")) - outputs.files(fileTree(rootDir.parentFile.resolve("target"))) - commandLine("cargo", "build", "--release") -} - // Compiling Tasks val buildAnonCredWrapperForMacOSArch64 by tasks.register("buildAnonCredWrapperForMacOSArch64") { @@ -260,7 +229,7 @@ val buildAnonCredWrapperForAndroidUniversal by tasks.register("buildAnonCredWrap val buildAnonCredWrapper by tasks.register("buildAnonCredWrapper") { group = "rust-compiling" description = "Build and compile AnonCred Wrapper" - dependsOn(buildAnonCredWrapperForMacOSUniversal, buildAnonCredWrapperForLinuxUniversal, buildAnonCredWrapperForAndroidUniversal) // buildAnonCredWrapperForiOSUniversal + dependsOn(buildAnonCredWrapperForMacOSUniversal, buildAnonCredWrapperForLinuxUniversal, buildAnonCredWrapperForAndroidUniversal) } // Copy Bindings Tasks @@ -376,7 +345,7 @@ val copyGeneratedBinaryForAndroid by tasks.register("copyGeneratedBinaryForAndro val copyGeneratedBinariesToCorrectLocation by tasks.register("copyGeneratedBinariesToCorrectLocation") { group = "rust-compiling" description = "Copy all generated binaries to generated resources folder" - dependsOn(copyGeneratedBinaryForMacOS, copyGeneratedBinaryForLinux, copyGeneratedBinaryForAndroid) // copyGeneratedBinaryForiOS + dependsOn(copyGeneratedBinaryForMacOS, copyGeneratedBinaryForLinux, copyGeneratedBinaryForAndroid) } /** @@ -390,18 +359,6 @@ val copyBindings by tasks.register("copyBindings") { dependsOn(copyGeneratedBinariesToCorrectLocation) } -/** - * Copy generated dylib to correct location - */ -val copyAnoncredsBinariesToProcessedResources by tasks.register("copyAnoncredsBinariesToProcessedResources") { - group = "rust-compiling" - description = "Copy generated AnonCreds binaries to generated resources folder" - include("*.so", "*.a", "*.d", "*.dylib") - from(rootDir.parentFile.resolve("target").resolve("release")) - into(rootDir.resolve("anoncreds-kmp").resolve("build").resolve("generatedResources").resolve("jvm").resolve("main")) - dependsOn(buildAnoncredsLib) -} - /** * Generate rust documentation */ @@ -631,7 +588,7 @@ val buildRust by tasks.register("buildRust") { moveRustSrcFiles } mustRunAfter(moveRustSrcFiles) - dependsOn(moveRustSrcFiles, requiredInstallation, verifyRust, copyBindings, copyAnoncredsBinariesToProcessedResources) + dependsOn(moveRustSrcFiles, copyBindings) } afterEvaluate {