|
90 | 90 | pnpm changeset status --since=origin/main; |
91 | 91 | fi |
92 | 92 |
|
| 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 | +
|
93 | 126 | build-packages: |
94 | 127 | needs: [check-permissions] |
95 | 128 | if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} |
@@ -324,13 +357,25 @@ jobs: |
324 | 357 | AFFECTED_JSON="{" |
325 | 358 | FIRST=true |
326 | 359 | 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 | +
|
328 | 374 | $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 |
331 | 377 | echo " affected: $name" |
332 | | - else |
333 | | - AFFECTED_JSON+="\"${name}\":false" |
| 378 | + elif [ "$IS_AFFECTED" != "true" ]; then |
334 | 379 | echo " skipped: $name" |
335 | 380 | fi |
336 | 381 | FIRST=false |
|
0 commit comments