config.yml
1 version: 2.1 2 3 parameters: 4 alphaos-rev: 5 type: string 6 default: "v4.4.0" 7 8 # Notes 9 # - `sccache` was removed because it doesn't actually provide much benefit in CI. Lots of cache misses. 10 # - https://github.com/Swatinem/rust-cache?tab=readme-ov-file#cache-details provides guidance on which directories to cache. 11 # - Incremental builds should be disabled in CI, since they don't provide much benefit. 12 # - Enabling `--only_testnet` feature flag to reduce the amount of time spent building leo-lang, since it's not needed for the test suite. 13 14 # Rust Version: 1.92.0 15 # Ensure that this matches the `rust-version` in `Cargo.toml`. 16 # If this is changed, propogate the changes to all places in this file, including the `install-rust` command. 17 18 # TODO: 19 # - The cache size can accumulate as the dependencies get upgraded. Ideally you want some pruning before the cache gets persisted. 20 # See swatinem/rust-cache for a sensible approach. Unfortunately, we'd have to build this for CircleCI. 21 22 23 orbs: 24 windows: circleci/windows@5.1.0 25 codecov: codecov/codecov@1.0.2 26 27 executors: 28 macos-executor: 29 macos: 30 xcode: "26.0.1" # Use appropriate Xcode version 31 resource_class: m4pro.large 32 33 linux-executor: 34 docker: 35 - image: "cimg/rust:1.92.0" # Ensure that this matches the `rust-version` in `Cargo.toml`. 36 resource_class: 2xlarge 37 38 commands: 39 install-rust: 40 description: "Install Rust (Linux/macOS)" 41 steps: 42 - run: 43 name: Install Rust 44 command: | 45 # If Rust is not installed on the machine, install it 46 # (temporarily install it regardless, as we want 1.92.0, not 1.85.0) 47 # if ! command -v rustc &> /dev/null; then 48 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 49 source "$HOME/.cargo/env" 50 rustup install 1.92.0 51 rustup override set 1.92.0 52 cargo --version --verbose 53 rustc --version 54 # fi 55 if [ ! -f "Cargo.lock" ]; then 56 cargo generate-lockfile 57 fi 58 cargo install cargo-mtime 59 60 61 62 install-rust-windows: 63 description: "Install Rust (Windows)" 64 steps: 65 - run: 66 name: Install Rust (Windows) 67 command: | 68 $ProgressPreference = "SilentlyContinue" 69 choco uninstall rust 70 Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\\rustup-init.exe" 71 Start-Process "C:\\rustup-init.exe" -ArgumentList '-y' -Wait 72 $Env:Path += ";$Env:USERPROFILE\.cargo\bin" 73 rustup install 1.92.0 74 rustup default 1.92.0 75 cargo --version --verbose 76 rustc --version | Out-File -FilePath "rust-version" 77 if (!(Test-Path "Cargo.lock" -PathType Leaf)) { 78 cargo generate-lockfile 79 } 80 cargo install cargo-mtime 81 82 install-alphaos: 83 description: "Install alphaos (Linux/macOS)" 84 steps: 85 - restore_cache: 86 keys: 87 - alphaos-bin-v1-{{ arch }}-<< pipeline.parameters.alphaos-rev >> 88 - run: 89 name: Install alphaos 90 command: | 91 set -euo pipefail 92 # Skip build if binary already exists from cache 93 if command -v alphaos &> /dev/null; then 94 echo "alphaos found in cache, skipping build" 95 alphaos --version 96 exit 0 97 fi 98 git clone https://github.com/BlockBlox-MD/alphaos.git 99 cd alphaos 100 git checkout << pipeline.parameters.alphaos-rev >> 101 cargo install --path . --features test_network --locked --force 102 cd .. 103 rm -rf alphaos 104 ulimit -n 65535 105 - save_cache: 106 key: alphaos-bin-v1-{{ arch }}-<< pipeline.parameters.alphaos-rev >> 107 paths: 108 - ~/.cargo/bin/alphaos 109 110 build-and-test: 111 description: "Build and run tests" 112 steps: 113 - run: 114 name: Build 115 no_output_timeout: 30m 116 command: | 117 cargo-mtime . ~/.cache/mtimes/project.db 118 cargo test --no-run --all --locked --profile ci --features only_testnet 119 - run: 120 name: Run tests 121 no_output_timeout: 30m 122 # The `--verbose` flag is used to check which files are being recompiled. Ideally, this should be none. 123 command: | 124 cargo-mtime . ~/.cache/mtimes/project.db 125 cargo test --all --locked --profile ci --features only_testnet --verbose 126 127 install_rust_nightly: 128 description: "Install Rust nightly toolchain" 129 steps: 130 - run: rustup toolchain install nightly-x86_64-unknown-linux-gnu 131 132 jobs: 133 test-windows: 134 executor: 135 name: windows/default 136 size: xlarge 137 environment: 138 CARGO_NET_GIT_FETCH_WITH_CLI: "true" 139 RUST_MIN_STACK: "16777216" # 16 MB stack for rustc 140 CARGO_INCREMENTAL: 0 141 steps: 142 - run: 143 name: Force git to use HTTPS 144 command: | 145 git config --global url."https://github.com/".insteadOf "git@github.com:" 146 git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" 147 - checkout 148 - restore_cache: 149 keys: 150 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 151 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }} 152 - cargo-v1-{{ arch }} 153 - install-rust-windows 154 - run: 155 name: Update Submodules 156 command: git submodule update --init --recursive 157 - build-and-test 158 - save_cache: 159 key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 160 paths: 161 - C:\Users\circleci\.cargo 162 - C:\Users\circleci\.alpha\resources 163 164 test-macos: 165 executor: macos-executor 166 steps: 167 - checkout 168 - restore_cache: 169 keys: 170 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 171 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }} 172 - cargo-v1-{{ arch }} 173 - install-rust 174 - install-alphaos 175 - run: 176 name: Verify SnarkOS installation 177 command: | 178 alphaos --version 179 - run: 180 name: Update Submodules 181 command: git submodule update --init --recursive 182 - build-and-test 183 - save_cache: 184 key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 185 paths: 186 - ~/.cargo 187 - ~/.alpha/resources 188 189 test-linux: 190 executor: linux-executor 191 steps: 192 - checkout 193 - restore_cache: 194 keys: 195 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 196 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }} 197 - cargo-v1-{{ arch }} 198 - install-rust 199 - run: 200 name: Install alphaos dependencies 201 command: | 202 sudo apt-get update 203 sudo apt-get install -y \ 204 build-essential \ 205 clang \ 206 libssl-dev \ 207 llvm \ 208 lld \ 209 pkg-config 210 - install-alphaos 211 - run: 212 name: Verify SnarkOS installation 213 command: | 214 alphaos --version 215 - run: 216 name: Update Submodules 217 command: git submodule update --init --recursive 218 - build-and-test 219 - save_cache: 220 key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 221 paths: 222 - ~/.cargo 223 - ~/.alpha/resources 224 225 # TODO: Move code-coverage to CircleCI 226 # code-coverage: 227 # executor: linux-executor 228 # steps: 229 # - checkout 230 # - restore_cache: 231 # keys: 232 # - codecov-cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 233 # - codecov-cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }} 234 # - codecov-cargo-v1-{{ arch }} 235 # - install-rust 236 # - build-and-test 237 # - codecov/upload: 238 # file: { { coverage_report_filepath } } 239 # - save_cache: 240 # key: codecov-cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 241 # paths: 242 # - ~/.cargo 243 # - ~/.alpha/resources 244 245 check-style-clippy-docs: 246 executor: linux-executor 247 resource_class: large 248 steps: 249 - checkout 250 - restore_cache: 251 keys: 252 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 253 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }} 254 - cargo-v1-{{ arch }} 255 - install_rust_nightly 256 - run: 257 name: Update Submodules 258 command: git submodule update --init --recursive 259 - run: 260 name: Check style 261 no_output_timeout: 35m 262 command: cargo +nightly fmt --all -- --check 263 - run: 264 name: Clippy 265 no_output_timeout: 35m 266 command: | 267 cargo clippy --workspace --all-targets -- -D warnings 268 cargo clippy --workspace --all-targets --all-features -- -D warnings 269 - run: 270 name: Build Cargo Docs 271 command: | 272 cargo doc --no-deps --document-private-items --workspace 273 rm -rf ./tests 274 environment: 275 RUSTDOCFLAGS: "--enable-index-page -Zunstable-options" 276 RUSTC_BOOTSTRAP: "1" 277 - save_cache: 278 key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 279 paths: 280 - ~/.cargo 281 282 leo-executable: 283 executor: linux-executor 284 resource_class: xlarge 285 steps: 286 - checkout 287 - restore_cache: 288 keys: 289 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 290 - cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }} 291 - cargo-v1-{{ arch }} 292 - run: 293 name: Update Submodules 294 command: git submodule update --init --recursive 295 - run: 296 name: Build and install Leo 297 no_output_timeout: 30m 298 command: cargo install --path . --root . --locked 299 - persist_to_workspace: 300 root: ~/ 301 paths: 302 - project/ 303 - save_cache: 304 key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} 305 paths: 306 - ~/.cargo 307 308 leo-new: 309 docker: 310 - image: cimg/rust:1.92.0 311 resource_class: xlarge 312 steps: 313 - attach_workspace: 314 at: /home/circleci/project/ 315 - run: 316 name: leo new 317 command: | 318 export LEO=/home/circleci/project/project/bin/leo 319 timeout 30m ./project/.circleci/leo-new.sh 320 321 leo-clean: 322 docker: 323 - image: cimg/rust:1.92.0 324 resource_class: xlarge 325 steps: 326 - attach_workspace: 327 at: /home/circleci/project/ 328 - run: 329 name: leo clean 330 command: | 331 export LEO=/home/circleci/project/project/bin/leo 332 ./project/.circleci/leo-clean.sh 333 334 test-examples: 335 docker: 336 - image: cimg/rust:1.92.0 337 resource_class: xlarge 338 steps: 339 - attach_workspace: 340 at: /home/circleci/project/ 341 - run: 342 name: test examples example 343 command: | 344 export LEO=/home/circleci/project/project/bin/leo 345 export EXAMPLES=/home/circleci/project/project/examples 346 ./project/.circleci/test-examples.sh 347 348 workflows: 349 version: 2 350 351 test-windows: 352 jobs: 353 - test-windows 354 355 test-macos: 356 jobs: 357 - test-macos 358 359 test-linux: 360 jobs: 361 - test-linux 362 363 code-quality: 364 jobs: 365 - check-style-clippy-docs 366 367 leo-executable: 368 jobs: 369 - leo-executable 370 - leo-new: 371 requires: 372 - leo-executable 373 - leo-clean: 374 requires: 375 - leo-executable 376 - test-examples: 377 requires: 378 - leo-executable