From bf275541cbd1c5703e58ef537991db5fbebdf6f5 Mon Sep 17 00:00:00 2001 From: oskarth Date: Thu, 7 Dec 2023 18:22:07 +0800 Subject: [PATCH] ci: Improve CI performance --- .github/workflows/build-and-test.yml | 62 +++++++++++++++++++--------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 85903a5d..99ee0cb0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,41 +6,63 @@ env: CARGO_TERM_COLOR: always jobs: - build: + build-ios: runs-on: macos-latest - steps: - uses: actions/checkout@v3 + - name: Cache cargo registry + uses: actions/cache@v2 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + - name: Cache cargo index + uses: actions/cache@v2 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + - name: Cache cargo build output + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-build-output-${{ hashFiles('**/Cargo.lock') }} - name: Install circom run: | git clone https://github.com/iden3/circom.git cd circom cargo build --release cargo install --path circom - - name: Prepare CI - run: ./scripts/prepare_ci.sh - name: Build for iOS run: ./scripts/build_ios.sh x86_64 debug - - name: Build for android - run: ./scripts/build_android.sh arm64 debug - - name: Run core tests - run: cd mopro-core && cargo test -- --nocapture - - name: Run ffi tests - run: | - cd mopro-ffi/ - curl -L https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar -o target/jna-5.13.0.jar - CLASSPATH=target/jna-5.13.0.jar cargo test -- --nocapture - name: Run ios tests run: | cd mopro-ios/MoproKit/Example xcodebuild test -scheme MoproKit-Example -workspace MoproKit.xcworkspace -destination "platform=iOS Simulator,OS=16.2,name=iPhone 14 Pro" - lint: + + build-android: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Check mopro-core formatting - run: cd ark-zkey/ && cargo fmt --all -- --check - - name: Check mopro-core formatting - run: cd mopro-core/ && cargo fmt --all -- --check - - name: Check mopro-ffi formatting - run: cd mopro-ffi/ && cargo fmt --all -- --check + - name: Build for android + run: ./scripts/build_android.sh arm64 debug + + test-core-ffi: + runs-on: ubuntu-latest + strategy: + matrix: + crate: ['mopro-core', 'mopro-ffi'] + steps: + - uses: actions/checkout@v3 + - name: Run tests for ${{ matrix.crate }} + run: | + cd ${{ matrix.crate }} + cargo test -- --nocapture + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check formatting + run: | + cd ark-zkey/ && cargo fmt --all -- --check + cd ../mopro-core/ && cargo fmt --all -- --check + cd ../mopro-ffi/ && cargo fmt --all -- --check