|
| 1 | +# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. |
| 2 | +# See the file LICENSE for licensing terms. |
| 3 | + |
| 4 | +name: Contracts CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + pull_request: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + cargo-fmt: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + - name: Install Rust |
| 23 | + uses: ./.github/actions/install-rust |
| 24 | + with: |
| 25 | + cache: false |
| 26 | + - uses: Swatinem/rust-cache@v2 |
| 27 | + with: |
| 28 | + # we just want to cache the tools for this one |
| 29 | + cache-targets: false |
| 30 | + # need to cache "all-crates" to get the tools |
| 31 | + cache-all-crates: true |
| 32 | + # caching isn't actually for dependencies but the tools |
| 33 | + # so it doesn't matter if the job passes or fails |
| 34 | + cache-on-failure: true |
| 35 | + - uses: taiki-e/install-action@v2 |
| 36 | + with: |
| 37 | + tool: taplo-cli |
| 38 | + - name: Run static analysis tests |
| 39 | + run: cargo fmt --all --check |
| 40 | + - name: Check TOML files |
| 41 | + run: taplo fmt --check |
| 42 | + - name: print diff |
| 43 | + if: failure() |
| 44 | + run: | |
| 45 | + cargo fmt --all |
| 46 | + taplo fmt |
| 47 | + git diff --color=always |
| 48 | +
|
| 49 | + cargo-doc: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@v4 |
| 54 | + - name: Install Go |
| 55 | + uses: ./.github/actions/install-go |
| 56 | + - name: Install Rust |
| 57 | + uses: ./.github/actions/install-rust |
| 58 | + with: |
| 59 | + targets: wasm32-unknown-unknown |
| 60 | + cache: false |
| 61 | + - name: Run doc tests |
| 62 | + run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items --all |
| 63 | + |
| 64 | + cargo-clippy: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + - name: Install Go |
| 70 | + uses: ./.github/actions/install-go |
| 71 | + - name: Install Rust |
| 72 | + uses: ./.github/actions/install-rust |
| 73 | + with: |
| 74 | + targets: wasm32-unknown-unknown |
| 75 | + - name: Run static analysis tests |
| 76 | + shell: bash |
| 77 | + run: cargo clippy --all --all-features --tests --benches --examples -- -D warnings |
| 78 | + |
| 79 | + cargo-test: |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + - name: Install Go |
| 85 | + uses: ./.github/actions/install-go |
| 86 | + - name: Install Rust |
| 87 | + uses: ./.github/actions/install-rust |
| 88 | + with: |
| 89 | + targets: wasm32-unknown-unknown |
| 90 | + - name: Run unit tests |
| 91 | + run: cargo test --all-features --all |
| 92 | + |
| 93 | + cross-tests: |
| 94 | + runs-on: ubuntu-latest |
| 95 | + services: |
| 96 | + docker: |
| 97 | + image: docker:19.03.12 |
| 98 | + options: --privileged |
| 99 | + steps: |
| 100 | + - name: Checkout |
| 101 | + uses: actions/checkout@v4 |
| 102 | + - name: Install Rust |
| 103 | + uses: ./.github/actions/install-rust |
| 104 | + - uses: Swatinem/rust-cache@v2 |
| 105 | + with: |
| 106 | + # we just want to cache the tools for this one |
| 107 | + cache-targets: false |
| 108 | + # need to cache "all-crates" to get the tools |
| 109 | + cache-all-crates: true |
| 110 | + # caching isn't actually for dependencies but the tools |
| 111 | + # so it doesn't matter if the job passes or fails |
| 112 | + cache-on-failure: true |
| 113 | + - uses: taiki-e/install-action@v2 |
| 114 | + with: |
| 115 | + tool: cross |
| 116 | + - name: Run cross tests |
| 117 | + run: | |
| 118 | + cross -v test -p wasmlanche --target=wasm32-unknown-emscripten |
| 119 | +
|
| 120 | + go-test: |
| 121 | + runs-on: ubuntu-20.04-32 |
| 122 | + steps: |
| 123 | + - name: Checkout |
| 124 | + uses: actions/checkout@v4 |
| 125 | + - name: Set up Go |
| 126 | + uses: ./.github/actions/install-go |
| 127 | + - name: Install Rust |
| 128 | + uses: ./.github/actions/install-rust |
| 129 | + with: |
| 130 | + targets: wasm32-unknown-unknown |
| 131 | + cache: false |
| 132 | + - name: Run unit tests |
| 133 | + shell: bash |
| 134 | + run: go test -v -race ./x/contracts/... |
| 135 | + |
| 136 | + go-bench: |
| 137 | + runs-on: ubuntu-20.04-32 |
| 138 | + steps: |
| 139 | + - name: Checkout |
| 140 | + uses: actions/checkout@v4 |
| 141 | + - name: Set up Go |
| 142 | + uses: ./.github/actions/install-go |
| 143 | + - name: Install Rust |
| 144 | + uses: ./.github/actions/install-rust |
| 145 | + with: |
| 146 | + targets: wasm32-unknown-unknown |
| 147 | + cache: false |
| 148 | + - name: Run unit tests |
| 149 | + shell: bash |
| 150 | + run: go test -v -benchmem -run=^$ -bench=. -benchtime=1x ./x/contracts/... |
0 commit comments