From 33563e292305f1ece28337f263c75fd1248b1655 Mon Sep 17 00:00:00 2001 From: nitro-neal <5314059+nitro-neal@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:07:31 -0500 Subject: [PATCH] update github actions (#124) * update github actions * fix lint * lint * update to 4.0.0-alpha-1 * get windows to be like web5-rs * fix windows * fix windows build * fix windows * update windows * update example --- .github/workflows/ci.yml | 132 ++++++++++++------ .github/workflows/release.yml | 54 ++++--- bound/kt/pom.xml | 2 +- bound/kt/src/main/resources/check_crate.sh | 21 +++ crates/tbdex/src/http/exchanges.rs | 1 + .../hosted-wallet-kt/pfi/build.gradle.kts | 4 +- .../hosted-wallet-kt/wallet/build.gradle.kts | 4 +- 7 files changed, 149 insertions(+), 69 deletions(-) create mode 100755 bound/kt/src/main/resources/check_crate.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6541c386..ac222fbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,13 +24,70 @@ env: TBDEX_SDK_LOG_LEVEL: debug jobs: + test: + permissions: + id-token: write + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install Rust 1.74.0 + run: rustup toolchain install 1.74.0 + - name: Set Rust 1.74.0 as default + run: rustup default 1.74.0 + - name: Test + run: | + rustup component add llvm-tools-preview + cargo install grcov + cargo test --package tbdex + env: + RUSTFLAGS: -Cinstrument-coverage + LLVM_PROFILE_FILE: tbdex-rs-%p-%m.profraw + - name: Upload test coverage to Codecov + uses: codecov/codecov-action@v4.5.0 + with: + use_oidc: true + files: '*.profraw' + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + - name: Setup + run: just setup + - name: Lint + run: just lint + + rust-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + - name: Setup + run: just setup + - name: Test + run: just test + build_aarch64_apple_darwin: runs-on: macos-latest name: Build aarch64-apple-darwin target steps: - - uses: actions/checkout@v2 - - name: Install Rust - run: rustup toolchain install stable + - uses: actions/checkout@v4 + - name: Install Rust 1.74.0 + run: rustup toolchain install 1.74.0 + - name: Set Rust 1.74.0 as default + run: rustup default 1.74.0 - name: Run Build Script run: | cd bindings/tbdex_uniffi/libtargets/aarch64_apple_darwin @@ -49,9 +106,11 @@ jobs: runs-on: macos-12 name: Build x86_64-apple-darwin target steps: - - uses: actions/checkout@v2 - - name: Install Rust - run: rustup toolchain install stable + - uses: actions/checkout@v4 + - name: Install Rust 1.74.0 + run: rustup toolchain install 1.74.0 + - name: Set Rust 1.74.0 as default + run: rustup default 1.74.0 - name: Run Build Script run: | cd bindings/tbdex_uniffi/libtargets/x86_64_apple_darwin @@ -70,7 +129,11 @@ jobs: runs-on: ubuntu-latest name: Build x86_64-unknown-linux-gnu target steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Install Rust 1.74.0 + run: rustup toolchain install 1.74.0 + - name: Set Rust 1.74.0 as default + run: rustup default 1.74.0 - name: Run Build Script run: | cd bindings/tbdex_uniffi/libtargets/x86_64_unknown_linux_gnu @@ -89,7 +152,11 @@ jobs: runs-on: ubuntu-latest name: Build x86_64-unknown-linux-musl target steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Install Rust 1.74.0 + run: rustup toolchain install 1.74.0 + - name: Set Rust 1.74.0 as default + run: rustup default 1.74.0 - name: Run Build Script run: | cd bindings/tbdex_uniffi/libtargets/x86_64_unknown_linux_musl @@ -116,39 +183,17 @@ jobs: - name: Build the library run: | cargo build --target x86_64-pc-windows-msvc --release --package tbdex_uniffi - mkdir -p bound/kt/src/main/resources + if (-not (Test-Path -Path "bound/kt/src/main/resources")) { + New-Item -ItemType Directory -Path "bound/kt/src/main/resources" + } cp target/x86_64-pc-windows-msvc/release/tbdex_uniffi.dll bound/kt/src/main/resources/tbdex_uniffi_x86_64_pc_windows_msvc.dll + shell: powershell - name: Upload .dll uses: actions/upload-artifact@v4.0.0 with: name: x86_64-pc-windows-msvc-dll path: bound/kt/src/main/resources/tbdex_uniffi_x86_64_pc_windows_msvc.dll - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1 - with: - cache: true - - name: Setup - run: just setup - - name: Lint - run: just lint - - rust-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1 - with: - cache: true - - name: Setup - run: just setup - - name: Test - run: just test kotlin-build-test-deploy-snapshot: needs: @@ -168,7 +213,7 @@ jobs: distribution: "adopt" java-version: "11" - # Cache Maven repo + # Cache Maven repo - uses: actions/cache@v3 with: path: ~/.m2/repository @@ -181,7 +226,11 @@ jobs: run: | # Version resolution: use provided if [ -n "${{ github.event.inputs.version }}" ]; then - resolvedVersion=${{ github.event.inputs.version }} + if [[ "${{ github.event.inputs.version }}" != *-SNAPSHOT ]]; then + resolvedVersion="${{ github.event.inputs.version }}-SNAPSHOT" + else + resolvedVersion="${{ github.event.inputs.version }}" + fi # Otherwise, construct a version for deployment in form X.Y.Z-commit-$shortSHA-SNAPSHOT else longSHA=$(git rev-parse --verify HEAD) @@ -193,8 +242,7 @@ jobs: echo "Resolved SNAPSHOT Version: $resolvedVersion" echo "resolved_version=$resolvedVersion" >> $GITHUB_OUTPUT - # Package up the native binaries - #TODO Centralize this block as we re-use it via copy/paste right now + # Download and package the native binaries - name: Download MacOS aarch64 Native Library uses: actions/download-artifact@v4.1.7 with: @@ -221,7 +269,7 @@ jobs: name: x86_64-pc-windows-msvc-dll path: bound/kt/src/main/resources/ - - name: Build and Test Kotlin Project + - name: Deploy Snapshot / Verify run: | # cd into the Kotlin project @@ -309,6 +357,8 @@ jobs: cache: true - name: Setup run: just setup + - name: Install latest stable Rust + run: rustup install stable && rustup default stable - name: Install Nextest run: cargo install cargo-nextest - name: Create nextest.toml @@ -326,8 +376,8 @@ jobs: sed -i '' 's/2.17.0 5.12.0 1.8.1 - commit-f28d90c-SNAPSHOT + 4.0.0-alpha-1 5.10.1 diff --git a/bound/kt/src/main/resources/check_crate.sh b/bound/kt/src/main/resources/check_crate.sh new file mode 100755 index 00000000..ea0f5213 --- /dev/null +++ b/bound/kt/src/main/resources/check_crate.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +files=( + "libtbdex_uniffi_aarch64_apple_darwin.dylib" + "libtbdex_uniffi_x86_64_apple_darwin.dylib" + "libweb5_uniffi_x86_64_unknown_linux_gnu.so" + "libweb5_uniffi_x86_64_unknown_linux_musl.so" +) + +crate_name="crate_name" # Replace with the actual crate name + +for file in "${files[@]}"; do + if [[ -f "$file" ]]; then + echo "Checking $file for $crate_name..." + nm -D "$file" | grep "$crate_name" && echo "$crate_name found in $file with gnm" + objdump -T "$file" | grep "$crate_name" && echo "$crate_name found in $file with gobjdump" + else + echo "$file does not exist" + fi +done + diff --git a/crates/tbdex/src/http/exchanges.rs b/crates/tbdex/src/http/exchanges.rs index 21de6e6a..69b4116a 100644 --- a/crates/tbdex/src/http/exchanges.rs +++ b/crates/tbdex/src/http/exchanges.rs @@ -238,6 +238,7 @@ mod tests { use super::*; use std::fs; + #[allow(dead_code)] #[derive(Debug, serde::Deserialize)] pub struct TestVector { pub input: String, diff --git a/examples/hosted-wallet-kt/pfi/build.gradle.kts b/examples/hosted-wallet-kt/pfi/build.gradle.kts index 46e37b45..be17e8ba 100644 --- a/examples/hosted-wallet-kt/pfi/build.gradle.kts +++ b/examples/hosted-wallet-kt/pfi/build.gradle.kts @@ -27,10 +27,10 @@ dependencies { // For a snapshot from maven // Update the short git commit SHA below - implementation("xyz.block:tbdex:commit-81f2d76-SNAPSHOT") + implementation("xyz.block:tbdex:commit-5b39d6d-SNAPSHOT") // For the official release on maven central - // implementation("xyz.block:tbdex:3.0.0") + // implementation("xyz.block:tbdex:4.0.0") } java { diff --git a/examples/hosted-wallet-kt/wallet/build.gradle.kts b/examples/hosted-wallet-kt/wallet/build.gradle.kts index b24cead9..48755b71 100644 --- a/examples/hosted-wallet-kt/wallet/build.gradle.kts +++ b/examples/hosted-wallet-kt/wallet/build.gradle.kts @@ -26,10 +26,10 @@ dependencies { // For a snapshot from maven // Update the short git commit SHA below - implementation("xyz.block:tbdex:commit-81f2d76-SNAPSHOT") + implementation("xyz.block:tbdex:commit-5b39d6d-SNAPSHOT") // For the official release on maven central - // implementation("xyz.block:tbdex:3.0.0") + // implementation("xyz.block:tbdex:4.0.0") } java {