-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-all
More file actions
executable file
·128 lines (113 loc) · 3.4 KB
/
Copy pathcheck-all
File metadata and controls
executable file
·128 lines (113 loc) · 3.4 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
#!/usr/bin/env bash
# check-all: Run all quality checks for the id project.
#
# This script runs formatting, linting, tests, and documentation checks
# in sequence, stopping on the first failure.
#
# Usage:
# ./check-all # Run all checks
# ./check-all --fix # Run checks and auto-fix what's possible
# ./check-all --quick # Skip slow checks (integration tests, docs)
#
# Exit codes:
# 0 - All checks passed
# 1 - One or more checks failed
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Parse arguments
FIX=false
QUICK=false
COVERAGE=false
for arg in "$@"; do
case $arg in
--fix)
FIX=true
;;
--quick)
QUICK=true
;;
--coverage)
COVERAGE=true
;;
--help|-h)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --fix Auto-fix formatting and clippy issues"
echo " --quick Skip slow checks (integration tests, docs)"
echo " --coverage Generate code coverage report"
echo " --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $arg"
exit 1
;;
esac
done
# Track failures
FAILED=()
# Helper function to run a check
run_check() {
local name="$1"
shift
echo -e "${BLUE}━━━ $name ━━━${NC}"
if "$@"; then
echo -e "${GREEN}✓ $name passed${NC}\n"
else
echo -e "${RED}✗ $name failed${NC}\n"
FAILED+=("$name")
return 1
fi
}
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ id - Running Quality Checks ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
# 1. Format check
if $FIX; then
run_check "Formatting (fix)" cargo fmt || true
else
run_check "Formatting" cargo fmt -- --check || true
fi
# 2. Clippy linting
if $FIX; then
run_check "Clippy (fix)" cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged || true
else
run_check "Clippy" cargo clippy --all-targets --all-features -- -D warnings || true
fi
# 3. Unit tests
run_check "Unit Tests" cargo test --lib || true
# 4. Integration tests (skip in quick mode)
if ! $QUICK; then
run_check "Integration Tests" cargo test --test cli_integration || true
fi
# 5. Doc tests
if ! $QUICK; then
run_check "Doc Tests" cargo test --doc || true
fi
# 6. Documentation build (skip in quick mode)
if ! $QUICK; then
run_check "Documentation" cargo doc --no-deps --document-private-items || true
fi
# 7. Coverage report (optional)
if $COVERAGE; then
run_check "Coverage Report" cargo llvm-cov --html || true
fi
# Summary
echo -e "${BLUE}━━━ Summary ━━━${NC}"
if [ ${#FAILED[@]} -eq 0 ]; then
echo -e "${GREEN}✓ All checks passed!${NC}"
exit 0
else
echo -e "${RED}✗ Failed checks:${NC}"
for check in "${FAILED[@]}"; do
echo -e "${RED} - $check${NC}"
done
exit 1
fi