Skip to content

Commit e4cbc46

Browse files
committed
OSS features
1 parent 418bbf1 commit e4cbc46

10 files changed

Lines changed: 1050 additions & 1 deletion

File tree

.claude/settings.local.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"Bash(cargo search:*)",
99
"Bash(cargo test:*)",
1010
"Bash(cat:*)",
11-
"Bash(tree:*)"
11+
"Bash(tree:*)",
12+
"Bash(find:*)",
13+
"Bash(docker build:*)",
14+
"Bash(docker run:*)",
15+
"Bash(sudo chown:*)",
16+
"Bash(sudo chmod:*)",
17+
"WebFetch(domain:github.com)"
1218
],
1319
"deny": [],
1420
"ask": []
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build & Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
env:
14+
REGISTRY: docker.io
15+
IMAGE_NAME: osotech/kafka-backup
16+
17+
jobs:
18+
build-and-push:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Log in to Docker Hub
31+
if: github.event_name != 'pull_request'
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ secrets.DOCKER_USERNAME }}
35+
password: ${{ secrets.DOCKER_PASSWORD }}
36+
37+
- name: Extract metadata
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=semver,pattern={{version}}
44+
type=semver,pattern={{major}}.{{minor}}
45+
type=ref,event=branch
46+
type=sha,prefix={{branch}}-
47+
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@v5
50+
with:
51+
context: .
52+
push: ${{ github.event_name != 'pull_request' }}
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
cache-from: type=gha
56+
cache-to: type=gha,mode=max

