-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
172 lines (149 loc) · 6.45 KB
/
Makefile
File metadata and controls
172 lines (149 loc) · 6.45 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
.PHONY: help build build-dev test test-unit test-security test-integration test-e2e test-all bench clean install install-nextest release check-version fmt clippy ci devcontainer-up devcontainer-exec devcontainer-down devcontainer-compose-up
# Default target
help:
@echo "Available commands:"
@echo " build - Build the project in release mode"
@echo " build-dev - Build the project in development mode"
@echo " test - Run all tests (using nextest)"
@echo " test-unit - Run unit tests only (using nextest)"
@echo " test-security - Run security tests only (using nextest)"
@echo " test-integration - Run integration tests (requires Docker)"
@echo " test-e2e - Run end-to-end tests (requires Docker and Linux)"
@echo " test-all - Run all tests including E2E (requires Docker and Linux)"
@echo " bench - Run performance benchmarks"
@echo " clean - Clean build artifacts"
@echo " install - Install the project"
@echo " install-nextest - Install cargo-nextest for faster test execution"
@echo " release - Create a tagged release (bumps version by 0.0.1)"
@echo " check-version - Check current version"
@echo " fmt - Format code"
@echo " clippy - Run clippy lints"
@echo " ci - Run full CI checks locally"
@echo " devcontainer-up - Start devcontainer (requires devcontainer CLI)"
@echo " devcontainer-exec - Execute command in running devcontainer"
@echo " devcontainer-down - Stop devcontainer"
@echo " devcontainer-compose-up - Start devcontainer with compose services (NFS/SMB servers)"
# Build the project in release mode
build:
cargo build --release
# Build the project in development mode
build-dev:
cargo build
# Run all tests
test: test-unit test-security
# Run unit tests only (using nextest for speed)
test-unit:
@command -v cargo-nextest >/dev/null 2>&1 || { echo "Installing cargo-nextest..."; cargo install cargo-nextest; }
cargo nextest run --all-features --no-fail-fast -E 'not (binary(cli_commands_test) or binary(complete_workflow_test) or binary(daemon_health_test) or binary(failure_recovery_test) or binary(systemd_service_test) or binary(multi_protocol_stress_test) or binary(real_world_mounting_test))'
cargo test --doc --all-features
# Run security tests only (using nextest for speed)
test-security:
@command -v cargo-nextest >/dev/null 2>&1 || { echo "Installing cargo-nextest..."; cargo install cargo-nextest; }
cargo nextest run -E 'test(security_)' --all-features --no-fail-fast
# Run integration tests (requires Docker services)
test-integration:
@echo "Starting Docker services..."
docker compose up -d nfs-server smb-server
@echo "Waiting for NFS server (up to 120 seconds)..."
@nfs_ready=0; \
for i in $$(seq 1 120); do \
if docker compose exec -T nfs-server showmount -e localhost 2>/dev/null; then \
echo "NFS server is ready after $$i seconds"; \
nfs_ready=1; \
break; \
fi; \
sleep 1; \
done; \
if [ "$$nfs_ready" != "1" ]; then \
echo "ERROR: NFS server failed to start within 120 seconds"; \
docker compose logs nfs-server; \
docker compose down -v; \
exit 1; \
fi
@echo "Waiting for SMB server (up to 120 seconds)..."
@smb_ready=0; \
for i in $$(seq 1 120); do \
if docker compose exec -T smb-server smbclient -L localhost -N 2>/dev/null; then \
echo "SMB server is ready after $$i seconds"; \
smb_ready=1; \
break; \
fi; \
sleep 1; \
done; \
if [ "$$smb_ready" != "1" ]; then \
echo "ERROR: SMB server failed to start within 120 seconds"; \
docker compose logs smb-server; \
docker compose down -v; \
exit 1; \
fi
@echo "Running integration tests..."
cargo test integration_tests --all-features
@echo "Cleaning up Docker services..."
docker compose down -v
# Run E2E tests (requires Docker and Linux)
test-e2e:
@echo "Starting Docker services for E2E tests..."
docker compose up -d nfs-server smb-server systemd-test
@echo "Waiting for services to be healthy..."
@echo "Running E2E tests..."
@command -v cargo-nextest >/dev/null 2>&1 || { echo "Installing cargo-nextest..."; cargo install cargo-nextest; }
cargo nextest run -E 'test(~integration_tests) and test(~security_) and kind(test) and binary(=~e2e)' --all-features --no-fail-fast || (docker compose down -v && exit 1)
@echo "Cleaning up Docker services..."
docker compose down -v
# Run all tests including E2E
test-all: test-unit test-security test-e2e
@echo "All tests passed!"
# Run performance benchmarks
bench:
@echo "Running performance benchmarks..."
cargo bench --bench mount_operations
# Clean build artifacts
clean:
cargo clean
# Install the project
install: build
cargo install --path .
# Install cargo-nextest for faster test execution
install-nextest:
@echo "Installing cargo-nextest..."
cargo install cargo-nextest --locked
@echo "cargo-nextest installed successfully!"
@echo "You can now use 'cargo nextest run' for faster test execution"
# Check current version
check-version:
@echo "Current version: v$$($(MAKE) -s get-version)"
# Get version from Cargo.toml
get-version:
@cargo metadata --no-deps --format-version 1 | grep -o '"version":"[^"]*"' | cut -d'"' -f4
# Format code
fmt:
cargo fmt --all
# Run clippy lints
clippy:
cargo clippy --all-targets --all-features -- -A warnings
# Run full CI checks locally
ci: fmt clippy test
@echo "All CI checks passed!"
# Create a tagged release using version from Cargo.toml
release: check-version build
@echo "Creating a new release..."
@version=$$(cargo metadata --no-deps --format-version 1 | grep -o '"version":"[^"]*"' | cut -d'"' -f4); \
echo "Release version: v$$version"; \
git tag -a "v$$version" -m "Release v$$version" && \
echo "Created tag v$$version" && \
echo "Pushing tag to origin..." && \
git push origin v$$version && \
echo "Release v$$version pushed successfully!"
# DevContainer commands (requires devcontainer CLI: https://github.com/devcontainers/cli)
devcontainer-up:
@echo "Starting devcontainer..."
@devcontainer up --workspace-folder . --config .devcontainer/devcontainer.json
devcontainer-exec:
@echo "Connecting to devcontainer..."
@devcontainer exec --workspace-folder . --config .devcontainer/devcontainer.json bash
devcontainer-down:
@echo "Stopping devcontainer..."
@devcontainer down --workspace-folder . --config .devcontainer/devcontainer.json
devcontainer-compose-up:
@echo "Starting devcontainer with compose services (NFS/SMB servers)..."
@devcontainer up --workspace-folder . --config .devcontainer/docker-compose.devcontainer.json