Skip to content

Commit d68dd2d

Browse files
authored
chore: redo CI (#88)
Using GPU workers is only needed for running the tests. Use other (way cheaper) machines for the other steps. This reduces the costs by about 7.5x (from around 1300 to 170 credits). Also the total runtime is about half now.
1 parent 6454672 commit d68dd2d

File tree

1 file changed

+27
-116
lines changed

1 file changed

+27
-116
lines changed

.circleci/config.yml

Lines changed: 27 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -2,137 +2,62 @@ version: 2.1
22

33
executors:
44
default:
5+
docker:
6+
- image: cimg/rust:1.70
7+
resource_class: small
8+
gpu:
59
machine:
610
image: linux-cuda-12:2023.05.1
7-
working_directory: ~/gpuci
8-
resource_class: gpu.nvidia.medium
11+
resource_class: gpu.nvidia.small
912

10-
restore-workspace: &restore-workspace
11-
attach_workspace:
12-
at: ~/
13-
14-
restore-cache: &restore-cache
15-
restore_cache:
16-
keys:
17-
- cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
18-
- repo-source-{{ .Branch }}-{{ .Revision }}
19-
20-
commands:
21-
set-env-path:
13+
jobs:
14+
test:
15+
executor: gpu
2216
steps:
17+
- checkout
2318
- run:
24-
name: Set the PATH env variable
19+
name: Install OpenCL
2520
command: |
26-
echo 'export PATH="$HOME:~/.cargo/bin:/usr/local/cuda-11.2/bin:$PATH"' | tee --append $BASH_ENV
27-
source $BASH_ENV
28-
29-
test_target:
30-
parameters:
31-
target:
32-
type: string
33-
steps:
34-
- *restore-workspace
35-
- *restore-cache
21+
sudo apt update
22+
sudo apt install ocl-icd-opencl-dev --no-install-recommends --yes
3623
- run:
37-
name: Test (<< parameters.target >>)
38-
command: TARGET=<< parameters.target >> cargo test
39-
no_output_timeout: 15m
40-
41-
jobs:
42-
43-
cargo_fetch:
44-
executor: default
45-
steps:
46-
- checkout
47-
- run: curl https://sh.rustup.rs -sSf | sh -s -- -y
48-
- set-env-path
49-
- run: echo $BASH_ENV
50-
- run: echo $HOME
51-
- run: cargo --version
52-
- run: rustc --version
24+
name: Install Rust
25+
command: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $(cat rust-toolchain) --profile minimal -y
5326
- run:
54-
name: Update submodules
55-
command: git submodule update --init --recursive
27+
name: Run tests
28+
command: cargo test
5629
- run:
57-
name: Calculate dependencies
58-
command: cargo generate-lockfile
59-
- restore_cache:
60-
keys:
61-
- cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
62-
- run: cargo update
63-
- run: cargo fetch
64-
- run: rustup install $(cat rust-toolchain)
65-
- run: rustup default $(cat rust-toolchain)
66-
- run: rustc --version
67-
- run: rm -rf .git
68-
- persist_to_workspace:
69-
root: ~/
70-
paths:
71-
- gpuci
72-
- save_cache:
73-
key: cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
74-
paths:
75-
- "~/.cargo"
76-
- "~/.rustup"
77-
78-
test_x86_64-unknown-linux-gnu:
79-
executor: default
80-
steps:
81-
- set-env-path
82-
- run: sudo apt-get update -y
83-
- run: apt-cache search opencl
84-
- run: sudo apt install -y ocl-icd-opencl-dev
85-
- test_target:
86-
target: "x86_64-unknown-linux-gnu"
30+
name: Run `add` example
31+
command: cargo run --example add
8732

8833
rustfmt:
8934
executor: default
9035
steps:
91-
- *restore-workspace
92-
- *restore-cache
93-
- set-env-path
94-
- run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV
95-
- run: source $BASH_ENV
36+
- checkout
9637
- run:
9738
name: Run cargo fmt
9839
command: cargo fmt --all -- --check
9940

10041
clippy:
10142
executor: default
10243
steps:
103-
- *restore-workspace
104-
- *restore-cache
105-
- set-env-path
44+
- checkout
10645
- run:
10746
name: Run cargo clippy
10847
command: cargo clippy --all-features --all-targets -- -D warnings
10948

11049
build:
11150
executor: default
11251
steps:
113-
- *restore-workspace
114-
- *restore-cache
115-
- set-env-path
52+
- checkout
11653
- run:
11754
name: Run cargo release build
11855
command: cargo build --release
11956

120-
example:
121-
executor: default
122-
steps:
123-
- *restore-workspace
124-
- *restore-cache
125-
- set-env-path
126-
- run:
127-
name: Run `add` example
128-
command: cargo run --example add
129-
13057
rustdoc:
13158
executor: default
13259
steps:
133-
- *restore-workspace
134-
- *restore-cache
135-
- set-env-path
60+
- checkout
13661
- run:
13762
name: Run rustdoc
13863
command: cargo rustdoc --all-features -- -D warnings
@@ -142,22 +67,8 @@ workflows:
14267

14368
test:
14469
jobs:
145-
- cargo_fetch
146-
- rustfmt:
147-
requires:
148-
- cargo_fetch
149-
- clippy:
150-
requires:
151-
- cargo_fetch
152-
- test_x86_64-unknown-linux-gnu:
153-
requires:
154-
- cargo_fetch
155-
- build:
156-
requires:
157-
- cargo_fetch
158-
- example:
159-
requires:
160-
- cargo_fetch
161-
- rustdoc:
162-
requires:
163-
- cargo_fetch
70+
- rustfmt
71+
- clippy
72+
- test
73+
- build
74+
- rustdoc

0 commit comments

Comments
 (0)