-
Notifications
You must be signed in to change notification settings - Fork 355
105 lines (87 loc) · 3.29 KB
/
check_api_bindings.yml
File metadata and controls
105 lines (87 loc) · 3.29 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
name: Check API Bindings
on:
push:
jobs:
check-api-bindings:
name: Check API Schema Bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Install the project
run: uv sync --all-extras --dev
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: "app/web_ui/.nvmrc"
cache: "npm"
cache-dependency-path: app/web_ui/package-lock.json
- name: Install Node.js dependencies
run: npm ci
working-directory: app/web_ui
- name: Mock Studio Web UI
run: mkdir -p ./app/web_ui/build && echo "test" > ./app/web_ui/build/index.html
- name: Check API schema bindings
run: |
# Start dev server in background
uv run python -m app.desktop.dev_server &
DEV_SERVER_PID=$!
# Wait for server to be ready
echo "Waiting for dev server to start..."
for i in {1..30}; do
if curl -s -f http://localhost:8757/openapi.json > /dev/null 2>&1; then
echo "Dev server is ready"
break
fi
if [ $i -eq 30 ]; then
echo "Dev server failed to start within 30 seconds"
kill $DEV_SERVER_PID || true
exit 1
fi
sleep 1
done
# Change to the correct directory and run the schema check
cd app/web_ui/src/lib
./check_schema.sh
cd -
# Check agent policy annotations
ANNOTATIONS_DIR="libs/server/kiln_server/utils/agent_checks/annotations"
TEMP_DIR=$(mktemp -d)
echo "Checking for unannotated endpoints..."
uv run python -m kiln_server.utils.agent_checks.dump_annotations \
http://localhost:8757/openapi.json "$TEMP_DIR"
echo "Checking annotation files are up to date..."
DIFF_FAILED=false
for f in "$TEMP_DIR"/*.json; do
filename=$(basename "$f")
if [ ! -f "$ANNOTATIONS_DIR/$filename" ]; then
echo "Missing checked-in annotation: $filename"
DIFF_FAILED=true
elif ! diff -q "$f" "$ANNOTATIONS_DIR/$filename" > /dev/null 2>&1; then
echo "Annotation differs: $filename"
diff -u "$ANNOTATIONS_DIR/$filename" "$f" || true
DIFF_FAILED=true
fi
done
if [ "$DIFF_FAILED" = true ]; then
echo ""
echo -e "\033[31mAgent policy annotations are not up to date.\033[0m"
echo "Run the dump CLI to regenerate:"
echo " uv run python -m kiln_server.utils.agent_checks.dump_annotations http://localhost:8757/openapi.json $ANNOTATIONS_DIR"
rm -rf "$TEMP_DIR"
kill $DEV_SERVER_PID || true
exit 1
fi
echo "Agent policy annotations are up to date."
rm -rf "$TEMP_DIR"
# Stop dev server
kill $DEV_SERVER_PID || true
# Wait a moment for graceful shutdown
sleep 2
# Force kill if still running
kill -9 $DEV_SERVER_PID 2>/dev/null || true