version: 2.1
orbs:
rust: circleci/rust@1.6.0
gh: circleci/github-cli@2.0.0
win: circleci/windows@2.2.0
executors:
linux: &linux
machine:
image: ubuntu-2004:202010-01
macos: &macos
macos:
xcode: "12.5.1"
windows: &windows
machine:
image: 'windows-server-2019-vs2019:stable'
resource_class: windows.medium
shell: powershell.exe -ExecutionPolicy Bypass
workflows:
lint:
jobs:
- lint:
name: Lint
matrix:
parameters:
platform: [linux]
rust_channel: [stable]
wasm:
jobs:
- wasm:
name: Wasm compilation
matrix:
parameters:
platform: [linux]
rust_channel: [stable]
test:
jobs:
- test:
name: Test (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [linux, macos, windows]
rust_channel: [stable, nightly]
jobs:
lint:
parameters:
rust_channel:
type: enum
enum: ["stable", "nightly"]
default: stable
platform:
type: executor
executor: << parameters.platform >>
steps:
- checkout
- install_system_deps:
rust_channel: << parameters.rust_channel >>
platform: << parameters.platform >>
- run:
name: Run cargo clippy
command: cargo clippy --all-targets --all-features -- -D warnings && cargo clippy --benches
wasm:
parameters:
rust_channel:
type: enum
enum: ["stable"]
default: stable
platform:
type: executor
executor: << parameters.platform >>
steps:
- checkout
- install_system_deps:
rust_channel: << parameters.rust_channel >>
platform: << parameters.platform >>
- run:
name: Download wasm target
command: rustup target add wasm32-unknown-unknown
- run:
name: Run cargo build on wasm32-unknown-unknown
command: cargo build --target wasm32-unknown-unknown
test:
parameters:
rust_channel:
type: enum
enum: ["stable", "nightly"]
default: stable
platform:
type: executor
executor: << parameters.platform >>
steps:
- checkout
- install_system_deps:
rust_channel: << parameters.rust_channel >>
platform: << parameters.platform >>
- run:
name: Run cargo test
command: cargo test
commands:
install_system_deps:
parameters:
platform:
type: executor
rust_channel:
type: enum
enum: ["stable", "nightly"]
steps:
- when:
condition:
equal: [ *linux, << parameters.platform >> ]
steps:
- run:
name: Update apt repositories
command: sudo apt-get update
- run:
name: Check glibc version
command: ldd --version
- run:
name: Install OpenSSL
command: sudo apt-get install -y libssl-dev
- when:
condition:
equal: [ *macos, << parameters.platform >> ]
steps:
- run:
name: Skip homebrew update
command: echo "HOMEBREW_NO_AUTO_UPDATE=1" >> $BASH_ENV
- run:
name: Install OpenSSL@1.1
command: brew install openssl@1.1
- install_rust_toolchain:
rust_channel: << parameters.rust_channel >>
platform: << parameters.platform >>
install_rust_toolchain:
parameters:
rust_channel:
type: enum
enum: ["stable", "nightly"]
platform:
type: executor
steps:
- unless:
condition:
equal: [ *windows, << parameters.platform >> ]
steps:
- rust/install:
version: << parameters.rust_channel >>
- when:
condition:
equal: [ *windows, << parameters.platform >> ]
steps:
- run:
name: Install rustup
environment:
RUSTUP_UNPACK_RAM: "21474836480"
command: |
$installer_dir = "$Env:TEMP"
echo "Downloading rustup"
(New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe")
echo "Installing rustup"
& $installer_dir\rustup-init.exe --profile minimal -y
exit $LASTEXITCODE
- run:
name: Configure cargo for Windows
command: |
Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @"
[net]
git-fetch-with-cli = true
"@