mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-22 05:00:59 +03:00
325 lines
10 KiB
YAML
Executable File
325 lines
10 KiB
YAML
Executable File
version: 2.1
|
|
|
|
# Notes
|
|
# - `sccache` was removed because it doesn't actually provide much benefit in CI. Lots of cache misses.
|
|
# - https://github.com/Swatinem/rust-cache?tab=readme-ov-file#cache-details provides guidance on which directories to cache.
|
|
# - Incremental builds should be disabled in CI, since they don't provide much benefit.
|
|
# - Enabling `--only_testnet` feature flag to reduce the amount of time spent building leo-lang, since it's not needed for the test suite.
|
|
|
|
# Rust Version: 1.82.0
|
|
# Ensure that this matches the `rust-version` in `Cargo.toml`.
|
|
# If this is changed, propogate the changes to all places in this file, including the `install-rust` command.
|
|
|
|
# TODO:
|
|
# - The cache size can accumulate as the dependencies get upgraded. Ideally you want some pruning before the cache gets persisted.
|
|
# See swatinem/rust-cache for a sensible approach. Unfortunately, we'd have to build this for CircleCI.
|
|
# - Rust v1.83.0 is coming with some sensible cargo rebuild improvements. We should upgrade to that when it's released.
|
|
|
|
|
|
environment:
|
|
CARGO_INCREMENTAL: 0
|
|
RUSTFLAGS: "-D warnings"
|
|
|
|
orbs:
|
|
windows: circleci/windows@5.0
|
|
codecov: codecov/codecov@1.0.2
|
|
|
|
executors:
|
|
macos-executor:
|
|
macos:
|
|
xcode: "16.0.0" # Use appropriate Xcode version
|
|
resource_class: m2pro.large
|
|
|
|
linux-executor:
|
|
docker:
|
|
- image: "cimg/rust:1.82.0" # Ensure that this matches the `rust-version` in `Cargo.toml`.
|
|
resource_class: xlarge
|
|
|
|
commands:
|
|
install-rust:
|
|
description: "Install Rust (Linux/macOS)"
|
|
steps:
|
|
- run:
|
|
name: Install Rust
|
|
command: |
|
|
# If Rust is not installed on the machine, install it
|
|
if ! command -v rustc &> /dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
source "$HOME/.cargo/env"
|
|
rustup install 1.82.0
|
|
rustup override set 1.82.0
|
|
cargo --version --verbose
|
|
rustc --version
|
|
fi
|
|
if [ ! -f "Cargo.lock" ]; then
|
|
cargo generate-lockfile
|
|
fi
|
|
cargo install cargo-mtime
|
|
|
|
|
|
|
|
install-rust-windows:
|
|
description: "Install Rust (Windows)"
|
|
steps:
|
|
- run:
|
|
name: Install Rust (Windows)
|
|
command: |
|
|
$ProgressPreference = "SilentlyContinue"
|
|
choco uninstall rust
|
|
Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\\rustup-init.exe"
|
|
Start-Process "C:\\rustup-init.exe" -ArgumentList '-y' -Wait
|
|
$Env:Path += ";$Env:USERPROFILE\.cargo\bin"
|
|
rustup install 1.82.0
|
|
rustup default 1.82.0
|
|
cargo --version --verbose
|
|
rustc --version | Out-File -FilePath "rust-version"
|
|
if (!(Test-Path "Cargo.lock" -PathType Leaf)) {
|
|
cargo generate-lockfile
|
|
}
|
|
cargo install cargo-mtime
|
|
|
|
build-and-test:
|
|
description: "Build and run tests"
|
|
steps:
|
|
- run:
|
|
name: Build
|
|
no_output_timeout: 30m
|
|
command: |
|
|
cargo-mtime . ~/.cache/mtimes/project.db
|
|
cargo test --no-run --all --locked --profile ci --features only_testnet
|
|
- run:
|
|
name: Run tests
|
|
no_output_timeout: 30m
|
|
# The `--verbose` flag is used to check which files are being recompiled. Ideally, this should be none.
|
|
command: |
|
|
cargo-mtime . ~/.cache/mtimes/project.db
|
|
cargo test --all --locked --profile ci --features only_testnet --verbose
|
|
|
|
install_rust_nightly:
|
|
description: "Install Rust nightly toolchain"
|
|
steps:
|
|
- run: rustup toolchain install nightly-x86_64-unknown-linux-gnu
|
|
|
|
jobs:
|
|
test-windows:
|
|
executor:
|
|
name: windows/default
|
|
size: xlarge
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}
|
|
- cargo-v1-{{ arch }}
|
|
- install-rust-windows
|
|
- run:
|
|
name: Update Submodules
|
|
command: git submodule update --init --recursive
|
|
- build-and-test
|
|
- save_cache:
|
|
key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
paths:
|
|
- C:\Users\circleci\.cargo
|
|
- target
|
|
|
|
test-macos:
|
|
executor: macos-executor
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}
|
|
- cargo-v1-{{ arch }}
|
|
- install-rust
|
|
- run:
|
|
name: Update Submodules
|
|
command: git submodule update --init --recursive
|
|
- build-and-test
|
|
- save_cache:
|
|
key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
paths:
|
|
- ~/.cargo
|
|
- target
|
|
|
|
test-linux:
|
|
executor: linux-executor
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}
|
|
- cargo-v1-{{ arch }}
|
|
- install-rust
|
|
- run:
|
|
name: Update Submodules
|
|
command: git submodule update --init --recursive
|
|
- build-and-test
|
|
- save_cache:
|
|
key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
paths:
|
|
- ~/.cargo
|
|
- target
|
|
|
|
# TODO: Move code-coverage to CircleCI
|
|
# code-coverage:
|
|
# executor: linux-executor
|
|
# steps:
|
|
# - checkout
|
|
# - restore_cache:
|
|
# keys:
|
|
# - codecov-cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
# - codecov-cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}
|
|
# - codecov-cargo-v1-{{ arch }}
|
|
# - install-rust
|
|
# - build-and-test
|
|
# - codecov/upload:
|
|
# file: { { coverage_report_filepath } }
|
|
# - save_cache:
|
|
# key: codecov-cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
# paths:
|
|
# - ~/.cargo
|
|
# - target
|
|
|
|
check-style-clippy-docs:
|
|
executor: linux-executor
|
|
resource_class: large
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}
|
|
- cargo-v1-{{ arch }}
|
|
- install_rust_nightly
|
|
- run:
|
|
name: Update Submodules
|
|
command: git submodule update --init --recursive
|
|
- run:
|
|
name: Check style
|
|
no_output_timeout: 35m
|
|
command: cargo +nightly fmt --all -- --check
|
|
- run:
|
|
name: Clippy
|
|
no_output_timeout: 35m
|
|
command: |
|
|
cargo clippy --workspace --all-targets -- -D warnings
|
|
cargo clippy --workspace --all-targets --all-features -- -D warnings
|
|
- run:
|
|
name: Build Cargo Docs
|
|
command: |
|
|
cargo doc --no-deps --document-private-items --workspace
|
|
rm -rf ./tests
|
|
environment:
|
|
RUSTDOCFLAGS: "--enable-index-page -Zunstable-options"
|
|
RUSTC_BOOTSTRAP: "1"
|
|
- save_cache:
|
|
key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
paths:
|
|
- ~/.cargo
|
|
- target
|
|
|
|
leo-executable:
|
|
executor: linux-executor
|
|
resource_class: xlarge
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
- cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}
|
|
- cargo-v1-{{ arch }}
|
|
- run:
|
|
name: Update Submodules
|
|
command: git submodule update --init --recursive
|
|
- run:
|
|
name: Build and install Leo
|
|
no_output_timeout: 30m
|
|
command: cargo install --path . --root . --locked
|
|
- persist_to_workspace:
|
|
root: ~/
|
|
paths:
|
|
- project/
|
|
- save_cache:
|
|
key: cargo-v1-{{ arch }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
|
|
paths:
|
|
- ~/.cargo
|
|
- target
|
|
|
|
leo-new:
|
|
docker:
|
|
- image: cimg/rust:1.82
|
|
resource_class: xlarge
|
|
steps:
|
|
- attach_workspace:
|
|
at: /home/circleci/project/
|
|
- run:
|
|
name: leo new
|
|
command: |
|
|
export LEO=/home/circleci/project/project/bin/leo
|
|
timeout 30m ./project/.circleci/leo-new.sh
|
|
|
|
leo-clean:
|
|
docker:
|
|
- image: cimg/rust:1.82
|
|
resource_class: xlarge
|
|
steps:
|
|
- attach_workspace:
|
|
at: /home/circleci/project/
|
|
- run:
|
|
name: leo clean
|
|
command: |
|
|
export LEO=/home/circleci/project/project/bin/leo
|
|
./project/.circleci/leo-clean.sh
|
|
|
|
leo-example:
|
|
docker:
|
|
- image: cimg/rust:1.82
|
|
resource_class: xlarge
|
|
steps:
|
|
- attach_workspace:
|
|
at: /home/circleci/project/
|
|
- run:
|
|
name: leo example
|
|
command: |
|
|
export LEO=/home/circleci/project/project/bin/leo
|
|
./project/.circleci/leo-example.sh
|
|
|
|
test-examples:
|
|
docker:
|
|
- image: cimg/rust:1.82
|
|
resource_class: xlarge
|
|
steps:
|
|
- attach_workspace:
|
|
at: /home/circleci/project/
|
|
- run:
|
|
name: test examples example
|
|
command: |
|
|
export LEO=/home/circleci/project/project/bin/leo
|
|
export EXAMPLES=/home/circleci/project/project/examples
|
|
./project/.circleci/test-examples.sh
|
|
|
|
workflows:
|
|
version: 2
|
|
main-workflow:
|
|
jobs:
|
|
- test-windows
|
|
- test-macos
|
|
- test-linux
|
|
- check-style-clippy-docs
|
|
- leo-executable
|
|
- leo-new:
|
|
requires:
|
|
- leo-executable
|
|
- leo-clean:
|
|
requires:
|
|
- leo-executable
|
|
- leo-example:
|
|
requires:
|
|
- leo-executable
|
|
- test-examples:
|
|
requires:
|
|
- leo-executable
|