ci.yml
1 name: CI 2 3 on: 4 push: 5 branches: [main, develop] 6 pull_request: 7 branches: [main, develop] 8 9 env: 10 CARGO_TERM_COLOR: always 11 RUST_BACKTRACE: 1 12 13 jobs: 14 test: 15 name: Test Suite 16 runs-on: ${{ matrix.os }} 17 strategy: 18 matrix: 19 os: [ubuntu-latest, macos-latest] 20 rust: [stable, nightly] 21 steps: 22 - uses: actions/checkout@v4 23 24 - name: Install Rust 25 uses: actions-rs/toolchain@v1 26 with: 27 toolchain: ${{ matrix.rust }} 28 profile: minimal 29 override: true 30 components: rustfmt, clippy 31 32 - name: Cache cargo registry 33 uses: actions/cache@v3 34 with: 35 path: ~/.cargo/registry 36 key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} 37 38 - name: Cache cargo index 39 uses: actions/cache@v3 40 with: 41 path: ~/.cargo/git 42 key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} 43 44 - name: Cache cargo build 45 uses: actions/cache@v3 46 with: 47 path: target 48 key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} 49 50 - name: Check formatting 51 run: cargo fmt -- --check 52 continue-on-error: ${{ matrix.rust == 'nightly' }} 53 54 - name: Run clippy 55 run: cargo clippy --all-targets --all-features -- -D warnings 56 continue-on-error: ${{ matrix.rust == 'nightly' }} 57 58 - name: Build 59 run: cargo build --verbose --all 60 61 - name: Run tests 62 run: cargo test --verbose --all 63 64 - name: Build release 65 run: cargo build --release --all 66 67 foundry-integration: 68 name: Foundry Integration Test 69 runs-on: ubuntu-latest 70 steps: 71 - uses: actions/checkout@v4 72 73 - name: Install Rust 74 uses: actions-rs/toolchain@v1 75 with: 76 toolchain: stable 77 profile: minimal 78 override: true 79 80 - name: Install Foundry 81 uses: foundry-rs/foundry-toolchain@v1 82 with: 83 version: nightly 84 85 - name: Build gramr 86 run: cargo build --release --all 87 88 - name: Test contract generation 89 run: | 90 mkdir test-project && cd test-project 91 forge init --force 92 ../target/release/gramr new contract TestToken --solidity --oz-erc20 93 forge build 94 95 - name: Test wotan wizard (smoke test) 96 run: | 97 timeout 5 ../target/release/wotan --help || true 98 99 coverage: 100 name: Test Coverage 101 runs-on: ubuntu-latest 102 steps: 103 - uses: actions/checkout@v4 104 105 - name: Install Rust 106 uses: actions-rs/toolchain@v1 107 with: 108 toolchain: stable 109 profile: minimal 110 override: true 111 112 - name: Install cargo-tarpaulin 113 run: cargo install cargo-tarpaulin 114 115 - name: Cache cargo registry 116 uses: actions/cache@v3 117 with: 118 path: ~/.cargo/registry 119 key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} 120 121 - name: Cache cargo index 122 uses: actions/cache@v3 123 with: 124 path: ~/.cargo/git 125 key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} 126 127 - name: Generate code coverage 128 run: | 129 cargo tarpaulin --config tarpaulin.toml --workspace --lib --out xml 130 131 - name: Upload coverage to Codecov 132 uses: codecov/codecov-action@v3 133 with: 134 file: ./cobertura.xml 135 flags: unittests 136 name: codecov-umbrella 137 fail_ci_if_error: false