ci.yml
1 # # ADnet SDK Continuous Integration 2 # 3 # REPO_ACCESS_TOKEN secret required for cross-repo checkout 4 # 5 # Runs on: 6 # - Push to main/develop branches 7 # - Pull requests to main/develop 8 # 9 # Jobs: 10 # - Build: Compile all packages 11 # - Test: Run all tests 12 # - Lint: Run clippy and rustfmt 13 14 name: CI 15 16 on: 17 push: 18 branches: [main, develop] 19 pull_request: 20 branches: [main, develop] 21 22 env: 23 CARGO_TERM_COLOR: always 24 RUST_BACKTRACE: 1 25 LIBCLANG_PATH: /usr/lib/llvm-14/lib 26 27 jobs: 28 # ========================================================================== 29 # Build Job 30 # ========================================================================== 31 build: 32 name: Build 33 runs-on: ubuntu-latest 34 timeout-minutes: 45 35 36 steps: 37 - name: Checkout adnet-sdk 38 uses: actions/checkout@v4 39 with: 40 path: adnet-sdk 41 42 - name: Checkout alphavm 43 uses: actions/checkout@v4 44 with: 45 repository: BlockBlox-MD/alphavm 46 token: ${{ secrets.REPO_ACCESS_TOKEN }} 47 path: alphavm 48 49 - name: Checkout deltavm 50 uses: actions/checkout@v4 51 with: 52 repository: BlockBlox-MD/deltavm 53 token: ${{ secrets.REPO_ACCESS_TOKEN }} 54 path: deltavm 55 56 - name: Configure git credentials for cargo 57 run: | 58 # Use URL rewriting to inject token for all GitHub URLs 59 TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r') 60 git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" 61 mkdir -p ~/.cargo 62 echo '[net]' >> ~/.cargo/config.toml 63 echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml 64 65 - name: Install system dependencies 66 run: | 67 sudo apt-get update 68 sudo apt-get install -y \ 69 build-essential \ 70 cmake \ 71 clang-14 \ 72 llvm-14 \ 73 libclang-14-dev \ 74 pkg-config \ 75 libssl-dev 76 77 - name: Setup Rust toolchain 78 uses: dtolnay/rust-toolchain@stable 79 with: 80 components: rustfmt, clippy 81 82 - name: Cache cargo registry 83 uses: actions/cache@v4 84 with: 85 path: | 86 ~/.cargo/registry 87 ~/.cargo/git 88 key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} 89 restore-keys: | 90 ${{ runner.os }}-cargo-registry- 91 92 - name: Cache cargo build 93 uses: actions/cache@v4 94 with: 95 path: adnet-sdk/target 96 key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} 97 restore-keys: | 98 ${{ runner.os }}-cargo-build- 99 100 - name: Build all packages 101 working-directory: adnet-sdk 102 run: cargo build --release --workspace 103 104 # ========================================================================== 105 # Test Job 106 # ========================================================================== 107 test: 108 name: Test 109 runs-on: ubuntu-latest 110 timeout-minutes: 30 111 needs: build 112 113 steps: 114 - name: Checkout adnet-sdk 115 uses: actions/checkout@v4 116 with: 117 path: adnet-sdk 118 119 - name: Checkout alphavm 120 uses: actions/checkout@v4 121 with: 122 repository: BlockBlox-MD/alphavm 123 token: ${{ secrets.REPO_ACCESS_TOKEN }} 124 path: alphavm 125 126 - name: Checkout deltavm 127 uses: actions/checkout@v4 128 with: 129 repository: BlockBlox-MD/deltavm 130 token: ${{ secrets.REPO_ACCESS_TOKEN }} 131 path: deltavm 132 133 - name: Configure git credentials for cargo 134 run: | 135 # Use URL rewriting to inject token for all GitHub URLs 136 TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r') 137 git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" 138 mkdir -p ~/.cargo 139 echo '[net]' >> ~/.cargo/config.toml 140 echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml 141 142 - name: Install system dependencies 143 run: | 144 sudo apt-get update 145 sudo apt-get install -y \ 146 build-essential \ 147 cmake \ 148 clang-14 \ 149 llvm-14 \ 150 libclang-14-dev \ 151 pkg-config \ 152 libssl-dev 153 154 - name: Setup Rust toolchain 155 uses: dtolnay/rust-toolchain@stable 156 157 - name: Cache cargo 158 uses: actions/cache@v4 159 with: 160 path: | 161 ~/.cargo/registry 162 ~/.cargo/git 163 adnet-sdk/target 164 key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} 165 restore-keys: | 166 ${{ runner.os }}-cargo-test- 167 168 - name: Run tests 169 working-directory: adnet-sdk 170 run: cargo test --workspace --release 171 172 # ========================================================================== 173 # Lint Job 174 # ========================================================================== 175 lint: 176 name: Lint 177 runs-on: ubuntu-latest 178 timeout-minutes: 30 179 180 steps: 181 - name: Checkout adnet-sdk 182 uses: actions/checkout@v4 183 with: 184 path: adnet-sdk 185 186 - name: Checkout alphavm 187 uses: actions/checkout@v4 188 with: 189 repository: BlockBlox-MD/alphavm 190 token: ${{ secrets.REPO_ACCESS_TOKEN }} 191 path: alphavm 192 193 - name: Checkout deltavm 194 uses: actions/checkout@v4 195 with: 196 repository: BlockBlox-MD/deltavm 197 token: ${{ secrets.REPO_ACCESS_TOKEN }} 198 path: deltavm 199 200 - name: Configure git credentials for cargo 201 run: | 202 # Use URL rewriting to inject token for all GitHub URLs 203 TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r') 204 git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" 205 mkdir -p ~/.cargo 206 echo '[net]' >> ~/.cargo/config.toml 207 echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml 208 209 - name: Install system dependencies 210 run: | 211 sudo apt-get update 212 sudo apt-get install -y \ 213 build-essential \ 214 cmake \ 215 clang-14 \ 216 llvm-14 \ 217 libclang-14-dev \ 218 pkg-config \ 219 libssl-dev 220 221 - name: Setup Rust toolchain 222 uses: dtolnay/rust-toolchain@stable 223 with: 224 components: rustfmt, clippy 225 226 - name: Cache cargo 227 uses: actions/cache@v4 228 with: 229 path: | 230 ~/.cargo/registry 231 ~/.cargo/git 232 adnet-sdk/target 233 key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} 234 restore-keys: | 235 ${{ runner.os }}-cargo-lint- 236 237 - name: Install nightly for rustfmt 238 run: rustup toolchain install nightly --component rustfmt 239 240 - name: Check formatting 241 working-directory: adnet-sdk 242 run: cargo +nightly fmt --all -- --check 243 244 - name: Run Clippy 245 working-directory: adnet-sdk 246 run: cargo clippy --workspace --all-targets -- -D warnings