Skip to content

feat: basic gas abstraction test case #678

feat: basic gas abstraction test case

feat: basic gas abstraction test case #678

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
permissions:
contents: write # Needed for Flutter CI which auto-updates bindings
env:
CARGO_TERM_COLOR: always
jobs:
build_rust_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- run: rustup toolchain install nightly -c rustfmt
- run: docker compose up -d
working-directory: test/scripts/forked_state
- run: while ! curl localhost:8545/health; do sleep 1; done
- run: while ! curl localhost:4337/health; do sleep 1; done
- run: while ! curl localhost:3000/ping; do sleep 1; done
- run: cargo build --workspace --features=full --all-targets
- run: cargo test --features=full --lib --bins
- run: cargo clippy --workspace --features=full --all-targets -- -D warnings
- run: cargo clippy -p yttrium --all-targets -- -D warnings # `-p yttrium` to avoid feature unification; kotlin-ffi enables uniffi feature and we want to test without that
- run: cargo +nightly fmt --all -- --check
udeps:
name: Unused dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- run: rustup toolchain install nightly -c rustfmt
- run: git submodule update --init --recursive
- run: cargo install cargo-udeps
- run: cargo +nightly udeps --workspace
# build_wasm:
# name: Build on WASM
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# - name: Run sccache-cache
# uses: mozilla-actions/[email protected]
# - run: rustup update stable && rustup default stable
# - run: rustup target add wasm32-unknown-unknown
# - run: cargo build --workspace --features=full --lib --bins --target wasm32-unknown-unknown --exclude=ffi
build_swift_and_test:
name: Swift Package - latest
runs-on: macos-14
strategy:
matrix:
config:
- debug
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- name: Select Xcode 15.4
run: sudo xcode-select -s /Applications/Xcode_15.4.app
# Build bindings
- run: make build-xcframework
# Don't think we actually need this check, since bindings will be updated during release
# - run: git diff crates/ffi
# - run: if [ -n "$(git diff crates/ffi)" ]; then exit 1; fi
# Test that it compiles
- name: Build ${{ matrix.config }}
run: make CONFIG=${{ matrix.config }} build-swift-apple-platforms
build-kotlin:
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64-linux-android, armv7-linux-androideabi]
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
components: rust-src
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Set up Android SDK
uses: android-actions/setup-android@v3
with:
api-level: 35
build-tools: 35.0.0
ndk-version: 27.2.12479018
- name: Build with Gradle
run: |
./gradlew clean assembleRelease -Pversion=${{ env.VERSION }}
- name: Install cargo-ndk
run: |
cargo install cargo-ndk
- name: Build Rust library
run: |
cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli
- name: Generate Kotlin bindings (once)
if: ${{ matrix.target == 'aarch64-linux-android' }}
run: |
cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir yttrium/kotlin-bindings
- name: Prepare artifacts
run: |
# Map Rust targets to Android ABI names
declare -A abi_map
abi_map[aarch64-linux-android]="arm64-v8a"
abi_map[armv7-linux-androideabi]="armeabi-v7a"
abi_name=${abi_map[${{ matrix.target }}]}
if [ -z "$abi_name" ]; then
echo "Unknown ABI for target ${{ matrix.target }}"
exit 1
fi
mkdir -p yttrium/libs/$abi_name
cp target/${{ matrix.target }}/release/libuniffi_yttrium.so yttrium/libs/$abi_name/
flutter:
runs-on: macos-latest-xlarge
if: github.event_name == 'pull_request'
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# Need to use a PAT, not GITHUB_TOKEN, or else CI won't run like normal
token: ${{ secrets.RELEASE_TOKEN_V3 }}
# Cache Flutter dependencies
- name: Cache Flutter dependencies
uses: actions/cache@v3
with:
path: ~/.pub-cache
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-flutter-
# Install Rust toolchain
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rust-src
# Cache Cargo dependencies
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# Install Java 17
- name: Install Java 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
architecture: x86_64
cache: 'gradle'
# Cache Gradle
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Install Flutter
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.5'
# Install flutter_rust_bridge_codegen
- name: Install flutter_rust_bridge_codegen
run: |
cargo install flutter_rust_bridge_codegen
# Get package dependencies
- name: Get package dependencies
shell: bash
working-directory: crates/yttrium_dart
run: |
flutter pub get
# Generate Dart Bindings
- name: Generate Dart Bindings
shell: bash
working-directory: crates/yttrium_dart
run: |
flutter_rust_bridge_codegen generate --config-file flutter_rust_bridge.yaml
- run: git diff crates/yttrium_dart
# - run: if [ -n "$(git diff crates/yttrium_dart)" ]; then exit 1; fi
- name: Commit and push updated Flutter bindings, if necessary
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add crates/yttrium_dart
if git diff --cached --quiet crates/yttrium_dart; then
echo "No changes to commit."
else
git commit -m "chore: update Flutter bindings"
git push origin HEAD:${{ github.head_ref }}
fi