-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (175 loc) · 5.87 KB
/
ci.yml
File metadata and controls
203 lines (175 loc) · 5.87 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
name: CI
on:
push:
branches: [main]
paths-ignore:
- "**.md"
- "docs/**"
- ".github/*.md"
- "LICENSE*"
- ".gitignore"
- ".env.example"
pull_request:
branches: [main]
paths-ignore:
- "**.md"
- "docs/**"
- ".github/*.md"
- "LICENSE*"
- ".gitignore"
- ".env.example"
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: short
CARGO_INCREMENTAL: 1
RUSTFLAGS: "-C debuginfo=0"
CARGO_NET_RETRY: 10
# Cancel previous runs of the same workflow
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
# Quick checks run first and fail fast
quick-checks:
name: Quick Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "quick"
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Unit tests for each package in parallel
test-unit:
name: Unit Tests - ${{ matrix.package }}
needs: quick-checks
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
package: [redis-cloud, redis-enterprise, redisctl]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "test-${{ matrix.package }}"
- name: Run unit tests
run: cargo test --package ${{ matrix.package }} --lib --all-features
# Integration tests
test-integration:
name: Integration Tests
needs: quick-checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "integration"
- name: Run integration tests
run: cargo test --workspace --test '*' --all-features
# Platform builds - only required for main branch and releases
build-platforms:
name: Build - ${{ matrix.os }}
needs: [test-unit, test-integration]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
required: true
- os: macos-latest
required: false
- os: windows-latest
required: false
continue-on-error: ${{ !matrix.required }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "build"
- name: Build binary
run: cargo build --release --bin redisctl
# Only run full tests on Linux (fastest platform)
- name: Run all tests
if: matrix.os == 'ubuntu-latest'
run: cargo test --workspace --all-features
# Code coverage - only on main branch
coverage:
name: Code Coverage
needs: [test-unit, test-integration]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "coverage"
- name: Install tarpaulin
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin@0.31.2
- name: Generate coverage
run: cargo tarpaulin --workspace --all-features --out xml --timeout 300
- name: Upload coverage to Codecov
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.1
with:
files: ./cobertura.xml
fail_ci_if_error: false
# Final status check - ensures all required jobs passed
ci-status:
name: CI Status
runs-on: ubuntu-latest
needs: [quick-checks, test-unit, test-integration, build-platforms]
if: always()
steps:
- name: Check CI status
run: |
if [[ "${{ needs.quick-checks.result }}" != "success" ]]; then
echo "Quick checks failed"
exit 1
fi
if [[ "${{ needs.test-unit.result }}" != "success" ]]; then
echo "Unit tests failed"
exit 1
fi
if [[ "${{ needs.test-integration.result }}" != "success" ]]; then
echo "Integration tests failed"
exit 1
fi
# Build platforms can have failures for non-Linux
echo "CI passed!"