Skip to content

Commit

Permalink
[CI] Add reusable workflow for test-tube tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lubkoll committed Jul 18, 2024
1 parent aade672 commit e95dc2b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 77 deletions.
76 changes: 1 addition & 75 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,78 +54,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/[email protected]
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/[email protected]
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 }}
4 changes: 4 additions & 0 deletions .github/workflows/dex_router_osmosis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 2 additions & 2 deletions .github/workflows/rust_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
PATTERNS: |
**/**.rs
**/Cargo.toml
**/Cargo.lock
- name: Install Rust
if: env.GIT_DIFF
uses: dtolnay/rust-toolchain@stable
Expand All @@ -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
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/rust_test_tube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test Tube

on:
workflow_call:
inputs:
contract:
required: true
type: string

jobs:
checks:
permissions:
contents: write
actions: write
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get git diff
uses: technote-space/[email protected]
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 smart contracts
if: env.GIT_DIFF
run: just workspace-optimize
working_directory: smart-contracts
- 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: cargo test-tube
env:
PROPTEST_CASES: 10
working-directory: smart-contracts/contracts/${{ inputs.contract }}
1 change: 1 addition & 0 deletions smart-contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cw-utils = "1.0.3"
cw-asset = "3.0"
cw2 = "1.1.2"
cw20 = "1.1.2"
cw721 = "1.1.2"
cw20-base = {version = "1.1.2", features = ["library"]}
cw20-staking = "0.11.1"
apollo-cw-asset = "0.1.2"
Expand Down
1 change: 1 addition & 0 deletions smart-contracts/contracts/dex-router-osmosis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mars-owner = { workspace = true }
osmosis-std = { workspace = true }
quasar-types = { workspace = true }
prost = { workspace = true }
cw721 = { workspace = true }

[dev-dependencies]
osmosis-test-tube = { workspace = true }

0 comments on commit e95dc2b

Please sign in to comment.