Skip to content

Commit 20678cb

Browse files
Replace test-all-examples.sh with dynamic test-examples.sh
Replace hardcoded provider list (5 skills) with filesystem discovery that automatically finds all skills with examples/ directories (19 skills). Accepts optional positional args to test specific skills. - Discover skills via ls skills/*/examples/ instead of hardcoded array - Accept optional args: ./scripts/test-examples.sh stripe-webhooks - Add --help with dynamic list of available skills and frameworks - Update providers.yaml to use default skillName convention - Update CI workflow to remove hookdeck-event-gateway special case - Update TESTING.md scenario 4 for hookdeck-event-gateway-webhooks - Update AGENTS.md references to new script name Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 3a0404d commit 20678cb

3 files changed

Lines changed: 125 additions & 22 deletions

File tree

AGENTS.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ webhook-skills/
1515
├── TESTING.md # Testing documentation
1616
├── LICENSE
1717
├── scripts/
18-
│ ├── test-all-examples.sh # Run all example tests
18+
│ ├── test-examples.sh # Run example tests (all or specific skills)
1919
│ └── test-agent-scenario.sh # Run agent integration tests
2020
├── .github/
2121
│ └── workflows/
@@ -701,10 +701,14 @@ See [TESTING.md](TESTING.md) for comprehensive testing documentation.
701701

702702
**Run example tests:**
703703
```bash
704-
# All examples
705-
./scripts/test-all-examples.sh
704+
# All skills with examples
705+
./scripts/test-examples.sh
706706

707-
# Single example
707+
# Specific skill(s)
708+
./scripts/test-examples.sh stripe-webhooks
709+
./scripts/test-examples.sh stripe-webhooks github-webhooks
710+
711+
# Single example directly
708712
cd skills/{provider}-webhooks/examples/express && npm test
709713
```
710714

@@ -788,7 +792,7 @@ cd skills/{provider}-webhooks/examples/nextjs && npm test
788792
cd skills/{provider}-webhooks/examples/fastapi && pytest test_webhook.py -v
789793

790794
# Run all example tests
791-
./scripts/test-all-examples.sh
795+
./scripts/test-examples.sh
792796
```
793797

794798
Ensure test scripts exit properly (e.g. `"test": "vitest run"` not `"vitest"`).

TESTING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ npm test
3838
Use the test runner script to run all examples:
3939

4040
```bash
41-
./scripts/test-all-examples.sh
41+
# All skills with examples
42+
./scripts/test-examples.sh
43+
44+
# Specific skill(s)
45+
./scripts/test-examples.sh stripe-webhooks
46+
./scripts/test-examples.sh stripe-webhooks github-webhooks
4247
```
4348

4449
### CI Pipeline
Lines changed: 110 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/bash
22

3-
# Test All Webhook Skills Examples
4-
# This script runs tests for all example applications across providers and frameworks.
3+
# Test Webhook Skills Examples
4+
# Runs tests for example applications across skills and frameworks.
5+
#
6+
# Usage:
7+
# ./scripts/test-examples.sh # Test all skills that have examples
8+
# ./scripts/test-examples.sh stripe-webhooks # Test one specific skill
9+
# ./scripts/test-examples.sh stripe-webhooks github-webhooks # Test multiple skills
10+
#
11+
# Discovery: Finds skills by looking for skills/*/examples/ directories.
512

613
set -e
714

@@ -13,6 +20,7 @@ SKILLS_DIR="$ROOT_DIR/skills"
1320
RED='\033[0;31m'
1421
GREEN='\033[0;32m'
1522
YELLOW='\033[1;33m'
23+
BLUE='\033[0;34m'
1624
NC='\033[0m' # No Color
1725

1826
# Track results
@@ -21,16 +29,107 @@ FAILED=0
2129
SKIPPED=0
2230
FAILED_TESTS=()
2331

24-
# Providers to test
25-
PROVIDERS=("stripe-webhooks" "shopify-webhooks" "github-webhooks" "hookdeck-event-gateway-webhooks" "deepgram-webhooks")
26-
2732
# Frameworks to test
2833
FRAMEWORKS=("express" "nextjs" "fastapi")
2934