.github/workflows/test.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
paths:
7+
- 'crates/**'
8+
- 'Cargo.toml'
9+
- 'Cargo.lock'
10+
- '.github/workflows/test.yml'
11+
pull_request:
12+
branches: [main]
13+
paths:
14+
- 'crates/**'
15+
- 'Cargo.toml'
16+
- 'Cargo.lock'
17+
- '.github/workflows/test.yml'
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
23+
jobs:
24+
# Fast checks - runs first to fail fast on simple issues
25+
check:
26+
name: Check & Lint
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Install Rust toolchain
32+
uses: dtolnay/rust-toolchain@stable
33+
with:
34+
components: clippy, rustfmt
35+
36+
- name: Cache cargo registry
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.cargo/registry
41+
~/.cargo/git
42+
target
43+
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-cargo-check-
46+
47+
- name: Check formatting
48+
run: cargo fmt --all -- --check
49+
50+
- name: Run clippy
51+
run: cargo clippy --all-targets --all-features -- -D warnings
52+
53+
- name: Check compilation
54+
run: cargo check --all-targets
55+
56+
# Unit tests - fast, no external dependencies
57+
unit-tests:
58+
name: Unit Tests
59+
runs-on: ubuntu-latest
60+
needs: check
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Install Rust toolchain
65+
uses: dtolnay/rust-toolchain@stable
66+
67+
- name: Cache cargo registry
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
~/.cargo/registry
72+
~/.cargo/git
73+
target
74+
key: ${{ runner.os }}-cargo-unit-${{ hashFiles('**/Cargo.lock') }}
75+
restore-keys: |
76+
${{ runner.os }}-cargo-unit-
77+
78+
- name: Run unit tests (lib)
79+
run: cargo test --lib --all-features
80+
env:
81+
RUST_LOG: debug
82+
83+
- name: Run unit test suite
84+
run: cargo test --test unit --all-features
85+
env:
86+
RUST_LOG: debug
87+
88+
# Integration tests - require Docker
89+
integration-tests:
90+
name: Integration Tests
91+
runs-on: ubuntu-latest
92+
needs: unit-tests
93+
services:
94+
# Docker-in-Docker for testcontainers
95+
dind:
96+
image: docker:dind
97+
options: --privileged
98+
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Install Rust toolchain
103+
uses: dtolnay/rust-toolchain@stable
104+
105+
- name: Cache cargo registry
106+
uses: actions/cache@v4
107+
with:
108+
path: |
109+
~/.cargo/registry
110+
~/.cargo/git
111+
target
112+
key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
113+
restore-keys: |
114+
${{ runner.os }}-cargo-integration-
115+
116+
- name: Run integration tests
117+
run: cargo test --test integration --all-features -- --nocapture
118+
env:
119+
DOCKER_HOST: unix:///var/run/docker.sock
120+
RUST_LOG: debug
121+
TESTCONTAINERS: "true"
122+
123+
- name: Run integration test suite
124+
run: cargo test --test integration_tests --all-features -- --nocapture --include-ignored
125+
env:
126+
DOCKER_HOST: unix:///var/run/docker.sock
127+
RUST_LOG: debug
128+
TESTCONTAINERS: "true"
129+
timeout-minutes: 15
130+
131+
# Chaos tests - slower, may require special setup
132+
chaos-tests:
133+
name: Chaos Tests
134+
runs-on: ubuntu-latest
135+
needs: integration-tests
136+
# Only run on main branch or when explicitly requested
137+
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run-chaos-tests')
138+
139+
steps:
140+
- uses: actions/checkout@v4
141+
142+
- name: Install Rust toolchain
143+
uses: dtolnay/rust-toolchain@stable
144+
145+
- name: Cache cargo registry
146+
uses: actions/cache@v4
147+
with:
148+
path: |
149+
~/.cargo/registry
150+
~/.cargo/git
151+
target
152+
key: ${{ runner.os }}-cargo-chaos-${{ hashFiles('**/Cargo.lock') }}
153+
restore-keys: |
154+
${{ runner.os }}-cargo-chaos-
155+
156+
- name: Run chaos tests (non-ignored only)
157+
run: cargo test --test chaos_tests --all-features -- --nocapture
158+
env:
159+
DOCKER_HOST: unix:///var/run/docker.sock
160+
RUST_LOG: debug
161+
timeout-minutes: 20
162+
163+
# Coverage reporting
164+
coverage:
165+
name: Code Coverage
166+
runs-on: ubuntu-latest
167+
needs: unit-tests
168+
# Only run on main branch pushes
169+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
170+
171+
steps:
172+
- uses: actions/checkout@v4
173+
174+
- name: Install Rust toolchain
175+
uses: dtolnay/rust-toolchain@stable
176+
177+
- name: Install cargo-tarpaulin
178+
uses: taiki-e/install-action@cargo-tarpaulin
179+
180+
- name: Cache cargo registry
181+
uses: actions/cache@v4
182+
with:
183+
path: |
184+
~/.cargo/registry
185+
~/.cargo/git
186+
target
187+
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
188+
restore-keys: |
189+
${{ runner.os }}-cargo-coverage-
190+
191+
- name: Generate coverage report
192+
run: |
193+
cargo tarpaulin \
194+
--out Xml \
195+
--out Html \
196+
--timeout 300 \
197+
--ignore-panics \
198+
--ignore-tests \
199+
--workspace \
200+
--exclude-files "*/tests/*"
201+
continue-on-error: true
202+
203+
- name: Upload coverage to Codecov
204+
uses: codecov/codecov-action@v4
205+
with:
206+
files: ./cobertura.xml
207+
fail_ci_if_error: false
208+
verbose: true
209+
210+
- name: Upload coverage HTML report
211+
uses: actions/upload-artifact@v4
212+
with:
213+
name: coverage-report
214+
path: tarpaulin-report.html
215+
retention-days: 7
216+
217+
# Security audit
218+
security-audit:
219+
name: Security Audit
220+
runs-on: ubuntu-latest
221+
steps:
222+
- uses: actions/checkout@v4
223+
224+
- name: Install Rust toolchain
225+
uses: dtolnay/rust-toolchain@stable
226+
227+
- name: Install cargo-audit
228+
run: cargo install cargo-audit
229+
230+
- name: Run security audit
231+
run: cargo audit
232+
continue-on-error: true
233+
234+
# Summary job for branch protection
235+
tests-complete:
236+
name: Tests Complete
237+
runs-on: ubuntu-latest
238+
needs: [check, unit-tests, integration-tests]
239+
if: always()
240+
steps:
241+
- name: Check all tests passed
242+
run: |
243+
if [ "${{ needs.check.result }}" != "success" ] || \
244+
[ "${{ needs.unit-tests.result }}" != "success" ] || \
245+
[ "${{ needs.integration-tests.result }}" != "success" ]; then
246+
echo "One or more required jobs failed"
247+
exit 1
248+
fi
249+
echo "All required tests passed!"

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/kafka-backup-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tracing-subscriber.workspace = true
2727
anyhow.workspace = true
2828

2929
# Serialization (for config loading)
30+
serde.workspace = true
3031
serde_yaml.workspace = true
3132
serde_json.workspace = true
3233

crates/kafka-backup-cli/src/commands/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ pub mod describe;
33
pub mod list;
44
pub mod offset_mapping;
55
pub mod offset_reset;
6+
pub mod offset_reset_bulk;
7+
pub mod offset_rollback;
68
pub mod restore;
79
pub mod status;
810
pub mod three_phase;

0 commit comments

Comments
 (0)