-
Notifications
You must be signed in to change notification settings - Fork 4
316 lines (266 loc) · 9 KB
/
ci.yml
File metadata and controls
316 lines (266 loc) · 9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
exclude:
# Reduce CI load by excluding some combinations
- os: macos-latest
rust: beta
- os: windows-latest
rust: beta
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
shared-key: "ci-${{ matrix.os }}-${{ matrix.rust }}"
cache-all-crates: true
- name: Check formatting
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: cargo fmt -- --check
- name: Check for executor.execute_command antipattern
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: |
# Commands should use self.execute_command(args) not self.executor.execute_command("docker", args)
# The latter causes "docker docker <cmd>" double-command bug (issue #233)
if grep -rE 'executor\.execute_command\("docker"|execute_command\("docker",' src/command.rs src/command/; then
echo "ERROR: Found execute_command(\"docker\", ...) antipattern!"
echo "Use self.execute_command(args) instead to avoid 'docker docker' bug."
echo "For compose commands, pass 'compose' as command name, not 'docker'."
exit 1
fi
- name: Run Clippy
if: matrix.rust == 'stable'
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --all-features
- name: Build examples
run: cargo build --examples --all-features
- name: Check individual template features compile
shell: bash
run: |
for feature in template-redis template-redis-cluster template-redis-enterprise template-postgres template-mysql template-mongodb template-nginx; do
echo "Checking feature: $feature"
cargo check --features "$feature"
done
- name: Run tests
run: cargo test --lib --all-features && cargo test --doc --all-features
docker-tests:
name: Docker Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
shared-key: "ci-docker"
cache-all-crates: true
- name: Start Docker
run: |
sudo systemctl start docker
docker --version
- name: Pull test images in parallel
run: |
docker pull alpine:latest &
docker pull redis:7.2-alpine &
docker pull redis:7-alpine &
docker pull redis:6-alpine &
docker pull redis/redis-stack:latest &
docker pull nginx:alpine &
docker pull postgres:15-alpine &
docker pull mysql:8 &
docker pull mongo:latest &
wait
- name: Run integration tests
run: cargo test --test '*' --all-features
env:
DOCKER_HOST: unix:///var/run/docker.sock
- name: Build examples
run: cargo build --examples --all-features
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
shared-key: "ci-security"
cache-all-crates: true
- name: Cache cargo-audit
id: cache-cargo-audit
uses: actions/cache@v5
with:
path: ~/.cargo/bin/cargo-audit
key: cargo-audit-${{ runner.os }}
- name: Install cargo-audit if not cached
if: steps.cache-cargo-audit.outputs.cache-hit != 'true'
run: cargo install cargo-audit --locked
- name: Run security audit
run: cargo audit
# TODO: Re-enable and fix coverage job - currently has flaky integration tests
# coverage:
# name: Code Coverage
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v6
#
# - name: Install Rust
# uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
# with:
# toolchain: stable
#
# - name: Cache Rust dependencies
# uses: swatinem/rust-cache@v2
# with:
# shared-key: "ci-coverage"
# cache-all-crates: true
#
# - name: Cache cargo-tarpaulin
# id: cache-cargo-tarpaulin
# uses: actions/cache@v5
# with:
# path: ~/.cargo/bin/cargo-tarpaulin
# key: cargo-tarpaulin-${{ runner.os }}
#
# - name: Install cargo-tarpaulin if not cached
# if: steps.cache-cargo-tarpaulin.outputs.cache-hit != 'true'
# run: cargo install cargo-tarpaulin --locked
#
# - name: Start Docker
# run: |
# sudo systemctl start docker
# docker --version
#
# - name: Pull test images for coverage
# run: |
# docker pull alpine:latest &
# docker pull redis:7.2-alpine &
# docker pull redis:7-alpine &
# docker pull redis/redis-stack:latest &
# docker pull nginx:alpine &
# docker pull postgres:15-alpine &
# wait
#
# - name: Create redis-dev config directory
# run: mkdir -p ~/.config/redis-dev
#
# - name: Generate code coverage
# run: cargo tarpaulin --all-features --workspace --timeout 120 --out xml --skip-clean
#
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v5
# with:
# file: cobertura.xml
# fail_ci_if_error: false
msrv:
name: Minimum Supported Rust Version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust 1.89.0
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: 1.89.0
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
shared-key: "ci-msrv"
cache-all-crates: true
- name: Build with MSRV
run: cargo build --all-features
- name: Test with MSRV
run: cargo test --lib --all-features
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
shared-key: "ci-docs"
cache-all-crates: true
- name: Build documentation
run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: -D warnings
dependency-check:
name: Dependency Management
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
- name: Cache Rust dependencies and tools
uses: swatinem/rust-cache@v2
with:
shared-key: "ci-deps"
cache-all-crates: true
cache-directories: |
~/.cargo/bin/
- name: Cache cargo-machete
id: cache-cargo-machete
uses: actions/cache@v5
with:
path: ~/.cargo/bin/cargo-machete
key: cargo-machete-${{ runner.os }}
- name: Install cargo-machete if not cached
if: steps.cache-cargo-machete.outputs.cache-hit != 'true'
run: cargo install cargo-machete --locked
- name: Check for unused dependencies
run: cargo machete
continue-on-error: true
- name: Cache cargo-outdated
id: cache-cargo-outdated
uses: actions/cache@v5
with:
path: ~/.cargo/bin/cargo-outdated
key: cargo-outdated-${{ runner.os }}
- name: Install cargo-outdated if not cached
if: steps.cache-cargo-outdated.outputs.cache-hit != 'true'
run: cargo install cargo-outdated --locked
- name: Check for outdated dependencies
run: cargo outdated --exit-code 1 || true
continue-on-error: true