Merge pull request #579 from Georgebingi/main #176
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "contracts/**" | |
| - ".github/workflows/ci.yml" | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "contracts/**" | |
| - ".github/workflows/ci.yml" | |
| env: | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| contract: | |
| name: Contract Validation | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: contracts | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('contracts/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-git-${{ hashFiles('contracts/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v3 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('contracts/Cargo.lock') }} | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Build contract | |
| run: cargo build --release --target wasm32-unknown-unknown | |
| - name: Run tests | |
| run: cargo test | |
| - name: Verify WASM artifact | |
| run: | | |
| if ls ../target/wasm32-unknown-unknown/release/*.wasm 1> /dev/null 2>&1; then | |
| echo "✓ WASM file generated successfully" | |
| ls -lh ../target/wasm32-unknown-unknown/release/*.wasm | |
| else | |
| echo "✗ WASM file not found" | |
| find ../target -name "*.wasm" -type f | |
| exit 1 | |
| fi |