Skip to content

Commit

Permalink
Prevents coupling UTF-16 text value encodings to WASM targets (autome…
Browse files Browse the repository at this point in the history
…rge#198)

* migrate from wasm32-wasi to wasm32-wasip1-threads
* wasm: introduce test cases to verify the integrity between platforms
* ci: running unit tests over wasm
* tests: making unit-tests compatible with wasm
* propagate cursor exceptions
* rust: define features for automerge wasi
* update cargo lock
* generate wasm library using wasm32-wasip1 and wasm32-wasip1-threads
* propagate automerge rust changes to uniffi
* ci: split dependencies from job of running tests
* running tests using wasm32-wasip1
* bump to automerge core 0.5.12
* forcing xcode 15.4
* ci: fix cache toolchain key check
  • Loading branch information
miguelangel-dev authored Oct 26, 2024
1 parent 4159e71 commit 6e729d2
Show file tree
Hide file tree
Showing 18 changed files with 2,014 additions and 1,539 deletions.
121 changes: 93 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,123 @@ on:
branches: [main]

jobs:
build-test:

automerge-dependencies:
runs-on: macos-14
env:
LOCAL_BUILD: true
DEVELOPER_DIR: /Applications/Xcode_15.4.app
concurrency:
group: automerge-dependencies-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache Automerge XCFramework and library
id: cache-automerge
uses: actions/cache@v4
with:
path: |
automergeFFI.xcframework
automergeFFI.xcframework.zip
libuniffi_automerge.a
libuniffi_automerge_threads.a
key: automerge-dependencies-{{ hashFiles(AutomergeUniffi/automerge.swift) }}-{{ hashFiles(rust/Cargo.lock) }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
toolchain: 1.81.0
default: true
- name: get xcode information
run: |
xcodebuild -version
swift --version
- name: build xcframework
- name: Select Xcode 15.4
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Build Automerge XCFramework and library
if: steps.cache-automerge.outputs.cache-hit != 'true'
run: ./scripts/build-xcframework.sh
- name: compress framework
- name: Compress Automerge XCFramework
if: steps.cache-automerge.outputs.cache-hit != 'true'
run: ./scripts/compress-framework.sh
- uses: actions/upload-artifact@v4
if: steps.cache-automerge.outputs.cache-hit != 'true'
with:
name: libuniffi_automerge
path: |
libuniffi_automerge.a
libuniffi_automerge_threads.a
mac:
runs-on: macos-14
needs: automerge-dependencies
steps:
- uses: actions/checkout@v4
- name: Select Xcode 15.4
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Restore Automerge XCFramework and library
uses: actions/cache/restore@v4
with:
path: |
automergeFFI.xcframework
automergeFFI.xcframework.zip
libuniffi_automerge.a
libuniffi_automerge_threads.a
key: automerge-dependencies-{{ hashFiles(AutomergeUniffi/automerge.swift) }}-{{ hashFiles(rust/Cargo.lock) }}
- name: Get swift version
run: swift --version
- name: Swift tests
run: swift test

build-wasm32-unknown-wasi:
wasm:
runs-on: ubuntu-latest
needs: automerge-dependencies
strategy:
matrix:
include:
- toolchain: swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a
swift-sdk: swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a
checksum: 229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
default: true
- run: rustup target add wasm32-wasi
- uses: swiftwasm/setup-swiftwasm@v1
- uses: bytecodealliance/actions/wasmtime/setup@v1
- name: Restore Automerge XCFramework and library
uses: actions/cache/restore@v4
with:
swift-version: "wasm-5.9.1-RELEASE"
#- run: cargo build --manifest-path rust/Cargo.toml --target wasm32-wasi --release
- run: scripts/ci/wasi-regen-swift.sh
- uses: actions/upload-artifact@v4
path: |
automergeFFI.xcframework
automergeFFI.xcframework.zip
libuniffi_automerge.a
libuniffi_automerge_threads.a
key: automerge-dependencies-{{ hashFiles(AutomergeUniffi/automerge.swift) }}-{{ hashFiles(rust/Cargo.lock) }}
- name: Cache Toolchain for WebAssembly
id: cache-wasm-toolchain
uses: actions/cache@v4
with:
name: libuniffi_automerge-wasm32-unknown-wasi.a
path: ./rust/target/wasm32-wasi/release/libuniffi_automerge.a
- run: swift build --triple wasm32-unknown-wasi
path: /tmp/swift-toolchain.tar.gz
key: wasm-toolchain-${{ matrix.checksum }}
- name: Download Toolchain for WebAssembly
if: steps.cache-wasm-toolchain.outputs.cache-hit != 'true'
run: |
SWIFT_TOOLCHAIN_TAG="${{ matrix.toolchain }}"
set -ex
curl -f -o /tmp/swift-toolchain.tar.gz "https://download.swift.org/development/ubuntu2204/$SWIFT_TOOLCHAIN_TAG/$SWIFT_TOOLCHAIN_TAG-ubuntu22.04.tar.gz"
- name: Install Swift and Swift SDK for WebAssembly
run: |
PREFIX=/opt/swift
SWIFT_SDK_TAG="${{ matrix.swift-sdk }}"
set -ex
sudo mkdir -p $PREFIX; sudo tar -xzf /tmp/swift-toolchain.tar.gz -C $PREFIX --strip-component 1
$PREFIX/usr/bin/swift sdk install "https://github.com/swiftwasm/swift/releases/download/$SWIFT_SDK_TAG/$SWIFT_SDK_TAG-wasm32-unknown-wasi.artifactbundle.zip" --checksum ${{ matrix.checksum }}
echo "$PREFIX/usr/bin" >> $GITHUB_PATH
- name: Build tests
run: swift build --swift-sdk wasm32-unknown-wasi --build-tests -Xlinker "`pwd`/libuniffi_automerge.a" -Xlinker -z -Xlinker stack-size=$((1024 * 1024))
- name: Run tests
run: wasmtime run --wasm max-wasm-stack=$((1024 * 1024)) --dir . .build/debug/AutomergePackageTests.wasm

rustfmt:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
toolchain: 1.81.0
default: true
components: rustfmt
- name: Clippy
Expand All @@ -66,11 +131,11 @@ jobs:
clippy:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
toolchain: 1.81.0
default: true
components: clippy
- name: Clippy
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.vscode
# generated WebAssembly library from build scripts
libuniffi_automerge.a
libuniffi_automerge_threads.a

# generated by the UniFFI build process and replicated into repos,
# but not stored directly, since they're generated
Expand Down
Loading

0 comments on commit 6e729d2

Please sign in to comment.