ci: split tests workflow into two and refactor them #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, dynamic-callee-contract, dynamic-caller-contract, number, call-number, simple-callee, intermediate-number, events] | |
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 the contract needs other wasm file, please build currently | |
# | |
- 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 integration-test --locked --no-default-features | |
- name: Documentation tests | |
working-directory: ${{env.working-directory}} | |
run: cargo doc-test --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 on burner | |
working-directory: ${{env.working-directory}} | |
run: cargo clippy --tests -- -D warnings |