Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
update github actions (#124)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nitro-neal authored Sep 25, 2024
1 parent 5b39d6d commit 33563e2
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 69 deletions.
132 changes: 91 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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/[email protected]
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:
Expand All @@ -168,7 +213,7 @@ jobs:
distribution: "adopt"
java-version: "11"

# Cache Maven repo
# Cache Maven repo
- uses: actions/cache@v3
with:
path: ~/.m2/repository
Expand All @@ -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)
Expand All @@ -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/[email protected]
with:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -326,8 +376,8 @@ jobs:
sed -i '' 's/<testsuite name="tbdex"/<testsuite name="TbdexTestVectorsProtocolTest"/' target/nextest/ci/junit.xml
- name: Move Test Results
run: mv target/nextest/ci/junit.xml test-results/rust-test-results.xml
- name: Upload Rust Test Results
uses: actions/upload-artifact@v3
- name: Upload Rust Test Vector Results
uses: actions/upload-artifact@v4.0.0
with:
name: rust-test-results
path: test-results/rust-test-results.xml
54 changes: 31 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:

git-tag:
runs-on: ubuntu-latest
needs: run-ci
needs:
- run-ci
outputs:
RELEASE_TAG: ${{ steps.set-version-and-tag.outputs.RELEASE_TAG }}
RELEASE_VERSION: ${{ steps.set-version-and-tag.outputs.RELEASE_VERSION }}
Expand All @@ -43,8 +44,7 @@ jobs:
git config user.email "[email protected]"
# Cache Maven repo
- id: cache
uses: actions/cache@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
-DnewVersion=$nextVersion
git add -Av
git commit -m "[TBD Release Manager 🚀] Setting next development version after $version to: $nextVersion"
git push origin main
git push origin "${GITHUB_REF#refs/heads/}"
git push origin $tagName
kotlin-release-to-tbd-artifactory-and-maven-central:
Expand Down Expand Up @@ -130,13 +130,12 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
# 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/[email protected]
with:
name: aarch64-apple-darwin-dylib
path: bound/kt/src/main/resources/
name: aarch64-apple-darwin-dylib
path: bound/kt/src/main/resources/
- name: Download MacOS x86_64 Native Library
uses: actions/[email protected]
with:
Expand All @@ -160,26 +159,35 @@ jobs:

- name: Deploy Release Version of Kotlin Project to Maven Central
run: |
# cd into the Kotlin project
cd bound/kt/
# Publish to Sonatype
# Precondition check: Only attempt to publish artifact if we have credentials
if [ -n "${{ secrets.SONATYPE_PASSWORD }}" ]; then
# Maven deploy lifecycle will build, run tests, verify, sign, and deploy
mvn deploy --batch-mode \
--settings .maven_settings.xml \
-P ossrh,sign-artifacts
else
echo "Error: No credentials"
exit 1
fi
# cd into the Kotlin project
cd bound/kt/
# Publish to Sonatype
# Precondition check: Only attempt to publish artifact if we have credentials
if [ -n "${{ secrets.SONATYPE_PASSWORD }}" ]; then
# Maven deploy lifecycle will build, run tests, verify, sign, and deploy
mvn deploy --batch-mode \
--settings .maven_settings.xml \
-P ossrh,sign-artifacts
else
echo "Error: No credentials"
exit 1
fi
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }}
SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }}

- name: Create GitHub Release
uses: actions/[email protected]
id: release
with:
tag_name: "v${{ github.event.inputs.version }}"
release_name: "v${{ github.event.inputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

kotlin-docs:
permissions:
contents: read
Expand All @@ -201,7 +209,7 @@ jobs:
${{ runner.os }}-maven-
- run: mvn dokka:dokka
working-directory: bound/kt
- run: mkdir -p _site/kt/${GITHUB_REF_NAME} && mv bound/kt/target/dokka/* _site/kt/${GITHUB_REF_NAME}
- run: mkdir -p _site/kt/v${{ github.event.inputs.version }} && mv bound/kt/target/dokka/* _site/kt/v${{ github.event.inputs.version }}
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Setup Pages
Expand Down
2 changes: 1 addition & 1 deletion bound/kt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<version.com.fasterxml.jackson>2.17.0</version.com.fasterxml.jackson>
<version.net.java.dev.jna>5.12.0</version.net.java.dev.jna>
<version.org.jetbrains.kotlinx.kotlinx.coroutines.core>1.8.1</version.org.jetbrains.kotlinx.kotlinx.coroutines.core>
<version.xyz.block.web5>commit-f28d90c-SNAPSHOT</version.xyz.block.web5>
<version.xyz.block.web5>4.0.0-alpha-1</version.xyz.block.web5>

<!-- Versioning for Test Dependencies -->
<version.org.junit.jupiter>5.10.1</version.org.junit.jupiter>
Expand Down
21 changes: 21 additions & 0 deletions bound/kt/src/main/resources/check_crate.sh
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions crates/tbdex/src/http/exchanges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ mod tests {
use super::*;
use std::fs;

#[allow(dead_code)]
#[derive(Debug, serde::Deserialize)]
pub struct TestVector<T> {
pub input: String,
Expand Down
4 changes: 2 additions & 2 deletions examples/hosted-wallet-kt/pfi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions examples/hosted-wallet-kt/wallet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 33563e2

Please sign in to comment.