-
Notifications
You must be signed in to change notification settings - Fork 18
135 lines (114 loc) · 4.79 KB
/
validate-plugin-tests.yml
File metadata and controls
135 lines (114 loc) · 4.79 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
name: Validate Plugin Tests
on:
push:
branches:
- "**" # Run on push to any branch
paths:
- "packages/plugin-*/**"
pull_request:
paths:
- "packages/plugin-*/**"
jobs:
validate-plugin-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build packages (required for tests)
run: |
echo "Building packages before running tests..."
npm run build
- name: Check Plugin Tests
run: |
echo "Validating plugin tests..."
echo "Required: Core Functionality + Error Handling test categories"
echo "Note: Plugin Configuration tests are validated automatically by test execution"
# Find all plugin directories at the top level only
plugins=$(find packages -maxdepth 1 -name "plugin-*" -type d)
if [ -z "$plugins" ]; then
echo "No plugins found, nothing to check"
exit 0
fi
failed=false
for plugin in $plugins; do
name=$(basename "$plugin")
echo ""
echo "Checking $name..."
cd "$plugin"
# Run the tests (with 60 second timeout)
echo "Running tests..."
test_output=$(timeout 60s npm test 2>&1 || echo "TESTS_FAILED")
if [[ "$test_output" != *"TESTS_FAILED"* ]]; then
echo "✅ All tests passed (including Plugin Configuration)"
else
echo "❌ Tests failed or took too long"
# Check for common failure reasons
if [[ "$test_output" == *"TODO: Replace placeholder"* ]]; then
echo " → Reason: Placeholder tests detected (need customization)"
elif [[ "$test_output" == *"timeout"* ]]; then
echo " → Reason: Tests took longer than 60 seconds"
elif [[ "$test_output" == *"npm ERR!"* ]]; then
echo " → Reason: npm/dependency error"
else
echo " → Reason: Unknown test failure"
fi
failed=true
fi
# Check for the 2 required test categories
test_file=$(find tests -name "*.spec.ts" | head -1)
if [ -f "$test_file" ]; then
echo "Checking required test categories..."
# 1. Core Functionality tests (required)
if grep -E "(Core Functionality|Tool Registration|Tool Functionality|API Endpoint|Login Endpoint|OpenAPI Endpoint|Resource Handler|Registration|Functionality)" "$test_file" > /dev/null; then
echo "✅ Core Functionality tests found"
else
echo "❌ Missing Core Functionality tests (required category 1/2)"
failed=true
fi
# 2. Error Handling tests (required)
if grep -E "(Error Handling|Error Cases|Invalid Parameters|Validation Errors|Exception Handling)" "$test_file" > /dev/null; then
echo "✅ Error Handling tests found"
else
echo "❌ Missing Error Handling tests (required category 2/2)"
failed=true
fi
else
echo "❌ No test files found"
failed=true
fi
cd - > /dev/null
done
echo ""
echo "=== VALIDATION SUMMARY ==="
if [ "$failed" = true ]; then
echo "❌ Plugin validation failed!"
echo ""
# Check what types of failures occurred and provide specific guidance
if echo "$test_output" | grep -q "TODO: Replace placeholder"; then
echo "ISSUE: Placeholder tests found"
echo " You need to replace the auto-generated placeholder tests with real ones."
echo " Look for 'TODO: Replace placeholder test' messages in your test files."
echo ""
echo "SOLUTION:"
echo " 1. Open your tests/[plugin-name].spec.ts file"
echo " 2. Replace placeholder tests in 'Core Functionality' section"
echo " 3. Replace placeholder tests in 'Error Handling' section"
echo " 4. See packages/plugin-example/tests/ for examples"
echo ""
fi
echo ""
echo "Read packages/PLUGIN_TESTING_GUIDE.md for detailed instructions"
exit 1
else
echo "✅All plugins passed validation!"
echo "✅ Core Functionality tests found"
echo "✅ Error Handling tests found"
echo "✅ All tests passing"
fi