Skip to content

ci: split tests workflow into two and refactor them #9

ci: split tests workflow into two and refactor them

ci: split tests workflow into two and refactor them #9

Workflow file for this run

name: Contract Tests
on:
push:
branches:
- main
- 0.[0-9]+
pull_request:
jobs:
contract_build_and_test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
contract: [burner, crypto-verify, cyberpunk, hackatom, ibc-reflect, ibc-reflect-send, queue, query-queue, reflect, floaty, staking, voting-with-uuid]
env:
working-directory: ./contracts/${{ matrix.contract }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
target: wasm32-unknown-unknown
profile: minimal
override: true
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: ~/.cargo
key: cargocache-v2-${{ matrix.contract }}-rust:1.60.0-${{ hashFiles(format('contracts/{0}/Cargo.lock', matrix.contract)) }}
- name: Version information
run: rustc --version; cargo --version; rustup --version; rustup target list --installed
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown && rustup target list --installed
- name: Build wasm binary
working-directory: ${{env.working-directory}}
run: cargo wasm --locked
- name: Unit tests
working-directory: ${{env.working-directory}}
run: cargo unit-test --locked
#
# If this contract requires other contracts for integration testing, please compile it here
#
- name: Build queue wasm binary for integration tests (query-queue)
if: matrix.contract == 'query-queue'
working-directory: ./contracts/queue
run: cargo wasm --locked
#
# Finish
#
- name: Integration tests (singlepass backend)
working-directory: ${{env.working-directory}}
run: cargo test --test integration --locked --no-default-features
- name: Documentation tests
working-directory: ${{env.working-directory}}
run: cargo test --doc --locked
- name: Build and run schema generator
working-directory: ${{env.working-directory}}
run: cargo schema --locked
- name: Ensure schemas are up-to-date
working-directory: ${{env.working-directory}}
run: |
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- name: Check formatting
working-directory: ${{env.working-directory}}
run: cargo fmt -- --check
- name: Clippy linting
working-directory: ${{env.working-directory}}
run: cargo clippy --tests -- -D warnings