Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add reusable workflow for test-tube tests #666

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 6 additions & 78 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down Expand Up @@ -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/[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/cl_vault.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: 'cl-vault'
test-tube:
uses: ./.github/workflows/rust_test_tube.yml
with:
contract: 'cl-vault'
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'
22 changes: 22 additions & 0 deletions .github/workflows/merkle_incentives.yml
Original file line number Diff line number Diff line change
@@ -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'
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
44 changes: 44 additions & 0 deletions .github/workflows/rust_test_tube.yml
Original file line number Diff line number Diff line change
@@ -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/[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 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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
magiodev marked this conversation as resolved.
Show resolved Hide resolved
test-tube = "test -- --include-ignored --test-threads=1"
test-tube-build = "build --release --lib --target wasm32-unknown-unknown --target-dir ./test-tube-build"
1 change: 1 addition & 0 deletions smart-contracts/contracts/merkle-incentives/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
#[cfg(not(target_arch = "wasm32"))]
use cosmwasm_std::Empty;

use crate::{
Expand Down
Loading