Skip to content

Commit 2d9edd8

Browse files
committed
ci(repo): add safe default and validation for integration suite turbo config
Two safeguards against drift between integration presets and turbo.json: 1. Safe default in compute step: if a suite has no dependsOn in turbo.json, it's forced to run (with a warning). Failure mode is "runs too much" not "silently never runs." 2. Validation in pre-checks: cross-references package.json test:integration:* scripts against turbo.json entries. Fails CI if any suite is missing dependsOn, catching the problem at PR time.
1 parent bcaf79d commit 2d9edd8

1 file changed

Lines changed: 50 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,39 @@ jobs:
9090
pnpm changeset status --since=origin/main;
9191
fi
9292
93+
- name: Validate integration suite turbo config
94+
run: |
95+
# Every test:integration:* script in package.json must have a
96+
# matching turbo.json task with dependsOn so that turbo --affected
97+
# can detect SDK package changes. Without dependsOn, the suite
98+
# would only react to integration/** file changes.
99+
# Scripts that aren't test suites (utilities, disabled, base runner)
100+
SKIP_SCRIPTS="test:integration:base test:integration:cleanup test:integration:deployment:nextjs test:integration:expo-web:disabled"
101+
MISSING=()
102+
SUITES=$(jq -r '.scripts | keys[] | select(startswith("test:integration:"))' package.json)
103+
for script in $SUITES; do
104+
if echo "$SKIP_SCRIPTS" | grep -qw "$script"; then
105+
continue
106+
fi
107+
TASK_KEY="//#${script}"
108+
DEPS=$(jq -r --arg k "$TASK_KEY" '(.tasks[$k].dependsOn // []) | length' turbo.json 2>/dev/null || echo "0")
109+
if [ "$DEPS" = "0" ]; then
110+
MISSING+=("$script")
111+
fi
112+
done
113+
if [ ${#MISSING[@]} -gt 0 ]; then
114+
echo "ERROR: The following integration suites are missing dependsOn in turbo.json:"
115+
for s in "${MISSING[@]}"; do
116+
echo " - $s"
117+
done
118+
echo ""
119+
echo "Add dependsOn with the framework SDK build task(s) the suite uses,"
120+
echo "e.g.: \"dependsOn\": [\"@clerk/clerk-js#build\", \"@clerk/nextjs#build\"]"
121+
echo "See existing entries in turbo.json for examples."
122+
exit 1
123+
fi
124+
echo "All integration suites have dependsOn configured"
125+
93126
build-packages:
94127
needs: [check-permissions]
95128
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
@@ -324,13 +357,25 @@ jobs:
324357
AFFECTED_JSON="{"
325358
FIRST=true
326359
for name in "${TEST_NAMES[@]}"; do
327-
TASK_COUNT=$(pnpm turbo run "test:integration:${name}" --affected --dry=json 2>/dev/null | jq '.tasks | length' 2>/dev/null || echo "0")
360+
TASK_KEY="//#test:integration:${name}"
361+
HAS_DEPS=$(jq -r --arg k "$TASK_KEY" '(.tasks[$k].dependsOn // []) | length' turbo.json 2>/dev/null || echo "0")
362+
363+
if [ "$HAS_DEPS" = "0" ]; then
364+
# Safe default: suites without dependsOn always run.
365+
# This prevents silent skipping when someone adds a suite
366+
# but forgets to add dependsOn in turbo.json.
367+
IS_AFFECTED=true
368+
echo " WARNING: $name has no dependsOn in turbo.json, forcing affected"
369+
else
370+
TASK_COUNT=$(pnpm turbo run "test:integration:${name}" --affected --dry=json 2>/dev/null | jq '.tasks | length' 2>/dev/null || echo "0")
371+
[ "$TASK_COUNT" -gt 0 ] && IS_AFFECTED=true || IS_AFFECTED=false
372+
fi
373+
328374
$FIRST || AFFECTED_JSON+=","
329-
if [ "$TASK_COUNT" -gt 0 ]; then
330-
AFFECTED_JSON+="\"${name}\":true"
375+
AFFECTED_JSON+="\"${name}\":${IS_AFFECTED}"
376+
if [ "$IS_AFFECTED" = "true" ] && [ "$HAS_DEPS" != "0" ]; then
331377
echo " affected: $name"
332-
else
333-
AFFECTED_JSON+="\"${name}\":false"
378+
elif [ "$IS_AFFECTED" != "true" ]; then
334379
echo " skipped: $name"
335380
fi
336381
FIRST=false

0 commit comments

Comments
 (0)