|
1 |
| -version: 2 |
2 |
| -jobs: |
3 |
| - cargo_fetch: |
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +executors: |
| 4 | + rust-stable: |
4 | 5 | docker:
|
5 | 6 | - image: inputoutput/rust:stable
|
6 |
| - working_directory: /home/circleci/project |
| 7 | + working_directory: /home/circleci/build |
| 8 | + rust-beta: |
| 9 | + docker: |
| 10 | + - image: instrumentisto/rust:beta |
| 11 | + working_directory: /home/build |
| 12 | + |
| 13 | +jobs: |
| 14 | + cargo_fetch: |
| 15 | + executor: rust-stable |
7 | 16 | steps:
|
8 | 17 | - checkout
|
| 18 | + - run: git --version |
9 | 19 | - run: git submodule sync
|
10 |
| - - run: git submodule update --init |
| 20 | + - run: git submodule update --init --depth=1 |
| 21 | + - run: |
| 22 | + name: Get top commit hash of cargo registry index |
| 23 | + command: | |
| 24 | + git ls-remote --heads https://github.com/rust-lang/crates.io-index.git master | |
| 25 | + cut -f 1 | tee .circleci/crates.io-index.head |
| 26 | + - restore_cache: |
| 27 | + name: Restore cargo registry index from cache |
| 28 | + keys: |
| 29 | + - cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }} |
| 30 | + - cargo-index-v1- |
11 | 31 | - restore_cache:
|
| 32 | + name: Restore dependency crates from cache |
12 | 33 | keys:
|
13 |
| - - cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
14 |
| - - cargo-v3-{{ checksum "Cargo.toml" }} |
15 |
| - - cargo-v3- |
16 |
| - - run: cargo fetch |
| 34 | + - cargo-deps-v1-{{ checksum "Cargo.lock" }} |
| 35 | + - run: |
| 36 | + name: Fetch dependencies and update cargo registry index |
| 37 | + command: | |
| 38 | + cargo fetch --locked |
| 39 | + git -C /usr/local/cargo/registry/index/github.com-1ecc6299db9ec823 \ |
| 40 | + show-ref -s refs/remotes/origin/master | |
| 41 | + tee .circleci/crates.io-index.head |
17 | 42 | - save_cache:
|
18 |
| - key: cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
| 43 | + name: Save cargo registry index into cache |
| 44 | + key: cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }} |
19 | 45 | paths:
|
20 |
| - - /usr/local/cargo/registry |
21 |
| - - /usr/local/cargo/git |
| 46 | + - /usr/local/cargo/registry/index |
| 47 | + - save_cache: |
| 48 | + name: Save dependency crates into cache |
| 49 | + key: cargo-deps-v1-{{ checksum "Cargo.lock" }} |
| 50 | + paths: |
| 51 | + - /usr/local/cargo/registry/cache |
| 52 | + - persist_to_workspace: |
| 53 | + root: . |
| 54 | + paths: |
| 55 | + - .circleci/crates.io-index.head |
22 | 56 |
|
23 | 57 | cargo_audit:
|
24 |
| - docker: |
25 |
| - - image: inputoutput/rust:stable |
26 |
| - working_directory: /home/circleci/project |
| 58 | + executor: rust-stable |
27 | 59 | steps:
|
28 | 60 | - checkout
|
29 |
| - - run: git submodule sync |
30 |
| - - run: git submodule update --init |
| 61 | + - attach_workspace: |
| 62 | + at: . |
31 | 63 | - restore_cache:
|
| 64 | + name: Restore cargo registry index from cache |
32 | 65 | keys:
|
33 |
| - - cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
| 66 | + - cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }} |
| 67 | + - run: |
| 68 | + name: Get top commit hash of RustSec advisory database |
| 69 | + command: | |
| 70 | + git ls-remote --heads https://github.com/RustSec/advisory-db.git master | |
| 71 | + cut -f 1 | tee .circleci/advisory-db.head |
34 | 72 | - restore_cache:
|
| 73 | + name: Restore advisory database from cache |
35 | 74 | keys:
|
36 |
| - - cargo-advisory-db-v1 |
| 75 | + - cargo-advisory-db-v2-{{ checksum ".circleci/advisory-db.head" }} |
| 76 | + - cargo-advisory-db-v2- |
37 | 77 | - run:
|
38 | 78 | name: Print Cargo Audit Version
|
39 | 79 | command: cargo audit --version
|
40 | 80 | - run:
|
41 | 81 | name: Check Cargo Audit
|
42 |
| - command: cargo audit |
| 82 | + command: | |
| 83 | + cargo audit |
| 84 | + git -C /usr/local/cargo/advisory-db \ |
| 85 | + show-ref -s refs/remotes/origin/master \ |
| 86 | + > .circleci/advisory-db.head |
43 | 87 | - save_cache:
|
44 |
| - key: cargo-advisory-db-v1 |
| 88 | + name: Save advisory database into cache |
| 89 | + key: cargo-advisory-db-v2-{{ checksum ".circleci/advisory-db.head" }} |
45 | 90 | paths:
|
46 | 91 | - /usr/local/cargo/advisory-db
|
47 | 92 |
|
48 | 93 | rustfmt:
|
49 |
| - docker: |
50 |
| - - image: inputoutput/rust:stable |
51 |
| - working_directory: /home/circleci/project |
52 |
| - steps: |
53 |
| - - checkout |
54 |
| - - run: |
55 |
| - name: Print version information |
56 |
| - command: cargo fmt -- --version |
57 |
| - - run: |
58 |
| - name: Check rustfmt |
59 |
| - command: cargo fmt -- --check |
60 |
| - |
61 |
| - test_debug: |
62 |
| - docker: |
63 |
| - - image: inputoutput/rust:stable |
64 |
| - environment: |
65 |
| - CARGO_INCREMENTAL: 0 |
66 |
| - working_directory: /home/circleci/project |
| 94 | + executor: rust-stable |
67 | 95 | steps:
|
68 | 96 | - checkout
|
69 | 97 | - run: git submodule sync
|
70 |
| - - run: git submodule update --init |
| 98 | + - run: git submodule update --init --depth=1 |
| 99 | + - attach_workspace: |
| 100 | + at: . |
71 | 101 | - restore_cache:
|
| 102 | + name: Restore cargo registry index from cache |
72 | 103 | keys:
|
73 |
| - - cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
| 104 | + - cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }} |
74 | 105 | - run:
|
75 | 106 | name: Print version information
|
76 |
| - command: rustc --version; cargo --version |
77 |
| - - run: |
78 |
| - name: Build binaries |
79 |
| - command: cargo build -p jormungandr -p jcli --offline --verbose --frozen |
80 |
| - - run: |
81 |
| - name: Build tests |
82 |
| - command: cargo build --tests --offline --verbose --frozen |
| 107 | + command: cargo fmt -- --version |
83 | 108 | - run:
|
84 |
| - name: Test |
85 |
| - environment: |
86 |
| - RUST_BACKTRACE: 1 |
87 |
| - command: cargo test --offline --verbose --frozen --tests |
| 109 | + name: Check rustfmt |
| 110 | + command: cargo fmt --all -- --check |
88 | 111 |
|
89 |
| - test_doc: |
90 |
| - docker: |
91 |
| - - image: inputoutput/rust:stable |
| 112 | + test_debug: |
| 113 | + executor: rust-stable |
92 | 114 | environment:
|
93 | 115 | CARGO_INCREMENTAL: 0
|
94 |
| - working_directory: /home/circleci/project |
95 | 116 | steps:
|
96 |
| - - checkout |
97 |
| - - run: git submodule sync |
98 |
| - - run: git submodule update --init |
99 |
| - - restore_cache: |
100 |
| - keys: |
101 |
| - - cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
102 |
| - - run: |
103 |
| - name: Print version information |
104 |
| - command: rustc --version; cargo --version |
105 |
| - - run: |
106 |
| - name: Test |
107 |
| - environment: |
108 |
| - RUST_BACKTRACE: 1 |
109 |
| - command: cargo test --offline --verbose --frozen --doc -- --test-threads=1 |
| 117 | + - test |
110 | 118 |
|
111 | 119 | test_release:
|
112 |
| - docker: |
113 |
| - - image: inputoutput/rust:stable |
114 |
| - working_directory: /home/circleci/project |
| 120 | + executor: rust-stable |
115 | 121 | steps:
|
116 |
| - - checkout |
117 |
| - - run: git submodule sync |
118 |
| - - run: git submodule update --init |
119 |
| - - restore_cache: |
120 |
| - keys: |
121 |
| - - cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
122 |
| - - run: |
123 |
| - name: Print version information |
124 |
| - command: rustc --version; cargo --version |
125 |
| - - run: |
126 |
| - name: Build binaries |
127 |
| - command: cargo build -p jormungandr -p jcli --release --offline --verbose --frozen |
128 |
| - - run: |
129 |
| - name: Build tests |
130 |
| - command: cargo build --tests --release --offline --verbose --frozen |
131 |
| - - run: |
132 |
| - name: Test |
133 |
| - command: cargo test --release --offline --verbose --tests |
| 122 | + - test: |
| 123 | + mode: --release |
134 | 124 |
|
135 | 125 | test_beta:
|
136 |
| - docker: |
137 |
| - - image: instrumentisto/rust:beta |
| 126 | + executor: rust-beta |
138 | 127 | environment:
|
139 | 128 | CARGO_INCREMENTAL: 0
|
140 |
| - working_directory: /home/circleci/project |
| 129 | + steps: |
| 130 | + - test |
| 131 | + |
| 132 | +commands: |
| 133 | + test: |
| 134 | + description: "Steps for the test jobs" |
| 135 | + parameters: |
| 136 | + mode: |
| 137 | + type: string |
| 138 | + default: '' |
| 139 | + cargo_behavior: |
| 140 | + type: string |
| 141 | + default: --locked --offline --verbose |
141 | 142 | steps:
|
142 | 143 | - checkout
|
143 | 144 | - run: git submodule sync
|
144 |
| - - run: git submodule update --init |
| 145 | + - run: git submodule update --init --depth=1 |
| 146 | + - attach_workspace: |
| 147 | + at: . |
145 | 148 | - restore_cache:
|
| 149 | + name: Restore cargo registry index from cache |
146 | 150 | keys:
|
147 |
| - - cargo-v3-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }} |
| 151 | + - cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }} |
| 152 | + - restore_cache: |
| 153 | + name: Restore dependency crates from cache |
| 154 | + keys: |
| 155 | + - cargo-deps-v1-{{ checksum "Cargo.lock" }} |
148 | 156 | - run:
|
149 | 157 | name: Print version information
|
150 | 158 | command: rustc --version; cargo --version
|
| 159 | + # `cargo build --all-targets` runs out of memory |
| 160 | + - run: |
| 161 | + name: Build jormungandr |
| 162 | + command: | |
| 163 | + cargo build -p jormungandr --bin jormungandr << parameters.mode >> << parameters.cargo_behavior >> |
151 | 164 | - run:
|
152 |
| - name: Build binaries |
153 |
| - command: cargo build -p jormungandr -p jcli --offline --verbose --frozen |
| 165 | + name: Build jcli |
| 166 | + command: | |
| 167 | + cargo build -p jcli --bin jcli << parameters.mode >> << parameters.cargo_behavior >> |
154 | 168 | - run:
|
155 | 169 | name: Build tests
|
156 |
| - command: cargo build --tests --offline --verbose --frozen |
| 170 | + command: | |
| 171 | + cargo build --workspace --tests << parameters.mode >> << parameters.cargo_behavior >> |
| 172 | + - run: |
| 173 | + name: Run tests |
| 174 | + environment: |
| 175 | + RUST_BACKTRACE: 1 |
| 176 | + command: | |
| 177 | + cargo test --workspace --tests << parameters.mode >> << parameters.cargo_behavior >> |
157 | 178 | - run:
|
158 |
| - name: Test |
| 179 | + name: Run doc tests |
159 | 180 | environment:
|
160 | 181 | RUST_BACKTRACE: 1
|
161 |
| - command: cargo test --offline --verbose --tests |
| 182 | + CARGO_BUILD_JOBS: 1 |
| 183 | + command: | |
| 184 | + cargo test --workspace --doc << parameters.mode >> << parameters.cargo_behavior >> |
162 | 185 |
|
163 | 186 | workflows:
|
164 | 187 | version: 2
|
165 | 188 | test_all:
|
166 | 189 | jobs:
|
167 | 190 | - cargo_fetch
|
168 |
| - - rustfmt |
169 |
| - # Temporarily disabled, vulnerable dependencies are pending update |
170 |
| - #- cargo_audit: |
171 |
| - # requires: |
172 |
| - # - cargo_fetch |
173 |
| - - test_debug: |
| 191 | + - rustfmt: |
174 | 192 | requires:
|
175 |
| - - rustfmt |
176 | 193 | - cargo_fetch
|
177 |
| - - test_doc: |
| 194 | + - cargo_audit: |
| 195 | + requires: |
| 196 | + - cargo_fetch |
| 197 | + - test_debug: |
178 | 198 | requires:
|
179 |
| - - rustfmt |
180 | 199 | - cargo_fetch
|
181 | 200 | - test_release:
|
182 | 201 | requires:
|
183 |
| - - rustfmt |
184 | 202 | - cargo_fetch
|
185 | 203 | - test_beta:
|
186 | 204 | requires:
|
187 |
| - - rustfmt |
188 | 205 | - cargo_fetch
|
0 commit comments