|
| 1 | +name: MACP Runtime CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [ main ] |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + check: |
| 13 | + name: Check |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Install Rust toolchain |
| 21 | + uses: dtolnay/rust-toolchain@stable |
| 22 | + |
| 23 | + - name: Cache cargo registry and build |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: | |
| 27 | + ~/.cargo/registry |
| 28 | + ~/.cargo/git |
| 29 | + target |
| 30 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 31 | + restore-keys: ${{ runner.os }}-cargo- |
| 32 | + |
| 33 | + - name: Install protoc |
| 34 | + run: | |
| 35 | + sudo apt-get update |
| 36 | + sudo apt-get install -y protobuf-compiler |
| 37 | +
|
| 38 | + - name: Cargo check |
| 39 | + run: cargo check --all-targets |
| 40 | + |
| 41 | + fmt: |
| 42 | + name: Format |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout repository |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Install Rust toolchain |
| 50 | + uses: dtolnay/rust-toolchain@stable |
| 51 | + with: |
| 52 | + components: rustfmt |
| 53 | + |
| 54 | + - name: Check formatting |
| 55 | + run: cargo fmt --all -- --check |
| 56 | + |
| 57 | + clippy: |
| 58 | + name: Clippy |
| 59 | + runs-on: ubuntu-latest |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout repository |
| 63 | + uses: actions/checkout@v4 |
| 64 | + |
| 65 | + - name: Install Rust toolchain |
| 66 | + uses: dtolnay/rust-toolchain@stable |
| 67 | + with: |
| 68 | + components: clippy |
| 69 | + |
| 70 | + - name: Cache cargo registry and build |
| 71 | + uses: actions/cache@v4 |
| 72 | + with: |
| 73 | + path: | |
| 74 | + ~/.cargo/registry |
| 75 | + ~/.cargo/git |
| 76 | + target |
| 77 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 78 | + restore-keys: ${{ runner.os }}-cargo- |
| 79 | + |
| 80 | + - name: Install protoc |
| 81 | + run: | |
| 82 | + sudo apt-get update |
| 83 | + sudo apt-get install -y protobuf-compiler |
| 84 | +
|
| 85 | + - name: Run clippy |
| 86 | + run: cargo clippy --all-targets -- -D warnings |
| 87 | + |
| 88 | + test: |
| 89 | + name: Test |
| 90 | + runs-on: ubuntu-latest |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Checkout repository |
| 94 | + uses: actions/checkout@v4 |
| 95 | + |
| 96 | + - name: Install Rust toolchain |
| 97 | + uses: dtolnay/rust-toolchain@stable |
| 98 | + |
| 99 | + - name: Cache cargo registry and build |
| 100 | + uses: actions/cache@v4 |
| 101 | + with: |
| 102 | + path: | |
| 103 | + ~/.cargo/registry |
| 104 | + ~/.cargo/git |
| 105 | + target |
| 106 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 107 | + restore-keys: ${{ runner.os }}-cargo- |
| 108 | + |
| 109 | + - name: Install protoc |
| 110 | + run: | |
| 111 | + sudo apt-get update |
| 112 | + sudo apt-get install -y protobuf-compiler |
| 113 | +
|
| 114 | + - name: Run tests |
| 115 | + run: cargo test --all-targets |
| 116 | + |
| 117 | + build: |
| 118 | + name: Build |
| 119 | + runs-on: ubuntu-latest |
| 120 | + |
| 121 | + steps: |
| 122 | + - name: Checkout repository |
| 123 | + uses: actions/checkout@v4 |
| 124 | + |
| 125 | + - name: Install Rust toolchain |
| 126 | + uses: dtolnay/rust-toolchain@stable |
| 127 | + |
| 128 | + - name: Cache cargo registry and build |
| 129 | + uses: actions/cache@v4 |
| 130 | + with: |
| 131 | + path: | |
| 132 | + ~/.cargo/registry |
| 133 | + ~/.cargo/git |
| 134 | + target |
| 135 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 136 | + restore-keys: ${{ runner.os }}-cargo- |
| 137 | + |
| 138 | + - name: Install protoc |
| 139 | + run: | |
| 140 | + sudo apt-get update |
| 141 | + sudo apt-get install -y protobuf-compiler |
| 142 | +
|
| 143 | + - name: Build release |
| 144 | + run: cargo build --release |
| 145 | + |
| 146 | + lint-protobuf: |
| 147 | + name: Lint Protocol Buffers |
| 148 | + runs-on: ubuntu-latest |
| 149 | + |
| 150 | + steps: |
| 151 | + - name: Checkout repository |
| 152 | + uses: actions/checkout@v4 |
| 153 | + |
| 154 | + - name: Install buf |
| 155 | + uses: bufbuild/buf-setup-action@v1 |
| 156 | + with: |
| 157 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 158 | + |
| 159 | + - name: Lint protobuf with buf |
| 160 | + run: buf lint proto |
| 161 | + |
| 162 | + - name: Check for breaking changes |
| 163 | + if: github.event_name == 'pull_request' |
| 164 | + run: | |
| 165 | + git fetch origin main |
| 166 | + # Skip if main branch doesn't have a buf module yet |
| 167 | + if git show origin/main:proto/buf.yaml > /dev/null 2>&1; then |
| 168 | + buf breaking proto --against '.git#branch=origin/main,subdir=proto' |
| 169 | + else |
| 170 | + echo "No buf module found on main branch, skipping breaking change check" |
| 171 | + fi |
| 172 | +
|
| 173 | + ci-pass: |
| 174 | + name: All Checks Passed |
| 175 | + runs-on: ubuntu-latest |
| 176 | + needs: [check, fmt, clippy, test, build, lint-protobuf] |
| 177 | + |
| 178 | + steps: |
| 179 | + - name: Summary |
| 180 | + run: | |
| 181 | + echo "All checks passed successfully" |
| 182 | + echo " - cargo check" |
| 183 | + echo " - cargo fmt" |
| 184 | + echo " - cargo clippy" |
| 185 | + echo " - cargo test" |
| 186 | + echo " - cargo build --release" |
| 187 | + echo " - protobuf lint" |
0 commit comments