Skip to content

Commit

Permalink
ci: split tests workflow into two and refactor them (#352)
Browse files Browse the repository at this point in the history
* ci: split tests workflow into two and refactor them  (#351)

* ci: split tests workflow into two and refactor them

Signed-off-by: 170210 <j170210@icloud.com>

* ci: add document test for each contract

Signed-off-by: 170210 <j170210@icloud.com>

* ci: update cache action version

Signed-off-by: 170210 <j170210@icloud.com>

* chore: typo error

Signed-off-by: 170210 <j170210@icloud.com>

* ci: use test --doc instead of doc-test config

Signed-off-by: 170210 <j170210@icloud.com>

* ci: use cargo test --test integration instead of config

Signed-off-by: 170210 <j170210@icloud.com>

* chore: typo error (fix for comment)

Signed-off-by: 170210 <j170210@icloud.com>

* chore: delete unnecessary env parameter

Signed-off-by: 170210 <j170210@icloud.com>

* fixup: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>

* fix: update schema in cyberpunk contract

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>
  • Loading branch information
170210 authored Apr 11, 2024
1 parent a9bb800 commit 9397169
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 593 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/contract_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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
Loading

0 comments on commit 9397169

Please sign in to comment.