diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 918af841b..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,221 +0,0 @@ -name: Build -on: - push: - branches: - - main -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - target: [ - # aarch64-unknown-linux-gnu, - # x86_64-linux-android, - i686-linux-android, - armv7-linux-androideabi, - aarch64-linux-android, - ] - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: "Cache" - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} - - # Install latest cross to mitigate unwind linking issue on android builds. - # See https://github.com/cross-rs/cross/issues/1222 - - name: Install rust cross - run: | - cargo install cross --git https://github.com/cross-rs/cross - - - name: Build target - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target - - - name: Upload binary - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }} - path: bindings_ffi/target/${{ matrix.target }}/release/libxmtpv3.so - retention-days: 1 - - build-macos: - runs-on: warp-macos-13-arm64-6x - strategy: - fail-fast: false - matrix: - target: [aarch64-apple-darwin, aarch64-apple-ios, aarch64-apple-ios-sim] - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: "Cache" - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} - - # Install latest cross to mitigate unwind linking issue on android builds. - # See https://github.com/cross-rs/cross/issues/1222 - - name: Install rust cross - run: | - cargo install cross --git https://github.com/cross-rs/cross - - - name: Build target - uses: actions-rs/cargo@v1 - env: - CROSS_NO_WARNINGS: "0" - with: - use-cross: true - command: build - args: --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target - - - name: Upload binary - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }} - path: bindings_ffi/target/${{ matrix.target }}/release/libxmtpv3.a - retention-days: 1 - - kotlin: - runs-on: warp-macos-13-arm64-6x - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/release - key: ${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: x86_64-apple-darwin - - name: Install kotlin - run: brew install ktlint - - name: Generate Bindings - working-directory: bindings_ffi - run: ./gen_kotlin.sh - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: kotlin - path: bindings_ffi/src/uniffi/xmtpv3/xmtpv3.kt - retention-days: 1 - - swift: - runs-on: warp-macos-13-arm64-6x - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/release - key: ${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: x86_64-apple-darwin - - name: Install swift - run: brew install swiftformat - - name: Generate bindings - working-directory: bindings_ffi - run: | - make swift - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: swift - path: bindings_ffi/build/swift/ - retention-days: 1 - - package-android: - needs: [build, kotlin] - runs-on: warp-ubuntu-latest-x64-4x - steps: - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: . - - name: Build archive - run: | - mkdir -p jniLibs/x86 - mv i686-linux-android/libxmtpv3.so jniLibs/x86/ - mkdir -p jniLibs/armeabi-v7a - mv armv7-linux-androideabi/libxmtpv3.so jniLibs/armeabi-v7a/ - mkdir -p jniLibs/arm64-v8a - mv aarch64-linux-android/libxmtpv3.so jniLibs/arm64-v8a/ - mkdir -p java - mv kotlin/xmtpv3.kt java/ - zip -r libxmtp-android.zip jniLibs java - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: libxmtp-android.zip - path: libxmtp-android.zip - - package-swift: - needs: [build-macos, swift] - runs-on: warp-macos-13-arm64-6x - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: bindings_ffi/build - - name: Build archive - working-directory: bindings_ffi - run: | - find . - mkdir -p Sources/LibXMTP - mv build/swift/xmtpv3.swift Sources/LibXMTP/ - make framework - zip -r libxmtp-swift.zip Sources LibXMTPSwiftFFI.xcframework - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: libxmtp-swift.zip - path: bindings_ffi/libxmtp-swift.zip diff --git a/.github/workflows/github-pages.yml b/.github/workflows/deploy-docs.yml similarity index 69% rename from .github/workflows/github-pages.yml rename to .github/workflows/deploy-docs.yml index 76aa4a24b..8ca11d2f6 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,8 +1,10 @@ -name: GitHub Pages +name: Deploy Docs to GitHub Pages on: push: - branches: ["main"] + branches: + - main + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -22,26 +24,28 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - name: Setup Pages uses: actions/configure-pages@v2 - - name: Install rust - uses: actions-rs/toolchain@v1 + - name: Update rust toolchains + run: rustup update + + - name: Cache + uses: Swatinem/rust-cache@v2 with: - toolchain: stable - profile: minimal - override: true + workspaces: | + . - name: Invoke cargo doc run: ./dev/docs id: docgen - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v3 # Deployment job deploy: @@ -53,4 +57,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v3 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/validation-server-publish.yml b/.github/workflows/deploy-validation-server.yml similarity index 83% rename from .github/workflows/validation-server-publish.yml rename to .github/workflows/deploy-validation-server.yml index fc2eb1075..6a23759ae 100644 --- a/.github/workflows/validation-server-publish.yml +++ b/.github/workflows/deploy-validation-server.yml @@ -1,23 +1,25 @@ -name: Publish Validation Service Image +name: Deploy Validation Service Image on: push: branches: - main + workflow_dispatch: + jobs: push_to_registry: - name: Push Docker image to GitHub Packages + name: Push Docker Image to GitHub Packages runs-on: warp-ubuntu-latest-x64-16x permissions: contents: read packages: write steps: - - name: Check out the repo - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v4 - - name: Log in to the Container registry - uses: docker/login-action@v1 + - name: Log in to the container registry + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -25,12 +27,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: ghcr.io/xmtp/mls-validation-service - name: Build and push Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 id: push with: context: . diff --git a/.github/workflows/lint-ffi-bindings.yaml b/.github/workflows/lint-ffi-bindings.yaml new file mode 100644 index 000000000..38865cdb4 --- /dev/null +++ b/.github/workflows/lint-ffi-bindings.yaml @@ -0,0 +1,36 @@ +name: Lint FFI Bindings + +on: + push: + branches: + - main + + pull_request: + paths: + - "bindings_ffi/**" + - ".github/workflows/lint-ffi-bindings.yaml" + - "rustfmt.toml" + +jobs: + lint: + name: Lint + runs-on: warp-ubuntu-latest-x64-16x + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update rust toolchains + run: rustup update + + - name: Cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + . + bindings_ffi + + - name: Run clippy and fail on warnings + run: cargo clippy --manifest-path bindings_ffi/Cargo.toml --all-features --all-targets --no-deps -- -Dwarnings + + - name: Run format check + run: cargo fmt --manifest-path bindings_ffi/Cargo.toml --check diff --git a/.github/workflows/lint-node-bindings.yaml b/.github/workflows/lint-node-bindings.yaml index 019153e8d..547152a01 100644 --- a/.github/workflows/lint-node-bindings.yaml +++ b/.github/workflows/lint-node-bindings.yaml @@ -5,14 +5,19 @@ on: paths: - "bindings_node/**" - ".github/workflows/lint-node-bindings.yaml" + - "rustfmt.toml" jobs: lint: - runs-on: warp-ubuntu-latest-x64-8x + name: Lint + runs-on: warp-ubuntu-latest-x64-16x steps: - name: Checkout uses: actions/checkout@v4 + - name: Update rust toolchains + run: rustup update + - name: Cache uses: Swatinem/rust-cache@v2 with: @@ -26,12 +31,6 @@ jobs: - name: Run format check run: cargo fmt --manifest-path bindings_node/Cargo.toml --check - prettier: - runs-on: warp-ubuntu-latest-x64-8x - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup node uses: actions/setup-node@v4 with: @@ -45,11 +44,11 @@ jobs: run: corepack enable - name: Install dependencies + working-directory: bindings_node run: | - cd bindings_node yarn - name: Format check + working-directory: bindings_node run: | - cd bindings_node yarn format:check diff --git a/.github/workflows/lint-workspace.yaml b/.github/workflows/lint-workspace.yaml new file mode 100644 index 000000000..a92a1079b --- /dev/null +++ b/.github/workflows/lint-workspace.yaml @@ -0,0 +1,44 @@ +name: Lint Workspace + +on: + push: + branches: + - main + + pull_request: + paths: + - ".github/workflows/lint.yaml" + - "mls_validation_service/**" + - "xmtp_api_grpc/**" + - "xmtp_cryptography/**" + - "xmtp_id/**" + - "xmtp_mls/**" + - "xmtp_proto/**" + - "xmtp_v2/**" + - "Cargo.toml" + - "Cargo.lock" + - "rust-toolchain" + - "rustfmt.toml" + +jobs: + lint: + name: Lint + runs-on: warp-ubuntu-latest-x64-16x + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update rust toolchains + run: rustup update + + - name: Cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + . + + - name: Run clippy and fail on warnings + run: cargo clippy --all-features --all-targets --no-deps -- -Dwarnings + + - name: Run format check + run: cargo fmt --check diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 76dad4031..000000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Lint -on: - push: - branches: - - main - pull_request: -jobs: - lint: - runs-on: warp-ubuntu-latest-x64-4x - steps: - - uses: actions/checkout@v1 - - run: rustup update - - uses: Swatinem/rust-cache@v2 - with: - workspaces: | - . - bindings_ffi - - uses: actions-rs/clippy-check@v1 - name: Lint main workspace - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: workspace - args: --all-features --all-targets --no-deps - - uses: actions-rs/clippy-check@v1 - name: Lint ffi - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: ffi - args: --all-features --all-targets --no-deps --manifest-path bindings_ffi/Cargo.toml - - name: Format - run: cargo fmt --check - - name: Lint and fail on warnings - run: cargo clippy --no-deps --all-targets --all-features -- -Dwarnings - - name: Lint and fail on warnings - run: cargo clippy --all-features --all-targets --no-deps --manifest-path bindings_ffi/Cargo.toml -- -Dwarnings diff --git a/.github/workflows/noop.yml b/.github/workflows/noop.yml new file mode 100644 index 000000000..5d2b96b3e --- /dev/null +++ b/.github/workflows/noop.yml @@ -0,0 +1,45 @@ +name: No Op + +on: + pull_request: + # ignore code and some workflow changes + paths: + - "**" + - "!.github/workflows/lint-ffi-bindings.yml" + - "!.github/workflows/lint-node-bindings.yml" + - "!.github/workflows/lint-workspace.yml" + - "!.github/workflows/test-ffi-bindings.yml" + - "!.github/workflows/test-node-bindings.yml" + - "!.github/workflows/test-workspace.yml" + - "!bindings_ffi/**" + - "!bindings_node/**" + - "!dev/**" + - "!mls_validation_service/**" + - "!xmtp_api_grpc/**" + - "!xmtp_cryptography/**" + - "!xmtp_id/**" + - "!xmtp_mls/**" + - "!xmtp_proto/**" + - "!xmtp_v2/**" + - "!.node-version" + - "!Cargo.toml" + - "!Cargo.lock" + - "!rust-toolchain" + - "!rustfmt.toml" + +# Test and Lint steps are required for pull requests, but some file changes +# don't require them to run. These jobs define the required steps for these +# cases, but don't actually do anything. + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - run: echo "Nothing to test" + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - run: echo "Nothing to lint" diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 52cea5899..d15be2764 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -1,8 +1,10 @@ name: Release CLI + on: push: branches: - main + jobs: build: strategy: @@ -15,37 +17,34 @@ jobs: - macos-aarch64 include: - build: linux-x86_64 - os: warp-ubuntu-latest-x64-16x + runner: warp-ubuntu-latest-x64-16x target: x86_64-unknown-linux-musl - build: macos-aarch64 - os: warp-macos-13-arm64-6x + runner: warp-macos-13-arm64-6x target: aarch64-apple-darwin # - build: windows-x86_64-gnu - # os: windows-latest + # runner: windows-latest # target: x86_64-pc-windows-gnu - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.runner }} steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 + + - name: Update rust toolchains + run: | + rustup update + rustup target add ${{ matrix.target }} - - name: "Cache" - uses: actions/cache@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./examples/cli/target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} + workspaces: | + . - - run: sudo apt install musl-tools + - name: Configure x86_64-unknown-linux-musl toolchain if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} + run: | + sudo apt-get install -y musl-tools - name: Install openssl windows if: ${{ matrix.build == 'windows-x86_64-gnu' }} @@ -54,29 +53,25 @@ jobs: args: install openssl - name: Build target - uses: actions-rs/cargo@v1 - if: - with: - use-cross: false - command: build - args: --release --target ${{ matrix.target }} --manifest-path examples/cli/Cargo.toml --target-dir examples/cli/target + run: | + cargo build --release --target ${{ matrix.target }} --manifest-path examples/cli/Cargo.toml --target-dir examples/cli/target - name: Upload binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.build }} path: examples/cli/target/${{ matrix.target }}/release/xmtp_cli* retention-days: 1 release: - needs: ["build"] + needs: build runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: ./artifacts diff --git a/.github/workflows/release-kotlin-bindings.yml b/.github/workflows/release-kotlin-bindings.yml index 7060065e2..99ea159d7 100644 --- a/.github/workflows/release-kotlin-bindings.yml +++ b/.github/workflows/release-kotlin-bindings.yml @@ -5,7 +5,7 @@ on: jobs: build-linux: - runs-on: warp-ubuntu-latest-x64-8x + runs-on: warp-ubuntu-latest-x64-16x strategy: fail-fast: false matrix: @@ -26,88 +26,81 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: "Cache" - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 + - name: Update rust toolchains, add target + run: | + rustup update + rustup target add ${{ matrix.target }} + + - name: Cache + uses: Swatinem/rust-cache@v2 with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} + workspaces: | + . + bindings_ffi # Install latest cross to mitigate unwind linking issue on android builds. # See https://github.com/cross-rs/cross/issues/1222 - - name: Install rust cross + - name: Install cross run: | cargo install cross --git https://github.com/cross-rs/cross - name: Build target - uses: actions-rs/cargo@v1 - env: + env: CROSS_NO_WARNINGS: "0" - with: - use-cross: true - command: build - args: --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target - + run: | + cross build --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target + - name: Prepare JNI libs run: | mkdir -p bindings_ffi/jniLibs/${{ matrix.output_target }}/ && \ cp bindings_ffi/target/${{ matrix.target }}/release/libxmtpv3.so bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so - + - name: Upload binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.output_target }} path: bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so retention-days: 1 package-kotlin: - needs: [build-linux] - runs-on: warp-ubuntu-latest-x64-8x - steps: - - name: Checkout - uses: actions/checkout@v4 + needs: [build-linux] + runs-on: warp-ubuntu-latest-x64-16x + steps: + - name: Checkout + uses: actions/checkout@v4 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: bindings_ffi/jniLibs + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: bindings_ffi/jniLibs - - name: Build archive - working-directory: bindings_ffi - run: | - zip -r LibXMTPKotlinFFI.zip jniLibs + - name: Build archive + working-directory: bindings_ffi + run: | + zip -r LibXMTPKotlinFFI.zip jniLibs - - name: Get short SHA - id: slug - run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" + - name: Get short SHA + id: slug + run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: kotlin-bindings-${{ steps.slug.outputs.sha7 }} - release_name: Kotlin-Bindings-${{ steps.slug.outputs.sha7 }} - draft: false - prerelease: true + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: kotlin-bindings-${{ steps.slug.outputs.sha7 }} + release_name: Kotlin-Bindings-${{ steps.slug.outputs.sha7 }} + draft: false + prerelease: true - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./bindings_ffi/LibXMTPKotlinFFI.zip - asset_name: LibXMTPKotlinFFI.zip - asset_content_type: application/zip + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./bindings_ffi/LibXMTPKotlinFFI.zip + asset_name: LibXMTPKotlinFFI.zip + asset_content_type: application/zip diff --git a/.github/workflows/release-node-bindings.yml b/.github/workflows/release-node-bindings.yml index 3f66ef6fe..166682c8d 100644 --- a/.github/workflows/release-node-bindings.yml +++ b/.github/workflows/release-node-bindings.yml @@ -5,7 +5,7 @@ on: jobs: build-linux: - runs-on: warp-ubuntu-latest-x64-8x + runs-on: warp-ubuntu-latest-x64-16x strategy: fail-fast: false matrix: @@ -26,14 +26,19 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: "Cache" - uses: actions/cache@v3 + + - name: Update rust toolchains, add target + run: | + rustup update + rustup target add ${{ matrix.target }} + + - name: Cache + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} + workspaces: | + . + bindings_node + - name: Configure aarch64 toolchain if: startsWith(matrix.target, 'aarch64') run: | @@ -44,17 +49,12 @@ jobs: [target.aarch64-unknown-linux-musl] linker = "aarch64-linux-gnu-gcc" EOF + - name: Configure x86_64-unknown-linux-musl toolchain if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} run: | - sudo apt-get install -qq musl-tools - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} + sudo apt-get install -y musl-tools + - name: Setup node uses: actions/setup-node@v4 with: @@ -63,25 +63,30 @@ jobs: cache: "yarn" env: SKIP_YARN_COREPACK_CHECK: "1" + - name: Enable corepack run: corepack enable + - name: Install dependencies + working-directory: bindings_node run: | - cd bindings_node yarn + - name: Build target if: ${{ ! startsWith(matrix.target, 'aarch64') }} + working-directory: bindings_node run: | - cd bindings_node yarn build --target ${{ matrix.target }} + - name: Build target (aaarch64) if: startsWith(matrix.target, 'aarch64') env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc CC: aarch64-linux-gnu-gcc + working-directory: bindings_node run: | - cd bindings_node yarn build --target ${{ matrix.target }} + - name: Upload JS # only upload the JS files once, target doesn't matter if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} @@ -92,6 +97,7 @@ jobs: bindings_node/index.js bindings_node/index.d.ts retention-days: 1 + - name: Upload binding uses: actions/upload-artifact@v4 with: @@ -115,21 +121,19 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + + - name: Update rust toolchains, add target + run: | + rustup update + rustup target add ${{ matrix.target }} + - name: Cache - uses: actions/cache@v3 + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} + workspaces: | + . + bindings_node + - name: Setup node uses: actions/setup-node@v4 with: @@ -138,16 +142,20 @@ jobs: cache: "yarn" env: SKIP_YARN_COREPACK_CHECK: "1" + - name: Enable corepack run: corepack enable + - name: Install dependencies + working-directory: bindings_node run: | - cd bindings_node yarn + - name: Build target + working-directory: bindings_node run: | - cd bindings_node yarn build --target ${{ matrix.target }} + - name: Upload binding uses: actions/upload-artifact@v4 with: @@ -173,30 +181,30 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + + - name: Update rust toolchains + run: | + rustup update + rustup target add ${{ matrix.target }} + - name: Cache - uses: actions/cache@v3 + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} + workspaces: | + . + bindings_node + - name: Install Visual Studio 2022 build tools uses: crazy-max/ghaction-chocolatey@v3 with: args: install visualstudio2022buildtools + - name: Setup aarch64 toolchain if: ${{ matrix.target == 'aarch64-pc-windows-msvc' }} run: | echo "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin" >> $GITHUB_PATH shell: bash - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} + - name: Setup node uses: actions/setup-node@v4 with: @@ -205,16 +213,20 @@ jobs: cache: "yarn" env: SKIP_YARN_COREPACK_CHECK: "1" + - name: Enable corepack run: corepack enable + - name: Install dependencies + working-directory: bindings_node run: | - cd bindings_node yarn + - name: Build target + working-directory: bindings_node run: | - cd bindings_node yarn build --target ${{ matrix.target }} + - name: Upload binding uses: actions/upload-artifact@v4 with: @@ -230,12 +242,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Download build artifacts uses: actions/download-artifact@v4 with: pattern: bindings_node_* merge-multiple: true path: bindings_node/dist + - name: Setup node uses: actions/setup-node@v4 with: @@ -244,8 +258,10 @@ jobs: cache: "yarn" env: SKIP_YARN_COREPACK_CHECK: "1" + - name: Enable corepack run: corepack enable + - name: Publish to NPM uses: JS-DevTools/npm-publish@v3 with: diff --git a/.github/workflows/release_swift_bindings.yml b/.github/workflows/release-swift-bindings.yml similarity index 64% rename from .github/workflows/release_swift_bindings.yml rename to .github/workflows/release-swift-bindings.yml index 4cd55d2af..4756b81d9 100644 --- a/.github/workflows/release_swift_bindings.yml +++ b/.github/workflows/release-swift-bindings.yml @@ -9,45 +9,42 @@ jobs: strategy: fail-fast: false matrix: - target: [aarch64-apple-ios, x86_64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-darwin, aarch64-apple-darwin] + target: + - aarch64-apple-ios + - x86_64-apple-ios + - aarch64-apple-ios-sim + - x86_64-apple-darwin + - aarch64-apple-darwin steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - - name: "Cache" - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/${{ matrix.target }} - key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - - name: Install rust - uses: actions-rs/toolchain@v1 + - name: Update rust toolchains, add target + run: | + rustup update + rustup target add ${{ matrix.target }} + + - name: Cache + uses: Swatinem/rust-cache@v2 with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} + workspaces: | + . + bindings_ffi # Install latest cross to mitigate unwind linking issue on android builds. # See https://github.com/cross-rs/cross/issues/1222 - - name: Install rust cross + - name: Install cross run: | cargo install cross --git https://github.com/cross-rs/cross - name: Build target - uses: actions-rs/cargo@v1 - env: + env: CROSS_NO_WARNINGS: "0" - with: - use-cross: true - command: build - args: --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target + run: | + cross build --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target - name: Upload binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.target }} path: bindings_ffi/target/${{ matrix.target }}/release/libxmtpv3.a @@ -57,30 +54,30 @@ jobs: runs-on: warp-macos-13-arm64-6x steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 + + - name: Update rust toolchains, add target + run: | + rustup update + rustup target add x86_64-apple-darwin + - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ./target/release - key: ${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 + uses: Swatinem/rust-cache@v2 with: - toolchain: stable - profile: minimal - override: true - target: x86_64-apple-darwin + workspaces: | + . + bindings_ffi + - name: Install swift run: brew install swiftformat + - name: Generate bindings working-directory: bindings_ffi run: | make swift + - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: swift path: bindings_ffi/build/swift/ @@ -91,10 +88,10 @@ jobs: runs-on: warp-macos-13-arm64-6x steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: bindings_ffi/build @@ -117,7 +114,7 @@ jobs: id: slug run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - name: Create Release + - name: Create release id: create_release uses: actions/create-release@v1 env: @@ -129,7 +126,7 @@ jobs: draft: false prerelease: true - - name: Upload Release Asset + - name: Upload release asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index d23d0c802..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Release - -on: - push: - tags: - - "*" - -jobs: - android: - runs-on: warp-ubuntu-latest-x64-4x - permissions: - contents: write # for the release action - steps: - - uses: actions/checkout@v3 - - name: download package - env: - HEAD_SHA: ${{ github.sha }} - GITHUB_REPO: ${{ github.repository }} - GH_TOKEN: ${{ github.token }} - working-directory: bindings_ffi - run: ./get_android_artifact.sh - - name: create release - uses: ncipollo/release-action@v1 - with: - artifacts: "bindings_ffi/libxmtp-android.zip" - allowUpdates: "true" - - swift: - runs-on: warp-ubuntu-latest-x64-4x - permissions: - contents: write - env: - RELEASE_BRANCH: main - steps: - - uses: actions/checkout@v3 - - name: download artifacts - env: - HEAD_SHA: ${{ github.sha }} - GITHUB_REPO: ${{ github.repository }} - GH_TOKEN: ${{ github.token }} - working-directory: bindings_ffi - run: ./get_swift_artifact.sh - - name: generate access token - id: generate_token - uses: tibdex/github-app-token@v1.8.0 - with: - app_id: ${{ secrets.GH_APP_ID }} - private_key: ${{ secrets.GH_APP_PK }} - installation_id: ${{ secrets.GH_INSTALLATION_ID }} - - name: check out libxmtp-swift - uses: actions/checkout@v3 - with: - repository: xmtp/libxmtp-swift - path: libxmtp-swift - ref: ${{ env.RELEASE_BRANCH }} - token: ${{ steps.generate_token.outputs.token }} - - name: update libxmtp-swift - working-directory: libxmtp-swift - run: | - # set -x - # extract the tag fro GITHUB_REF which has the form refs/tags/... - RELEASE=$(basename $GITHUB_REF) - # Update the version field in the podspec. - # This could be single inlined sed expression in theory, - # but the quoting issues were a pain to debug, - # so instead the sed rule is in a file - # and we need to inject the RELEASE tag into it. - sed -i '' -e "s/VERSION/$RELEASE/" ../bindings_ffi/update_spec_version.sed - sed -i '' -f ../bindings_ffi/update_spec_version.sed LibXMTP.podspec - # unzip the new framework version over the repo - unzip -o ../bindings_ffi/libxmtp-swift.zip - # commit, tag and push - git config user.name libxmtp - git config user.email libxmtp@xmtp.com - git add . - git commit -m "libxmtp release $RELEASE" - git tag $RELEASE - git push --tags origin $RELEASE_BRANCH diff --git a/.github/workflows/test.yml b/.github/workflows/test-ffi-bindings.yml similarity index 61% rename from .github/workflows/test.yml rename to .github/workflows/test-ffi-bindings.yml index 96c3de23d..e6ebac803 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-ffi-bindings.yml @@ -1,40 +1,47 @@ -name: Test +name: Test FFI Bindings + on: push: branches: - main + pull_request: + # only run tests when related changes are made + paths: + - ".github/workflows/test-ffi-bindings.yml" + - "bindings_ffi/**" + - "dev/**" + - "mls_validation_service/**" + - "xmtp_api_grpc/**" + - "xmtp_cryptography/**" + - "xmtp_id/**" + - "xmtp_mls/**" + - "xmtp_proto/**" + - "xmtp_v2/**" + - "Cargo.toml" + - "Cargo.lock" + - "rust-toolchain" + jobs: test: name: Test runs-on: warp-ubuntu-latest-x64-16x steps: - - name: Checkout sources - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v4 - - name: Update rust toolchain from rust-toolchain file + - name: Update rust toolchains run: rustup update - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - - uses: Swatinem/rust-cache@v2 with: workspaces: | . bindings_ffi - bindings_flutter - name: Start Docker containers run: dev/up - - name: Run cargo test on main workspace - uses: actions-rs/cargo@v1 - timeout-minutes: 20 - with: - command: test - args: -- --test-threads=2 - - name: Setup Kotlin run: | sudo apt update -q diff --git a/.github/workflows/test-node-bindings.yml b/.github/workflows/test-node-bindings.yml index 79a013ecb..35e759176 100644 --- a/.github/workflows/test-node-bindings.yml +++ b/.github/workflows/test-node-bindings.yml @@ -25,11 +25,15 @@ on: jobs: test: + name: Test runs-on: warp-ubuntu-latest-x64-16x steps: - name: Checkout uses: actions/checkout@v4 + - name: Update rust toolchains + run: rustup update + - name: Cache uses: Swatinem/rust-cache@v2 with: @@ -37,9 +41,6 @@ jobs: . bindings_node - - name: Update rust toolchain from rust-toolchain file - run: rustup update - - name: Start Docker containers run: dev/up @@ -56,16 +57,16 @@ jobs: run: corepack enable - name: Install dependencies + working-directory: bindings_node run: | - cd bindings_node yarn - name: Build release + working-directory: bindings_node run: | - cd bindings_node yarn build:release - name: Run tests + working-directory: bindings_node run: | - cd bindings_node yarn test diff --git a/.github/workflows/test-workspace.yml b/.github/workflows/test-workspace.yml new file mode 100644 index 000000000..df73a80b4 --- /dev/null +++ b/.github/workflows/test-workspace.yml @@ -0,0 +1,48 @@ +name: Test Workspace + +on: + push: + branches: + - main + + pull_request: + # only run tests when related changes are made + paths: + - ".github/workflows/test-workspace.yml" + - "dev/**" + - "mls_validation_service/**" + - "xmtp_api_grpc/**" + - "xmtp_cryptography/**" + - "xmtp_id/**" + - "xmtp_mls/**" + - "xmtp_proto/**" + - "xmtp_v2/**" + - "Cargo.toml" + - "Cargo.lock" + - "rust-toolchain" + +jobs: + test: + name: Test + runs-on: warp-ubuntu-latest-x64-16x + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update rust toolchains + run: rustup update + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - name: Cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + . + + - name: Start Docker containers + run: dev/up + + - name: Run cargo test on main workspace + run: cargo test -- --test-threads=2 diff --git a/bindings_ffi/src/v2.rs b/bindings_ffi/src/v2.rs index c40bf23cc..932650f55 100644 --- a/bindings_ffi/src/v2.rs +++ b/bindings_ffi/src/v2.rs @@ -293,7 +293,7 @@ pub trait FfiV2SubscriptionCallback: Send + Sync { pub struct FfiV2Subscription { tx: mpsc::Sender, abort: AbortHandle, - // we require Arc> here because uniffi doesn't like &mut self, or the owned version of self on exported methods + // we require Arc> here because uniffi doesn't like &mut self, or the owned version of self on exported methods #[allow(clippy::type_complexity)] handle: Arc>>>, }