Skip to content

Commit 4e805a9

Browse files
committed
ci: Migrate Rust to cimg/rust, cache cargo
1 parent 54daf26 commit 4e805a9

1 file changed

Lines changed: 50 additions & 33 deletions

File tree

circle.yml

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ executors:
1515
macos:
1616
macos:
1717
xcode: 11.6.0
18+
rust:
19+
docker:
20+
- image: cimg/rust:1.49
1821

1922
commands:
2023
install_macos_deps:
@@ -35,7 +38,7 @@ commands:
3538
else
3639
[[ $OSTYPE = darwin* ]] && os=macos || os=ubuntu
3740
cd /usr/local
38-
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.20/wabt-1.0.20-$os.tar.gz | (sudo tar xz --strip 1 || tar xz --strip 1)
41+
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.20/wabt-1.0.20-$os.tar.gz | sudo tar xz --strip 1
3942
fi
4043
4144
install_testfloat:
@@ -265,6 +268,39 @@ commands:
265268
echo $result
266269
if [ "$expected" != "$result" ]; then exit 1; fi
267270
271+
rust_restore_cargo_cache:
272+
steps:
273+
- restore_cache:
274+
name: "Restore cargo cache"
275+
key: cargo-
276+
277+
rust_save_cargo_cache:
278+
steps:
279+
- save_cache:
280+
name: "Save cargo cache"
281+
key: cargo-{{checksum "Cargo.lock"}}
282+
paths:
283+
- ~/.cargo
284+
285+
rust_install_system_dependencies:
286+
steps:
287+
- run:
288+
name: "Install system build dependencies"
289+
command: |
290+
sudo apt-get -q update
291+
sudo apt-get -qy install cmake --no-install-recommends
292+
sudo apt-get -qy install llvm-10-dev clang-10 --no-install-recommends
293+
294+
rust_install_nightly:
295+
steps:
296+
- run:
297+
name: "Install nightly toolchain"
298+
command: |
299+
rustup toolchain install nightly-x86_64-unknown-linux-gnu
300+
rustup component add llvm-tools-preview
301+
cargo install cargo-binutils rustfilt
302+
303+
268304
jobs:
269305

270306
lint:
@@ -585,18 +621,11 @@ jobs:
585621
objects: fizzy-spectests
586622

587623
bindings-rust:
588-
docker:
589-
- image: rust:1-buster
624+
executor: rust
590625
steps:
626+
- rust_restore_cargo_cache
627+
- rust_install_system_dependencies
591628
- checkout
592-
- run:
593-
name: Update environment
594-
command: |
595-
echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list
596-
apt -qq update
597-
apt -yq -t buster-backports install cmake --no-install-recommends
598-
apt -yq install libclang-dev clang cmake --no-install-recommends
599-
rustup component add rustfmt
600629
- run:
601630
name: Check formatting
602631
command: |
@@ -623,20 +652,15 @@ jobs:
623652
# The package must be run within the actual crate and not in the workspace.
624653
working_directory: bindings/rust
625654
command: cargo package
655+
- rust_save_cargo_cache
626656

627657
bindings-rust-asan:
628-
docker:
629-
- image: rust:1-buster
658+
executor: rust
630659
steps:
660+
- rust_restore_cargo_cache
661+
- rust_install_system_dependencies
662+
- rust_install_nightly
631663
- checkout
632-
- run:
633-
name: Update environment
634-
command: |
635-
echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list
636-
apt -qq update
637-
apt -yq -t buster-backports install cmake --no-install-recommends
638-
apt -yq install llvm-8-dev clang-8 --no-install-recommends
639-
rustup toolchain install nightly-x86_64-unknown-linux-gnu
640664
- run:
641665
name: Build (debug mode)
642666
command: RUSTFLAGS="-Z sanitizer=address" cargo +nightly build --target x86_64-unknown-linux-gnu
@@ -645,26 +669,19 @@ jobs:
645669
command: RUSTFLAGS="-Z sanitizer=address -C opt-level=0" cargo +nightly test --target x86_64-unknown-linux-gnu
646670

647671
bindings-rust-coverage:
648-
docker:
649-
- image: rust:1-buster
672+
executor: rust
650673
steps:
674+
- rust_restore_cargo_cache
675+
- rust_install_system_dependencies
676+
- rust_install_nightly
651677
- checkout
652-
- run:
653-
name: Update environment
654-
command: |
655-
echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list
656-
apt -qq update
657-
apt -yq -t buster-backports install cmake --no-install-recommends
658-
apt -yq install llvm-8-dev clang-8 --no-install-recommends
659-
rustup toolchain install nightly-x86_64-unknown-linux-gnu
660-
rustup component add llvm-tools-preview
661-
cargo install cargo-binutils rustfilt
662678
- run:
663679
name: Build (debug mode)
664680
command: RUSTFLAGS="-Z instrument-coverage" cargo +nightly build --target x86_64-unknown-linux-gnu
665681
- run:
666682
name: Test (debug mode)
667683
command: RUSTFLAGS="-Z instrument-coverage -C opt-level=0" LLVM_PROFILE_FILE="fizzy-%m.profraw" cargo +nightly test --target x86_64-unknown-linux-gnu
684+
- rust_save_cargo_cache
668685
- run:
669686
name: Collect coverage data (Rust)
670687
command: |

0 commit comments

Comments
 (0)