From 2715aa1bdd2690f0a061b7d249ebc5f7b8ed4adf Mon Sep 17 00:00:00 2001 From: Andrew Lee Rubinger Date: Mon, 29 Jul 2024 21:23:33 -0700 Subject: [PATCH] Issue #94: Promote the prototype pipeline to be the main CI --- .github/workflows/ci-issue-94.yml | 189 -------------------------- .github/workflows/ci.yml | 216 ++++++++++++++++++++---------- 2 files changed, 146 insertions(+), 259 deletions(-) delete mode 100644 .github/workflows/ci-issue-94.yml diff --git a/.github/workflows/ci-issue-94.yml b/.github/workflows/ci-issue-94.yml deleted file mode 100644 index 5fcbbaa8..00000000 --- a/.github/workflows/ci-issue-94.yml +++ /dev/null @@ -1,189 +0,0 @@ -name: CI Issue 94 - -on: - workflow_dispatch: - inputs: - version: - description: 'Version of Kotlin binary to publish to TBD Artifactory. For example "1.0.0-SNAPSHOT". If not supplied, will default to version specified in the POM. Must end in "-SNAPSHOT".' - required: false - default: "0.0.0-SNAPSHOT" - push: - branches: - - main - pull_request: - -env: - CARGO_TERM_COLOR: always - RUSTFLAGS: "-Dwarnings" - -jobs: - 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 - - name: Run Build Script - run: | - cd bindings/tbdex_uniffi/libtargets/aarch64_apple_darwin - ./build - - name: Upload .dylib - uses: actions/upload-artifact@v4.0.0 - with: - name: aarch64-apple-darwin-dylib - path: bound/kt/src/main/resources/libtbdex_uniffi_aarch64_apple_darwin.dylib - - build_x86_64_apple_darwin: - runs-on: macos-12 - name: Build x86_64-apple-darwin target - steps: - - uses: actions/checkout@v2 - - name: Install Rust - run: rustup toolchain install stable - - name: Run Build Script - run: | - cd bindings/tbdex_uniffi/libtargets/x86_64_apple_darwin - ./build - - name: Upload .dylib - uses: actions/upload-artifact@v4.0.0 - with: - name: x86_64-apple-darwin-dylib - path: bound/kt/src/main/resources/libtbdex_uniffi_x86_64_apple_darwin.dylib - - build_x86_64_unknown_linux_gnu: - runs-on: ubuntu-latest - name: Build x86_64-unknown-linux-gnu target - steps: - - uses: actions/checkout@v2 - - name: Run Build Script - run: | - cd bindings/tbdex_uniffi/libtargets/x86_64_unknown_linux_gnu - ./build - - name: Upload .so - uses: actions/upload-artifact@v4.0.0 - with: - name: x86_64-unknown-linux-gnu-so - path: bound/kt/src/main/resources/libtbdex_uniffi_x86_64_unknown_linux_gnu.so - - build_x86_64_unknown_linux_musl: - runs-on: ubuntu-latest - name: Build x86_64-unknown-linux-musl target - steps: - - uses: actions/checkout@v2 - - name: Run Build Script - run: | - cd bindings/tbdex_uniffi/libtargets/x86_64_unknown_linux_musl - ./build - - name: Upload .so - uses: actions/upload-artifact@v4.0.0 - with: - name: x86_64-unknown-linux-musl-so - path: bound/kt/src/main/resources/libtbdex_uniffi_x86_64_unknown_linux_musl.so - - 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 - - kotlin-build-test-deploy-snapshot: - needs: - - build_aarch64_apple_darwin - - build_x86_64_apple_darwin - - build_x86_64_unknown_linux_gnu - - build_x86_64_unknown_linux_musl - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: "adopt" - java-version: "11" - - - name: Resolve Snapshot Version - id: resolve_version - run: | - # Version resolution: use provided - if [ -n "${{ github.event.inputs.version }}" ]; then - resolvedVersion=${{ github.event.inputs.version }} - # Otherwise, construct a version for deployment in form X.Y.Z-commit-$shortSHA-SNAPSHOT - else - longSHA=$(git rev-parse --verify HEAD) - shortSHA=$(echo "${longSHA:0:7}") - resolvedVersion="commit-$shortSHA-SNAPSHOT" - echo "Requesting deployment as version: $resolvedVersion" - fi - - # Postcondition check; only allow this to proceed if we have a version ending in "-SNAPSHOT" - if [[ ! "$resolvedVersion" =~ -SNAPSHOT$ ]]; then - echo "Error: The version does not end with \"-SNAPSHOT\": $resolvedVersion" - exit 1 - fi - - echo "Resolved SNAPSHOT Version: $resolvedVersion" - echo "resolved_version=$resolvedVersion" >> $GITHUB_OUTPUT - - - name: Download MacOS aarch64 Native Library - uses: actions/download-artifact@v4.0.0 - with: - name: aarch64-apple-darwin-dylib - path: bound/kt/src/main/resources/ - - name: Download MacOS x86_64 Native Library - uses: actions/download-artifact@v4.0.0 - with: - name: x86_64-apple-darwin-dylib - path: bound/kt/src/main/resources/ - - name: Download Linux x86_64 GNU Native Library - uses: actions/download-artifact@v4.0.0 - with: - name: x86_64-unknown-linux-gnu-so - path: bound/kt/src/main/resources/ - - name: Download Linux x86_64 MUSL Native Library - uses: actions/download-artifact@v4.0.0 - with: - name: x86_64-unknown-linux-musl-so - path: bound/kt/src/main/resources/ - - - name: Build and Test Kotlin Project - run: | - - # cd into the Kotlin project - cd bound/kt/ - - # Set newly resolved version in POM config - mvn \ - versions:set \ - --batch-mode \ - -DnewVersion=${{ steps.resolve_version.outputs.resolved_version }} - - # Only attempt to publish artifact if we have credentials - if [ -n "${{ secrets.ARTIFACTORY_PASSWORD }}" ]; then - # Maven deploy lifecycle will build, run tests, verify, sign, and deploy - mvn deploy --batch-mode --settings .maven_settings.xml -P sign-artifacts - else - # Otherwise, Maven verify lifecycle will build, run tests, and verify - mvn verify --batch-mode - fi - - env: - ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }} - SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} - - - name: Upload Kotlin Test Results - uses: actions/upload-artifact@v3 - with: - name: kotlin-test-results - path: bound/kt/target/surefire-reports/*.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70275a5c..a7ef0c52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,14 @@ name: CI on: workflow_dispatch: + inputs: + version: + description: 'Version of Kotlin binary to publish to TBD Artifactory. For example "1.0.0-SNAPSHOT". If not supplied, will default to version specified in the POM. Must end in "-SNAPSHOT".' + required: false + default: "0.0.0-SNAPSHOT" + push: + branches: + - main pull_request: env: @@ -9,37 +17,69 @@ env: RUSTFLAGS: "-Dwarnings" jobs: - build: - runs-on: ubuntu-latest + build_aarch64_apple_darwin: + runs-on: macos-latest + name: Build aarch64-apple-darwin target steps: - - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1 + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup toolchain install stable + - name: Run Build Script + run: | + cd bindings/tbdex_uniffi/libtargets/aarch64_apple_darwin + ./build + - name: Upload .dylib + uses: actions/upload-artifact@v4.0.0 with: - cache: true - - name: Setup - run: just setup - - name: Build - run: just build - - test: - strategy: - matrix: - os: [ ubuntu-latest, macos-latest ] # TODO add back windows-latest https://github.com/TBD54566975/tbdex-rs/issues/44 - rust: [ stable, nightly ] - runs-on: ${{ matrix.os }} + name: aarch64-apple-darwin-dylib + path: bound/kt/src/main/resources/libtbdex_uniffi_aarch64_apple_darwin.dylib + + build_x86_64_apple_darwin: + runs-on: macos-12 + name: Build x86_64-apple-darwin target steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup toolchain install stable + - name: Run Build Script + run: | + cd bindings/tbdex_uniffi/libtargets/x86_64_apple_darwin + ./build + - name: Upload .dylib + uses: actions/upload-artifact@v4.0.0 with: - submodules: true - - name: Init Hermit - uses: cashapp/activate-hermit@v1 + name: x86_64-apple-darwin-dylib + path: bound/kt/src/main/resources/libtbdex_uniffi_x86_64_apple_darwin.dylib + + build_x86_64_unknown_linux_gnu: + runs-on: ubuntu-latest + name: Build x86_64-unknown-linux-gnu target + steps: + - uses: actions/checkout@v2 + - name: Run Build Script + run: | + cd bindings/tbdex_uniffi/libtargets/x86_64_unknown_linux_gnu + ./build + - name: Upload .so + uses: actions/upload-artifact@v4.0.0 with: - cache: true - - name: Setup - run: just setup - - name: Test - run: just test + name: x86_64-unknown-linux-gnu-so + path: bound/kt/src/main/resources/libtbdex_uniffi_x86_64_unknown_linux_gnu.so + + build_x86_64_unknown_linux_musl: + runs-on: ubuntu-latest + name: Build x86_64-unknown-linux-musl target + steps: + - uses: actions/checkout@v2 + - name: Run Build Script + run: | + cd bindings/tbdex_uniffi/libtargets/x86_64_unknown_linux_musl + ./build + - name: Upload .so + uses: actions/upload-artifact@v4.0.0 + with: + name: x86_64-unknown-linux-musl-so + path: bound/kt/src/main/resources/libtbdex_uniffi_x86_64_unknown_linux_musl.so lint: runs-on: ubuntu-latest @@ -54,60 +94,96 @@ jobs: - name: Lint run: just lint - kt-test: + kotlin-build-test-deploy-snapshot: + needs: + - build_aarch64_apple_darwin + - build_x86_64_apple_darwin + - build_x86_64_unknown_linux_gnu + - build_x86_64_unknown_linux_musl runs-on: macos-latest steps: - uses: actions/checkout@v4 with: submodules: true - - name: Init Hermit - uses: cashapp/activate-hermit@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v3 with: - cache: true - - name: Setup - run: just setup - - name: Build and Test Kotlin Project - working-directory: bound/kt + distribution: "adopt" + java-version: "11" + + - name: Resolve Snapshot Version + id: resolve_version run: | - mkdir -p test-results - mvn test - - name: Upload Kotlin Test Results - uses: actions/upload-artifact@v3 - with: - name: kotlin-test-results - path: bound/kt/target/surefire-reports/*.xml + # Version resolution: use provided + if [ -n "${{ github.event.inputs.version }}" ]; then + resolvedVersion=${{ github.event.inputs.version }} + # Otherwise, construct a version for deployment in form X.Y.Z-commit-$shortSHA-SNAPSHOT + else + longSHA=$(git rev-parse --verify HEAD) + shortSHA=$(echo "${longSHA:0:7}") + resolvedVersion="commit-$shortSHA-SNAPSHOT" + echo "Requesting deployment as version: $resolvedVersion" + fi - rust-test: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 + # Postcondition check; only allow this to proceed if we have a version ending in "-SNAPSHOT" + if [[ ! "$resolvedVersion" =~ -SNAPSHOT$ ]]; then + echo "Error: The version does not end with \"-SNAPSHOT\": $resolvedVersion" + exit 1 + fi + + echo "Resolved SNAPSHOT Version: $resolvedVersion" + echo "resolved_version=$resolvedVersion" >> $GITHUB_OUTPUT + + - name: Download MacOS aarch64 Native Library + uses: actions/download-artifact@v4.0.0 with: - submodules: true - - name: Init Hermit - uses: cashapp/activate-hermit@v1 + name: aarch64-apple-darwin-dylib + path: bound/kt/src/main/resources/ + - name: Download MacOS x86_64 Native Library + uses: actions/download-artifact@v4.0.0 with: - cache: true - - name: Setup - run: just setup - - name: Install Nextest - run: cargo install cargo-nextest - - name: Create nextest.toml - run: | - echo '[profile.ci.junit]' > nextest.toml - echo 'path = "junit.xml"' >> nextest.toml - echo 'store-success-output = true' >> nextest.toml - echo 'store-failure-output = true' >> nextest.toml - - name: Run Rust Tests - run: | - mkdir -p test-results - cargo nextest run --profile ci --config-file ./nextest.toml - - name: Modify testsuite name in XML for test runner consumption + name: x86_64-apple-darwin-dylib + path: bound/kt/src/main/resources/ + - name: Download Linux x86_64 GNU Native Library + uses: actions/download-artifact@v4.0.0 + with: + name: x86_64-unknown-linux-gnu-so + path: bound/kt/src/main/resources/ + - name: Download Linux x86_64 MUSL Native Library + uses: actions/download-artifact@v4.0.0 + with: + name: x86_64-unknown-linux-musl-so + path: bound/kt/src/main/resources/ + + - name: Build and Test Kotlin Project run: | - sed -i '' 's/