|
| 1 | +# Based on https://github.com/actions-rs/example/blob/master/.github/workflows/quickstart.yml |
| 2 | +name: Test and Lint CW contracts |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - "**" |
| 8 | + paths: |
| 9 | + - "contracts/**" |
| 10 | + - ".github/workflows/Basic.yml" |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + |
| 15 | +jobs: |
| 16 | + |
| 17 | + test: |
| 18 | + name: Test Suite |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout sources |
| 23 | + uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Install Rust |
| 26 | + run: rustup update stable |
| 27 | + |
| 28 | + - name: Cache Rust dependencies |
| 29 | + uses: Swatinem/rust-cache@v2 |
| 30 | + |
| 31 | + - name: Run unit tests |
| 32 | + run: | |
| 33 | + RUST_BACKTRACE=1 cargo unit-test --locked |
| 34 | +
|
| 35 | + - name: Install wasm32 |
| 36 | + run: | |
| 37 | + rustup target add wasm32-unknown-unknown |
| 38 | +
|
| 39 | + - name: Compile WASM contract |
| 40 | + run: | |
| 41 | + RUSTFLAGS='-C link-arg=-s' cargo wasm --locked |
| 42 | +
|
| 43 | + lints: |
| 44 | + name: Lints |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - name: Checkout sources |
| 48 | + uses: actions/checkout@v3 |
| 49 | + |
| 50 | + - name: Install Rust |
| 51 | + run: rustup update stable |
| 52 | + |
| 53 | + - name: Cache Rust dependencies |
| 54 | + uses: Swatinem/rust-cache@v2 |
| 55 | + |
| 56 | + - name: Run cargo fmt |
| 57 | + run: | |
| 58 | + cargo fmt --all -- --check |
| 59 | +
|
| 60 | + - name: Run cargo clippy |
| 61 | + run: | |
| 62 | + cargo clippy -- -D warnings |
| 63 | +
|
| 64 | + - name: Generate schema |
| 65 | + run: | |
| 66 | + cd contracts |
| 67 | + ../scripts/run_in_subprojects.sh token-contracts/cw-hub-bnusd |
| 68 | +
|
| 69 | + - name: Verify schema |
| 70 | + uses: tj-actions/verify-changed-files@v14 |
| 71 | + id: verify-schema |
| 72 | + with: |
| 73 | + files: | |
| 74 | + contracts/*/*/schema/** |
| 75 | +
|
| 76 | + - name: Display changed schemas |
| 77 | + if: steps.verify-schema.outputs.files_changed == 'true' |
| 78 | + run: | |
| 79 | + echo "Changed files: ${{ steps.verify-schema.outputs.changed_files }}" |
0 commit comments