-
Notifications
You must be signed in to change notification settings - Fork 529
Expand file tree
/
Copy pathrun-chain-workflow.sh
More file actions
executable file
·90 lines (75 loc) · 2.35 KB
/
run-chain-workflow.sh
File metadata and controls
executable file
·90 lines (75 loc) · 2.35 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
#!/bin/bash
# Script to build and run the Chain Workflow example with verification
# Usage: ./run-chain-workflow.sh
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
cd "$SCRIPT_DIR"
# Function to display section header
function section() {
echo -e "\n${YELLOW}======== $1 ========${NC}"
}
# Build the project
section "Building Chain Workflow"
echo "Running mvn clean package..."
./mvnw clean package
# Run the application and capture output
section "Running Chain Workflow"
echo "Starting the application..."
OUTPUT_FILE=$(mktemp)
./mvnw spring-boot:run | tee "$OUTPUT_FILE"
# Verify the output
section "Verifying Output"
# Check if markdown table is present
if ! grep -q "| Metric | Value |" "$OUTPUT_FILE"; then
echo -e "${RED}ERROR: Markdown table header not found in output${NC}"
rm "$OUTPUT_FILE"
exit 1
fi
# Check for expected metrics in the output
EXPECTED_METRICS=(
"Customer Satisfaction"
"Employee Satisfaction"
"Product Adoption Rate"
"Revenue Growth"
"Operating Margin"
"Market Share"
"Customer Churn"
)
ERRORS=0
for metric in "${EXPECTED_METRICS[@]}"; do
if ! grep -q "| $metric |" "$OUTPUT_FILE"; then
echo -e "${RED}ERROR: Expected metric not found: $metric${NC}"
ERRORS=$((ERRORS+1))
fi
done
# Verify sorting (highest values should come first)
# This is a basic check - values should decrease as we go down the table
if grep -A1 "Customer Satisfaction" "$OUTPUT_FILE" | grep -q "Employee Satisfaction" && \
grep -A1 "Employee Satisfaction" "$OUTPUT_FILE" | grep -q "Product Adoption Rate"; then
echo -e "${GREEN}✓ Metrics appear to be correctly sorted by value${NC}"
else
echo -e "${RED}ERROR: Metrics don't appear to be correctly sorted${NC}"
ERRORS=$((ERRORS+1))
fi
# Check for completion status
if grep -q "BUILD SUCCESS" "$OUTPUT_FILE"; then
echo -e "${GREEN}✓ Application completed successfully${NC}"
else
echo -e "${RED}ERROR: Application did not complete successfully${NC}"
ERRORS=$((ERRORS+1))
fi
# Clean up
rm "$OUTPUT_FILE"
# Final result
if [ $ERRORS -eq 0 ]; then
echo -e "\n${GREEN}✓ Chain Workflow executed and verified successfully!${NC}"
exit 0
else
echo -e "\n${RED}× Chain Workflow verification failed with $ERRORS errors!${NC}"
exit 1
fi