diff --git a/.github/workflows/all_checks_osmosis.yml b/.github/workflows/all_checks_osmosis.yml new file mode 100644 index 000000000..378082b54 --- /dev/null +++ b/.github/workflows/all_checks_osmosis.yml @@ -0,0 +1,85 @@ +name: Test Tube (osmosis) + +on: + workflow_call: + inputs: + proptest: + required: false + default: false + type: boolean + store_deps: + required: false + default: false + type: boolean + workflow_dispatch: + +env: + RUSTC_WRAPPER: cachepot + CARGO_TARGET_DIR: ~/target + +jobs: + test-tube: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Restore dependencies + id: restore-cache + uses: actions/cache/restore@v4 + with: + path: | + ~/.cache/cachepot + ~/.cargo + ~/go + ~/target + key: ${{ runner.os }}-cargo-osmosis-${{github.sha}} + restore-keys: ${{ runner.os }}-cargo-osmosis + - name: Update PATH and RUSTC_WRAPPER + run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Install cachepot + run: test -e $HOME/.cargo/bin/cachepot && echo "cachepot found -- skipping install" || cargo install --git https://github.com/paritytech/cachepot + env: + RUSTC_WRAPPER: "" + - name: Rust lint + run: cargo clippy --features test-tube --all-targets -- -D warnings + working-directory: smart-contracts/osmosis + - name: Unit tests + run: cargo unit-test + working-directory: smart-contracts/osmosis + - name: Build merkle-incentives + run: cargo test-tube-build + working-directory: smart-contracts/osmosis/contracts/merkle-incentives + - name: Test merkle-incentives + run: cargo test-tube + working-directory: smart-contracts/osmosis/contracts/merkle-incentives + - name: Build dex-router-osmosis + run: cargo test-tube-build + working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis + - name: Test dex-router-osmosis + run: cargo test-tube + working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis + - name: Build cl-vault + run: cargo test-tube-build + working-directory: smart-contracts/osmosis/contracts/cl-vault + - name: Test cl-vault + run: cargo test-tube + working-directory: smart-contracts/osmosis/contracts/cl-vault + - if: inputs.proptest + name: Run prop-test + run: cargo prop-test + env: + PROPTEST_CASES: 10 + working-directory: smart-contracts/osmosis/contracts/cl-vault + - name: Store dependencies + if: inputs.store_deps + uses: actions/cache/save@v4 + with: + path: | + ~/.cache/cachepot + ~/.cargo + ~/go + ~/target + key: ${{ runner.os }}-cargo-osmosis-${{github.sha}} + diff --git a/.github/workflows/cargo_build_cache.yml b/.github/workflows/cargo_build_cache.yml index 3076a3a62..1921ab46b 100644 --- a/.github/workflows/cargo_build_cache.yml +++ b/.github/workflows/cargo_build_cache.yml @@ -15,15 +15,29 @@ jobs: uses: actions/checkout@v3 - name: Install Rust uses: dtolnay/rust-toolchain@stable + - name: Restore dependencies + uses: actions/cache/restore@v4 + with: + path: | + ~/.cache/cachepot + ~/.cargo + ~/go + smart-contracts/${{ inputs.workspace }}/**/target + key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-${{github.sha}} + restore-keys: ${{ runner.os }}-cargo-${{ inputs.workspace }} + - name: Install cachepot + run: test -e $HOME/.cargo/bin/cachepot && echo "cachepot found -- skipping install" || cargo install --git https://github.com/paritytech/cachepot - name: Rust check - run: cargo check + run: cargo check --all-targets --features test-tube working-directory: smart-contracts/${{ inputs.workspace }} + env: + RUSTC_WRAPPER: cachepot - name: Store dependencies uses: actions/cache/save@v4 with: path: | + ~/.cache/cachepot ~/.cargo ~/go smart-contracts/${{ inputs.workspace }}/**/target - key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-$GITHUB_SHA - restore-keys: ${{ runner.os }}-cargo-${{ inputs.workspace }} + key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-${{github.sha}} diff --git a/.github/workflows/cargo_build_cache_osmosis.yml b/.github/workflows/cargo_build_cache_osmosis.yml deleted file mode 100644 index 90415d125..000000000 --- a/.github/workflows/cargo_build_cache_osmosis.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Store cargo build cache (osmosis) - -on: - push: - branches: - - main - paths: - - 'smart-contracts/osmosis/**.rs' - - 'smart-contracts/osmosis/**.toml' - workflow_dispatch: - -jobs: - osmosis-build-cache: - uses: ./.github/workflows/cargo_build_cache.yml - with: - workspace: osmosis diff --git a/.github/workflows/test_tube.yml b/.github/workflows/test_tube.yml new file mode 100644 index 000000000..2cb68d52c --- /dev/null +++ b/.github/workflows/test_tube.yml @@ -0,0 +1,28 @@ +name: Test Tube (osmosis) + +on: + pull_request: + branches: + - main + paths: + - 'smart-contracts/osmosis/**/Cargo.toml' + - 'smart-contracts/osmosis/**.rs' + - '.github/workflows/test_tube.yml' + - '.github/workflows/all_checks_osmosis.yml' + push: + branches: + - main + paths: + - 'smart-contracts/osmosis/**/Cargo.toml' + - 'smart-contracts/osmosis/**.rs' + - '.github/workflows/test_tube.yml' + - '.github/workflows/all_checks_osmosis.yml' + workflow_dispatch: + +jobs: + post-merge: + uses: ./.github/workflows/all_checks_osmosis.yml + if: github.event_name == 'push' + with: + proptest: true + store_deps: true diff --git a/.github/workflows/test_tube_osmosis.yml b/.github/workflows/test_tube_osmosis.yml deleted file mode 100644 index 97099e264..000000000 --- a/.github/workflows/test_tube_osmosis.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Test Tube (osmosis) - -on: - pull_request: - branches: - - main - paths: - - 'smart-contracts/osmosis/contracts/dex-router-osmosis/Cargo.toml' - - 'smart-contracts/osmosis/contracts/dex-router-osmosis/**.rs' - - 'smart-contracts/osmosis/contracts/cl-vault/Cargo.toml' - - 'smart-contracts/osmosis/contracts/cl-vault/**.rs' - - 'smart-contracts/osmosis/contracts/merkle-incentives/Cargo.toml' - - 'smart-contracts/osmosis/contracts/merkle-incentives/**.rs' - - '.github/workflows/dex_router_osmosis.yml' - - '.github/workflows/cl_vault_osmosis.yml' - - '.github/workflows/merkle_incentives_osmosis.yml' - - '.github/workflows/test_tube_osmosis.yml' - push: - branches: - - main - paths: - - 'smart-contracts/osmosis/contracts/dex-router-osmosis/Cargo.toml' - - 'smart-contracts/osmosis/contracts/dex-router-osmosis/**.rs' - - 'smart-contracts/osmosis/contracts/cl-vault/Cargo.toml' - - 'smart-contracts/osmosis/contracts/cl-vault/**.rs' - - 'smart-contracts/osmosis/contracts/merkle-incentives/Cargo.toml' - - 'smart-contracts/osmosis/contracts/merkle-incentives/**.rs' - - '.github/workflows/dex_router_osmosis.yml' - - '.github/workflows/cl_vault_osmosis.yml' - - '.github/workflows/merkle_incentives_osmosis.yml' - - '.github/workflows/test_tube_osmosis.yml' - workflow_dispatch: - -jobs: - test-tube: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - name: Restore dependencies - uses: actions/cache/restore@v4 - with: - path: | - ~/.cargo - ~/go - smart-contracts/osmosis/**/target - key: ${{ runner.os }}-cargo-osmosis-$GITHUB_SHA - restore-keys: ${{ runner.os }}-cargo-osmosis - - name: Rust lint - run: cargo clippy --features test-tube --all-targets -- -D warnings - working-directory: smart-contracts/osmosis - - name: Build merkle-incentives - run: cargo test-tube-build - working-directory: smart-contracts/osmosis/contracts/merkle-incentives - - name: Test merkle-incentives - run: cargo test-tube - working-directory: smart-contracts/osmosis/contracts/merkle-incentives - - name: Build dex-router-osmosis - run: cargo test-tube-build - working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis - - name: Test dex-router-osmosis - run: cargo test-tube - working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis - - name: Build cl-vault - run: cargo test-tube-build - working-directory: smart-contracts/osmosis/contracts/cl-vault - - name: Test cl-vault - run: cargo test-tube - working-directory: smart-contracts/osmosis/contracts/cl-vault - - name: Run prop-test - if: github.ref == 'refs/heads/main' - run: cargo prop-test - env: - PROPTEST_CASES: 10 - working-directory: smart-contracts/osmosis/contracts/cl-vault -