-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
151 lines (130 loc) · 2.96 KB
/
Copy pathtest.sh
File metadata and controls
151 lines (130 loc) · 2.96 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
#!/bin/bash
# IC Lib - Check Script
# Runs both linting and testing for all packages
set -e
echo "IC-Lib Check (Lint + Test)"
echo "=========================="
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
FAILED=0
# Parse arguments
COVERAGE=false
WATCH=false
LINT_ONLY=false
TEST_ONLY=false
while [[ "$#" -gt 0 ]]; do
case $1 in
--coverage) COVERAGE=true ;;
--watch) WATCH=true ;;
--lint-only) LINT_ONLY=true ;;
--test-only) TEST_ONLY=true ;;
*) echo "Unknown parameter: $1"; exit 1 ;;
esac
shift
done
# ==================
# LINT PHASE
# ==================
if [ "$TEST_ONLY" = false ]; then
echo "=== LINT PHASE ==="
echo ""
# Lint client
echo "Linting client (auto-fix)..."
cd client
if npm run lint:fix; then
echo -e "${GREEN}Client lint passed${NC}"
else
echo -e "${RED}Client lint failed${NC}"
FAILED=1
fi
cd ..
echo ""
# Lint server
echo "Linting server (auto-fix)..."
cd server
if npm run lint:fix; then
echo -e "${GREEN}Server lint passed${NC}"
else
echo -e "${RED}Server lint failed${NC}"
FAILED=1
fi
cd ..
echo ""
# Lint scripts
echo "Linting scripts (auto-fix)..."
cd scripts
if npm run lint:fix; then
echo -e "${GREEN}Scripts lint passed${NC}"
else
echo -e "${RED}Scripts lint failed${NC}"
FAILED=1
fi
cd ..
echo ""
fi
# ==================
# TEST PHASE
# ==================
if [ "$LINT_ONLY" = false ]; then
echo "=== TEST PHASE ==="
echo ""
# Test client
echo "Testing client..."
cd client
if [ "$WATCH" = true ]; then
npm test
elif [ "$COVERAGE" = true ]; then
if npm run test:coverage; then
echo -e "${GREEN}Client tests passed${NC}"
else
echo -e "${RED}Client tests failed${NC}"
FAILED=1
fi
else
if npm run test:run; then
echo -e "${GREEN}Client tests passed${NC}"
else
echo -e "${RED}Client tests failed${NC}"
FAILED=1
fi
fi
cd ..
echo ""
# Test server
echo "Testing server..."
cd server
if [ "$WATCH" = true ]; then
npm test
elif [ "$COVERAGE" = true ]; then
if npm run test:coverage; then
echo -e "${GREEN}Server tests passed${NC}"
else
echo -e "${RED}Server tests failed${NC}"
FAILED=1
fi
else
if npm run test:run; then
echo -e "${GREEN}Server tests passed${NC}"
else
echo -e "${RED}Server tests failed${NC}"
FAILED=1
fi
fi
cd ..
echo ""
fi
# ==================
# SUMMARY
# ==================
echo "=========================="
if [ $FAILED -eq 0 ]; then
echo -e "${GREEN}All checks passed${NC}"
exit 0
else
echo -e "${RED}Some checks failed${NC}"
exit 1
fi