@@ -2,75 +2,243 @@ name: CI
22
33on :
44 push :
5- branches : [ main ]
5+ branches : [main]
6+ paths-ignore :
7+ - " **.md"
8+ - " docs/**"
9+ - " .github/*.md"
10+ - " LICENSE*"
11+ - " .gitignore"
12+ - " .env.example"
613 pull_request :
7- branches : [ main ]
14+ branches : [main]
15+ paths-ignore :
16+ - " **.md"
17+ - " docs/**"
18+ - " .github/*.md"
19+ - " LICENSE*"
20+ - " .gitignore"
21+ - " .env.example"
822
923env :
1024 CARGO_TERM_COLOR : always
11- RUST_BACKTRACE : 1
25+ RUST_BACKTRACE : short
26+ CARGO_INCREMENTAL : 1
27+ RUSTFLAGS : " -C debuginfo=0"
28+ CARGO_NET_RETRY : 10
1229
1330# Cancel previous runs of the same workflow
1431concurrency :
1532 group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1633 cancel-in-progress : true
1734
1835jobs :
19- test :
20- name : Test
21- runs-on : ${{ matrix.os }}
22- strategy :
23- matrix :
24- os : [ubuntu-latest, macos-latest, windows-latest]
25- rust : [stable]
36+ # Quick checks run first and fail fast
37+ quick-checks :
38+ name : Quick Checks
39+ runs-on : ubuntu-latest
2640 steps :
27- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28-
41+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+
2943 - name : Install Rust
30- uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
44+ uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
3145 with :
32- toolchain : ${{ matrix.rust }}
46+ toolchain : stable
3347 components : rustfmt, clippy
34-
35- - name : Cache cargo
36- uses : Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
37-
48+
49+ - name : Cache cargo registry and build
50+ uses : actions/cache@v4
51+ with :
52+ path : |
53+ ~/.cargo/bin/
54+ ~/.cargo/registry/index/
55+ ~/.cargo/registry/cache/
56+ ~/.cargo/git/db/
57+ target/
58+ key : ${{ runner.os }}-cargo-quick-${{ hashFiles('**/Cargo.lock') }}
59+ restore-keys : |
60+ ${{ runner.os }}-cargo-quick-
61+ ${{ runner.os }}-cargo-
62+
3863 - name : Check formatting
3964 run : cargo fmt --all -- --check
40-
65+
4166 - name : Run clippy
4267 run : cargo clippy --all-targets --all-features -- -D warnings
43-
44- - name : Run tests
45- run : cargo test --workspace --all-features
46-
68+
69+ # Unit tests for each package in parallel
70+ test-unit :
71+ name : Unit Tests - ${{ matrix.package }}
72+ needs : quick-checks
73+ runs-on : ubuntu-latest
74+ strategy :
75+ fail-fast : true
76+ matrix :
77+ package : [redis-cloud, redis-enterprise, redisctl]
78+ steps :
79+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+
81+ - name : Install Rust
82+ uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
83+ with :
84+ toolchain : stable
85+
86+ - name : Cache cargo registry and build
87+ uses : actions/cache@v4
88+ with :
89+ path : |
90+ ~/.cargo/bin/
91+ ~/.cargo/registry/index/
92+ ~/.cargo/registry/cache/
93+ ~/.cargo/git/db/
94+ target/
95+ key : ${{ runner.os }}-cargo-test-${{ matrix.package }}-${{ hashFiles('**/Cargo.lock') }}
96+ restore-keys : |
97+ ${{ runner.os }}-cargo-test-${{ matrix.package }}-
98+ ${{ runner.os }}-cargo-test-
99+ ${{ runner.os }}-cargo-
100+
101+ - name : Run unit tests
102+ run : cargo test --package ${{ matrix.package }} --lib --all-features
103+
104+ # Integration tests
105+ test-integration :
106+ name : Integration Tests
107+ needs : quick-checks
108+ runs-on : ubuntu-latest
109+ steps :
110+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
111+
112+ - name : Install Rust
113+ uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
114+ with :
115+ toolchain : stable
116+
117+ - name : Cache cargo registry and build
118+ uses : actions/cache@v4
119+ with :
120+ path : |
121+ ~/.cargo/bin/
122+ ~/.cargo/registry/index/
123+ ~/.cargo/registry/cache/
124+ ~/.cargo/git/db/
125+ target/
126+ key : ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
127+ restore-keys : |
128+ ${{ runner.os }}-cargo-integration-
129+ ${{ runner.os }}-cargo-
130+
131+ - name : Run integration tests
132+ run : cargo test --workspace --test '*' --all-features
133+
134+ # Platform builds - only required for main branch and releases
135+ build-platforms :
136+ name : Build - ${{ matrix.os }}
137+ needs : [test-unit, test-integration]
138+ runs-on : ${{ matrix.os }}
139+ strategy :
140+ fail-fast : false
141+ matrix :
142+ include :
143+ - os : ubuntu-latest
144+ required : true
145+ - os : macos-latest
146+ required : false
147+ - os : windows-latest
148+ required : false
149+ continue-on-error : ${{ !matrix.required }}
150+ steps :
151+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
152+
153+ - name : Install Rust
154+ uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
155+ with :
156+ toolchain : stable
157+
158+ - name : Cache cargo registry and build
159+ uses : actions/cache@v4
160+ with :
161+ path : |
162+ ~/.cargo/bin/
163+ ~/.cargo/registry/index/
164+ ~/.cargo/registry/cache/
165+ ~/.cargo/git/db/
166+ target/
167+ key : ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
168+ restore-keys : |
169+ ${{ runner.os }}-cargo-build-
170+ ${{ runner.os }}-cargo-
171+
47172 - name : Build binary
48173 run : cargo build --release --bin redisctl
49174
175+ # Only run full tests on Linux (fastest platform)
176+ - name : Run all tests
177+ if : matrix.os == 'ubuntu-latest'
178+ run : cargo test --workspace --all-features
179+
180+ # Code coverage - only on main branch
50181 coverage :
51182 name : Code Coverage
183+ needs : [test-unit, test-integration]
184+ if : github.ref == 'refs/heads/main'
52185 runs-on : ubuntu-latest
53186 steps :
54- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
55-
187+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
188+
56189 - name : Install Rust
57- uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
190+ uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
58191 with :
59192 toolchain : stable
60-
61- - name : Cache cargo
62- uses : Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
63-
193+
194+ - name : Cache cargo registry and build
195+ uses : actions/cache@v4
196+ with :
197+ path : |
198+ ~/.cargo/bin/
199+ ~/.cargo/registry/index/
200+ ~/.cargo/registry/cache/
201+ ~/.cargo/git/db/
202+ target/
203+ key : ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
204+ restore-keys : |
205+ ${{ runner.os }}-cargo-coverage-
206+ ${{ runner.os }}-cargo-
207+
64208 - name : Install tarpaulin
65209 uses : taiki-e/install-action@v2
66210 with :
6721168-
212+
69213 - name : Generate coverage
70214 run : cargo tarpaulin --workspace --all-features --out xml --timeout 300
71-
215+
72216 - name : Upload coverage to Codecov
73- uses : codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.1
217+ uses : codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.1
74218 with :
75219 files : ./cobertura.xml
76- fail_ci_if_error : false
220+ fail_ci_if_error : false
221+
222+ # Final status check - ensures all required jobs passed
223+ ci-status :
224+ name : CI Status
225+ runs-on : ubuntu-latest
226+ needs : [quick-checks, test-unit, test-integration, build-platforms]
227+ if : always()
228+ steps :
229+ - name : Check CI status
230+ run : |
231+ if [[ "${{ needs.quick-checks.result }}" != "success" ]]; then
232+ echo "Quick checks failed"
233+ exit 1
234+ fi
235+ if [[ "${{ needs.test-unit.result }}" != "success" ]]; then
236+ echo "Unit tests failed"
237+ exit 1
238+ fi
239+ if [[ "${{ needs.test-integration.result }}" != "success" ]]; then
240+ echo "Integration tests failed"
241+ exit 1
242+ fi
243+ # Build platforms can have failures for non-Linux
244+ echo "CI passed!"
0 commit comments