35+
usage() {
36+
echo "Usage: $0 [skill-name ...]"
37+
echo ""
38+
echo "Test webhook skill example applications."
39+
echo ""
40+
echo " No arguments Discover and test all skills that have examples/"
41+
echo " skill-name ... Test only the specified skill(s)"
42+
echo ""
43+
echo "Examples:"
44+
echo " $0 # Test all"
45+
echo " $0 stripe-webhooks # Test one"
46+
echo " $0 stripe-webhooks github-webhooks # Test multiple"
47+
echo ""
48+
echo "Options:"
49+
echo " -h, --help Show this help message"
50+
echo ""
51+
52+
# Show available skills with examples
53+
echo "Skills with examples:"
54+
for dir in "$SKILLS_DIR"/*/examples; do
55+
if [ -d "$dir" ]; then
56+
local skill_name
57+
skill_name=$(basename "$(dirname "$dir")")
58+
# List which frameworks are available
59+
local frameworks=()
60+
for fw in "${FRAMEWORKS[@]}"; do
61+
if [ -d "$dir/$fw" ]; then
62+
frameworks+=("$fw")
63+
fi
64+
done
65+
echo " $skill_name (${frameworks[*]})"
66+
fi
67+
done
68+
exit 0
69+
}
70+
71+
# Parse arguments
72+
REQUESTED_SKILLS=()
73+
while [[ $# -gt 0 ]]; do
74+
case $1 in
75+
-h|--help)
76+
usage
77+
;;
78+
-*)
79+
echo -e "${RED}Unknown option: $1${NC}"
80+
echo ""
81+
usage
82+
;;
83+
*)
84+
REQUESTED_SKILLS+=("$1")
85+
shift
86+
;;
87+
esac
88+
done
89+
90+
# Discover skills with examples
91+
discover_skills() {
92+
local skills=()
93+
for dir in "$SKILLS_DIR"/*/examples; do
94+
if [ -d "$dir" ]; then
95+
skills+=("$(basename "$(dirname "$dir")")")
96+
fi
97+
done
98+
# Sort alphabetically
99+
IFS=$'\n' skills=($(sort <<<"${skills[*]}")); unset IFS
100+
echo "${skills[@]}"
101+
}
102+
103+
# Determine which skills to test
104+
if [ ${#REQUESTED_SKILLS[@]} -gt 0 ]; then
105+
# Validate requested skills exist and have examples
106+
SKILLS=()
107+
for skill in "${REQUESTED_SKILLS[@]}"; do
108+
if [ ! -d "$SKILLS_DIR/$skill" ]; then
109+
echo -e "${RED}Error: Skill '$skill' not found in $SKILLS_DIR/${NC}"
110+
exit 1
111+
fi
112+
if [ ! -d "$SKILLS_DIR/$skill/examples" ]; then
113+
echo -e "${RED}Error: Skill '$skill' has no examples/ directory${NC}"
114+
exit 1
115+
fi
116+
SKILLS+=("$skill")
117+
done
118+
else
119+
# Discover all skills with examples
120+
read -ra SKILLS <<< "$(discover_skills)"
121+
fi
122+
123+
if [ ${#SKILLS[@]} -eq 0 ]; then
124+
echo -e "${YELLOW}No skills with examples found.${NC}"
125+
exit 0
126+
fi
127+
30128
echo "========================================"
31129
echo " Webhook Skills Example Tests"
32130
echo "========================================"
33131
echo ""
132+
echo -e "Skills to test: ${BLUE}${#SKILLS[@]}${NC} (${SKILLS[*]})"
34133

35134
# Function to run Node.js tests (Express/Next.js)
36135
run_node_tests() {
@@ -165,22 +264,17 @@ run_python_tests() {
165264
deactivate
166265
}
167266

168-
# Run tests for each provider
169-
for provider in "${PROVIDERS[@]}"; do
170-
provider_dir="$SKILLS_DIR/$provider"
171-
172-
if [ ! -d "$provider_dir" ]; then
173-
echo "Provider $provider not found, skipping..."
174-
continue
175-
fi
267+
# Run tests for each skill
268+
for skill in "${SKILLS[@]}"; do
269+
skill_dir="$SKILLS_DIR/$skill"
176270

177271
echo ""
178-
echo "Testing $provider"
272+
echo "Testing $skill"
179273
echo "----------------------------------------"
180274

181275
for framework in "${FRAMEWORKS[@]}"; do
182-
example_dir="$provider_dir/examples/$framework"
183-
test_name="$provider/$framework"
276+
example_dir="$skill_dir/examples/$framework"
277+
test_name="$skill/$framework"
184278

185279
if [ ! -d "$example_dir" ]; then
186280
echo -n " Testing $test_name... "

0 commit comments

Comments
 (0)