Skip to content

fix(ci): replace broken --affected check with task validation for integration tests#8078

Open
jacekradko wants to merge 7 commits intomainfrom
jacek/fix-integration-ci-affected
Open

fix(ci): replace broken --affected check with task validation for integration tests#8078
jacekradko wants to merge 7 commits intomainfrom
jacek/fix-integration-ci-affected

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Mar 13, 2026

Summary

Replaces the broken --affected check in the integration tests CI job with explicit task validation that fails loudly on misconfiguration.

Problem

The previous check used turbo run --affected --dry=json to decide whether to run each integration test. Investigation revealed this was a no-op:

  • Root-level turbo tasks (//#) bypass --affected filtering entirely. Even with zero diff from main, turbo ls --affected reports 0 packages but turbo run test:integration:X --affected --dry still returns the root task. All integration tests are root tasks.
  • The only scenario where affected=0 occurred was when a turbo task was missing from turbo.json. This is a configuration error that should fail loudly, not silently skip the test.
  • Error suppression hid real failures. 2>/dev/null swallowed turbo errors, jq returned empty string (not "0") on empty input, and the || echo "0" fallback never fired because jq exited 0.

This is how the cache-components test was silently skipped for weeks — its turbo task was defined on an unmerged branch, and the CI check silently treated the missing task as "not affected."

Fix

Replace the --affected check with explicit task validation:

  • Runs turbo run <task> --dry=json without --affected (since it's meaningless for root tasks)
  • Fails with ::error:: annotation if the turbo command fails (missing task, bad config)
  • Fails with ::error:: annotation if jq returns 0 tasks
  • Logs the task name and graph size on success

Verification

Tested locally:

# Existing task → passes
pnpm turbo run test:integration:express --dry=json → tasks.length = 1 ✓

# Missing task → turbo exits non-zero with clear error
pnpm turbo run test:integration:nonexistent --dry=json 2>&1
→ "Could not find task `test:integration:nonexistent`"

Related

Summary by CodeRabbit

  • Chores

    • CI now explicitly validates configured tasks, failing fast with clear error messages on misconfiguration or invalid output.
    • Validation logs include task-count details to improve transparency.
    • Downstream pipeline steps now proceed based on validation results rather than a prior gate.
  • New Features

    • Added two new integration test tasks to the test configuration.
  • Chores

    • Added a placeholder changeset entry.

Turbo's --affected flag is a no-op for root-level tasks (//#) — they
are always returned as affected regardless of what files changed. The
previous check only 'worked' by silently swallowing errors when a task
was missing from turbo.json (2>/dev/null + jq returning empty string).

Replace with explicit task validation that fails loudly if the turbo
task doesn't exist or returns 0 tasks.
@vercel
Copy link

vercel bot commented Mar 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 13, 2026 10:07pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: bd651bf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8078

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8078

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8078

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8078

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8078

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8078

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8078

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8078

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8078

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8078

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8078

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8078

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8078

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8078

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8078

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8078

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8078

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8078

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8078

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8078

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8078

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8078

commit: bd651bf

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0bb9ede6-4118-47f5-a939-68010f8497fa

📥 Commits

Reviewing files that changed from the base of the PR and between 4109bbd and bd651bf.

📒 Files selected for processing (3)
  • .changeset/fix-integration-ci-affected.md
  • .github/workflows/ci.yml
  • turbo.json

📝 Walkthrough

Walkthrough

The CI workflow .github/workflows/ci.yml replaces the previous task-status/--affected gating with a "Validate turbo task" step that runs the Turbo task with --dry=json, captures STDERR, verifies valid JSON and presence of a .tasks array, and emits errors on failure. On success it logs the validated task count and allows downstream steps to proceed unconditionally. Additionally, two integration test tasks were added to turbo.json and a placeholder changeset was added.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds missing task definitions (cache-components, fastify) and removes the flawed --affected gating, addressing the core problem in #8073. However, dependsOn configuration for package dependencies is not implemented as specified in the linked issue. Add dependsOn fields to integration test turbo tasks mapping each test to its relevant @clerk/* package build tasks as specified in issue #8073 mapping table.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing a broken --affected check with explicit task validation for integration tests, which is the primary objective of this PR.
Out of Scope Changes check ✅ Passed All changes directly address the CI/task validation problems identified in the PR objectives. The new task definitions and validation changes are in scope for fixing the integration test execution issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 375-383: Replace the current assignment + manual exit check with
an if-not capture that keeps stderr out of the JSON stream: run pnpm turbo via
"if ! TURBO_OUTPUT=$(pnpm turbo run \"$TASK_NAME\" --dry=json 2>turbo_err); then
echo \"::error::Turbo task '$TASK_NAME' failed validation\"; cat turbo_err; exit
1; fi" so stdout (TURBO_OUTPUT) remains pure JSON for the subsequent
TASK_COUNT=$(echo "$TURBO_OUTPUT" | jq '.tasks | length') check and stderr is
preserved in turbo_err for logging; reference variables/commands TURBO_OUTPUT,
TASK_NAME, TASK_COUNT, pnpm turbo run and jq when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: bcd6b03b-2a6e-49ca-bc9c-10ca10096e6a

📥 Commits

Reviewing files that changed from the base of the PR and between 154eec9 and 475e98e.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 370-389: The jq invocation that computes TASK_COUNT (currently:
TASK_COUNT=$(echo "$TURBO_JSON" | jq '.tasks | length')) can mis-handle
missing/null tasks or invalid JSON; change the check to use jq -er -r to force
errors on null/false and emit raw integers, e.g., run jq -er -r '.tasks |
length' against TURBO_JSON (and check jq's exit status) so failures from invalid
JSON or missing .tasks produce a clear error (log TURBO_STDERR/TURBO_JSON
contents and exit non-zero), and only when jq succeeds parse TASK_COUNT as an
integer for the zero-task check; keep references to TASK_NAME, TURBO_STDERR,
TURBO_JSON and TASK_COUNT when adding the error messages.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 23f1e9c4-1d88-43e7-b5a0-9cf534a612fd

📥 Commits

Reviewing files that changed from the base of the PR and between 475e98e and accd6b0.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 388-394: The workflow currently sets "affected=1" unconditionally
after verifying TASK_COUNT, which only proves the task exists; change the logic
in the task-status step to set GITHUB_OUTPUT affected=1 only when the task is
actually affected by the PR (not just present in the graph). Concretely, use the
variable or check that indicates whether the task is in the affected set (e.g.,
the Turbo/affected output or a computed AFFECTED_TASKS list) instead of
TASK_COUNT/TASK_NAME alone, and write "affected=1" only when that check is true,
otherwise write "affected=0" so downstream if:
steps.task-status.outputs.affected == '1' filters correctly. Ensure you update
the code that currently writes echo "affected=1" >> $GITHUB_OUTPUT to be
conditional on the actual affected-check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 943615a6-3a83-48fa-aa50-2580017c132b

📥 Commits

Reviewing files that changed from the base of the PR and between accd6b0 and 4109bbd.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Comment on lines +388 to +394
if [ "$TASK_COUNT" -eq 0 ]; then
echo "::error::Turbo task '$TASK_NAME' returned 0 tasks"
exit 1
fi

echo "affected=${AFFECTED}"
echo "affected=${AFFECTED}" >> $GITHUB_OUTPUT
echo "Task '$TASK_NAME' validated ($TASK_COUNT tasks in graph)"
echo "affected=1" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

affected is now effectively always true.

TASK_COUNT here only proves that the task exists and has a non-empty dry-run graph. Since Line 394 unconditionally writes affected=1, the later if: steps.task-status.outputs.affected == '1' guards no longer filter anything, so every defined integration suite will run even on unrelated-file PRs. That looks like a regression from the intended skip-on-unrelated-changes behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 388 - 394, The workflow currently sets
"affected=1" unconditionally after verifying TASK_COUNT, which only proves the
task exists; change the logic in the task-status step to set GITHUB_OUTPUT
affected=1 only when the task is actually affected by the PR (not just present
in the graph). Concretely, use the variable or check that indicates whether the
task is in the affected set (e.g., the Turbo/affected output or a computed
AFFECTED_TASKS list) instead of TASK_COUNT/TASK_NAME alone, and write
"affected=1" only when that check is true, otherwise write "affected=0" so
downstream if: steps.task-status.outputs.affected == '1' filters correctly.
Ensure you update the code that currently writes echo "affected=1" >>
$GITHUB_OUTPUT to be conditional on the actual affected-check.

The validation step is now a gate — if it fails, the job stops. No need
for an output variable and downstream if-conditions since integration
tests always run (root-level turbo tasks bypass --affected filtering).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant