From 0096fcecadacc49c3ef5cf21ba2f39433bbc04b3 Mon Sep 17 00:00:00 2001 From: Lars Lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:35:13 +0200 Subject: [PATCH] [CI] Add reusable workflow for test-tube tests --- .github/workflows/build.yml | 84 ++----------------- .github/workflows/cl_vault.yml | 4 + .github/workflows/dex_router_osmosis.yml | 4 + .github/workflows/merkle_incentives.yml | 22 +++++ .github/workflows/rust_basic.yml | 4 +- .github/workflows/rust_test_tube.yml | 44 ++++++++++ .../dex-router-osmosis/.cargo/config.toml | 2 +- .../contracts/merkle-incentives/src/msg.rs | 1 + 8 files changed, 84 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/merkle_incentives.yml create mode 100644 .github/workflows/rust_test_tube.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 840476270..fbf6d1382 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,24 @@ -name: Build Quasar +name: Build Quasar (Go) on: pull_request: branches: - main - fix/* + paths-ignore: + - 'smart-contracts/**' push: branches: - main - fix/* + paths-ignore: + - 'smart-contracts/**' workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.head_ref }} cancel-in-progress: true -# This workflow makes x86_64 binaries for linux. -# TODO: add darwin later jobs: build-go: name: quasar-${{ matrix.targetos }}-${{ matrix.arch }} @@ -54,78 +56,4 @@ jobs: if: env.GIT_DIFF with: name: quasarnoded-${{ matrix.targetos }}-${{ matrix.arch }} - path: build/quasarnoded-${{ matrix.targetos }}-${{ matrix.arch }} - build-rust: - name: quasar-contracts-${{ matrix.targetos }}-${{ matrix.arch }} - runs-on: ubuntu-latest - strategy: - matrix: - arch: [ amd64 ] - targetos: [ linux ] - permissions: - contents: write - actions: write - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Get git diff - uses: technote-space/get-diff-action@v6.1.2 - with: - PATTERNS: | - **/**.rs - Makefile - .github/workflows/build.yml - - name: Install just via cargo - if: env.GIT_DIFF - run: cargo install just - - name: Build smart contracts - if: env.GIT_DIFF - run: | - cd smart-contracts - just workspace-optimize - - uses: actions/upload-artifact@v3 - if: env.GIT_DIFF - with: - name: smart-contracts - path: | - smart-contracts/artifacts/basic_vault.wasm - smart-contracts/artifacts/lp_strategy.wasm - smart-contracts/artifacts/cl_vault.wasm - smart-contracts/artifacts/merkle_incentives.wasm - smart-contracts/artifacts/dex_router_osmosis.wasm - smart-contracts/artifacts/lst_adapter_osmosis.wasm - test-test-tube: - runs-on: ubuntu-latest - needs: build-rust - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Get git diff - uses: technote-space/get-diff-action@v6.1.2 - with: - PATTERNS: | - **/**.rs - Makefile - .github/workflows/build.yml - - - name: Download contracts - if: env.GIT_DIFF - uses: actions/download-artifact@v3 - with: - name: - smart-contracts - - - name: Install Rust - if: env.GIT_DIFF - uses: dtolnay/rust-toolchain@stable - - - name: Move smart contracts - if: env.GIT_DIFF - run: | - find . -name "*.wasm" -exec bash -c 'file="{}"; contract_name=$(basename "$file" .wasm); dir_name=$(echo "$contract_name" | sed "s/_/-/g"); mkdir -p "smart-contracts/contracts/$dir_name/test-tube-build/wasm32-unknown-unknown/release"; mv "$file" "smart-contracts/contracts/$dir_name/test-tube-build/wasm32-unknown-unknown/release/$contract_name.wasm"' \; - - - name: Run test-tube tests - if: env.GIT_DIFF - run: cd smart-contracts && cargo test -- --include-ignored --test-threads=1 - env: - PROPTEST_CASES: 10 + path: build/quasarnoded-${{ matrix.targetos }}-${{ matrix.arch }} \ No newline at end of file diff --git a/.github/workflows/cl_vault.yml b/.github/workflows/cl_vault.yml index 39c0bd843..e281739f1 100644 --- a/.github/workflows/cl_vault.yml +++ b/.github/workflows/cl_vault.yml @@ -16,3 +16,7 @@ jobs: uses: ./.github/workflows/rust_basic.yml with: contract: 'cl-vault' + test-tube: + uses: ./.github/workflows/rust_test_tube.yml + with: + contract: 'cl-vault' diff --git a/.github/workflows/dex_router_osmosis.yml b/.github/workflows/dex_router_osmosis.yml index c8de62465..c8aff0d7e 100644 --- a/.github/workflows/dex_router_osmosis.yml +++ b/.github/workflows/dex_router_osmosis.yml @@ -16,3 +16,7 @@ jobs: uses: ./.github/workflows/rust_basic.yml with: contract: 'dex-router-osmosis' + test-tube: + uses: ./.github/workflows/rust_test_tube.yml + with: + contract: 'dex-router-osmosis' diff --git a/.github/workflows/merkle_incentives.yml b/.github/workflows/merkle_incentives.yml new file mode 100644 index 000000000..b4087363d --- /dev/null +++ b/.github/workflows/merkle_incentives.yml @@ -0,0 +1,22 @@ +name: Test merkle incentives + +on: + pull_request: + branches: + - main + paths: + - 'smart-contracts/contracts/merkle-incentives/**' + push: + branches: + - main + workflow_dispatch: + +jobs: + unit-test: + uses: ./.github/workflows/rust_basic.yml + with: + contract: 'merkle-incentives' + test-tube: + uses: ./.github/workflows/rust_test_tube.yml + with: + contract: 'merkle-incentives' diff --git a/.github/workflows/rust_basic.yml b/.github/workflows/rust_basic.yml index c0f89a0a7..68c2a2112 100644 --- a/.github/workflows/rust_basic.yml +++ b/.github/workflows/rust_basic.yml @@ -18,7 +18,7 @@ jobs: with: PATTERNS: | **/**.rs - **/Cargo.toml + **/Cargo.lock - name: Install Rust if: env.GIT_DIFF uses: dtolnay/rust-toolchain@stable @@ -30,7 +30,7 @@ jobs: ~/.cargo ~/go **/target - key: ${{ runner.os }}-cargo-$${{ hashFiles('smart-contracts/Cargo.toml') }} + key: ${{ runner.os }}-cargo-$${{ hashFiles('smart-contracts/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo - name: Rust lint if: env.GIT_DIFF diff --git a/.github/workflows/rust_test_tube.yml b/.github/workflows/rust_test_tube.yml new file mode 100644 index 000000000..eef3eabbc --- /dev/null +++ b/.github/workflows/rust_test_tube.yml @@ -0,0 +1,44 @@ +name: Test Tube + +on: + workflow_call: + inputs: + contract: + required: true + type: string + +jobs: + test-tube: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Get git diff + uses: technote-space/get-diff-action@v6.1.2 + with: + PATTERNS: | + **/**.rs + **/Cargo.lock + - name: Install Rust + if: env.GIT_DIFF + uses: dtolnay/rust-toolchain@stable + - name: Restore dependencies + if: env.GIT_DIFF + uses: actions/cache@v4 + with: + path: | + ~/.cargo + ~/go + **/target + key: ${{ runner.os }}-cargo-$${{ hashFiles('smart-contracts/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo + - name: Build test-tube tests + if: env.GIT_DIFF + run: cargo test-tube-build + working-directory: smart-contracts/contracts/${{ inputs.contract }} + - name: Run test-tube tests + if: env.GIT_DIFF + run: cargo test-tube + env: + PROPTEST_CASES: 10 + working-directory: smart-contracts/contracts/${{ inputs.contract }} diff --git a/smart-contracts/contracts/dex-router-osmosis/.cargo/config.toml b/smart-contracts/contracts/dex-router-osmosis/.cargo/config.toml index 2894d9006..f890b1c69 100644 --- a/smart-contracts/contracts/dex-router-osmosis/.cargo/config.toml +++ b/smart-contracts/contracts/dex-router-osmosis/.cargo/config.toml @@ -2,5 +2,5 @@ wasm = "build --release --target wasm32-unknown-unknown" unit-test = "test --lib" schema = "run --bin schema" -test-tube = "test --package dex-router-osmosis --lib -- --include-ignored test_tube:: --nocapture --test-threads=1" +test-tube = "test -- --include-ignored --test-threads=1" test-tube-build = "build --release --lib --target wasm32-unknown-unknown --target-dir ./test-tube-build" diff --git a/smart-contracts/contracts/merkle-incentives/src/msg.rs b/smart-contracts/contracts/merkle-incentives/src/msg.rs index 9a3fa1054..c3d4466dd 100644 --- a/smart-contracts/contracts/merkle-incentives/src/msg.rs +++ b/smart-contracts/contracts/merkle-incentives/src/msg.rs @@ -1,4 +1,5 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; +#[cfg(not(target_arch = "wasm32"))] use cosmwasm_std::Empty; use crate::{