Skip to content

fix(ci): print a JSON result when ci run skips the gate - #709

Open
Yazan-O wants to merge 2 commits into
TestSprite:mainfrom
Yazan-O:fix/ci-skip-json-stdout
Open

Yazan-O wants to merge 2 commits into
TestSprite:mainfrom
Yazan-O:fix/ci-skip-json-stdout

Conversation

@Yazan-O

@Yazan-O Yazan-O commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

ci run --output json exited 0 with empty stdout when it skipped the gate: on a draft pull request, and on a deployment_status event whose commit belongs to no open pull request. A step that parses the result (jq, JSON.parse, an agent reading stdout) then failed on an empty string. The documentation promises that under --output json the same information is on stdout on every path.

skipCiRun now prints one JSON result under --output json:

{ "skipped": true, "reason": "<the ::notice:: text>", "summary": { "total": 0, "passed": 0, "failed": 0, "skipped": 0, "timedOut": 0, "runs": [] } }

summary is the same zeroed CiSummary the step outputs are written from, under the same key the gated run's envelope uses, so jq .summary.passed reads on every path. Text mode is unchanged (stdout stays empty). The summary file, job summary and JUnit report are still not written on a skip: they describe runs, and none ran.

Before:

$ GITHUB_ACTIONS=true GITHUB_EVENT_NAME=pull_request GITHUB_EVENT_PATH=./draft.json \
    testsprite ci run --project <id> --env staging --target-url https://preview.example --output json | jq .
::notice title=TestSprite::Skipping draft pull request #7; the gate runs once it is ready for review.
(stdout empty; jq reads no input)          exit 0

After:

::notice title=TestSprite::Skipping draft pull request #7; the gate runs once it is ready for review.
{
  "skipped": true,
  "reason": "Skipping draft pull request #7; the gate runs once it is ready for review.",
  "summary": { "total": 0, "passed": 0, "failed": 0, "skipped": 0, "timedOut": 0, "runs": [] }
}                                          exit 0

Related issue

Closes #671

Season 4 CLI Improvement Bonus

  • I'm entering this PR for the Season 4 CLI Improvement Bonus

Discord username: yazan030803

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only
  • Build / CI / chore

Checklist

  • PR targets the main branch.
  • Commits follow Conventional Commits
    (feat(...), fix(...), docs(...), …).
  • npm run lint and npm run format:check pass.
  • npm run typecheck passes.
  • npm test passes and coverage stays at or above the 80% gate.
  • New behavior is covered by unit tests (mock-based; no network or
    credentials required).
  • No secrets, API keys, internal endpoints, or personal data are included.
  • User-facing changes are reflected in README.md / DOCUMENTATION.md where
    relevant.

Notes for reviewers

  • Tests: ci-run.spec.ts gains two it.each blocks over both skip paths. Under JSON, stdout parses to exactly the envelope, the reason matches the ::notice::, nothing is dispatched, and no summary file is written. In text mode, stdout stays empty. The two JSON cases fail on main with Unexpected end of JSON input.
  • Local run on Node 22.23.4, Windows 11: tsc --noEmit clean, eslint 0 errors, prettier clean, build clean. Full suite 4793 passed / 11 skipped (main 4789 / 11; +4 new). Coverage: statements 89.97, branches 84.99, functions 83.64, lines 92.14.
  • Step outputs, telemetry outcomes (skipped_draft, skipped_no_pr) and exit code 0 are unchanged.

Summary by CodeRabbit

  • New Features
    • Skipped pull-request and deployment-status runs now return a JSON result with the skipped status, notice reason, and zeroed summary when JSON output is requested.
    • Skipped runs continue to provide a GitHub notice and step outputs; text mode produces no standard output.
  • Documentation
    • Updated the ci run documentation to describe skipped-run output and confirm that skip conditions and exit codes are unchanged.

Under --output json, a draft pull request or a deployment_status event
with no pull request exited 0 with empty stdout, so a step parsing the
result failed on an empty string. skipCiRun now prints
{skipped: true, reason, summary} with the zeroed CiSummary the step
outputs carry. Text mode is unchanged, and the summary file, job summary
and JUnit report are still not written on a skip.

Closes TestSprite#671
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 5281202 and c51645a.

Files selected for processing: 3
  • DOCUMENTATION.md
  • src/commands/ci-run.spec.ts
  • src/commands/ci.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

Skipped draft pull requests and deployment-status events without an associated pull request now emit a JSON result when JSON output is selected. The result contains a skipped flag, notice reason, and zeroed summary. Text output behavior and the existing skip conditions remain unchanged.

Changes

Skipped CI run output

Layer / File(s) Summary
Wire and validate skipped-run output
src/commands/ci.ts, src/commands/ci-run.spec.ts, DOCUMENTATION.md
The skip paths pass output settings to skip handling. JSON mode emits a result with the skip reason and zeroed summary. Tests cover JSON and text behavior, and the documentation describes the JSON response.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested labels: needs-issue, s4-cli-bonus

Merge Risk: Minimal · up to c5164

With --output json, draft pull requests and deployment events with no open pull request now print a parseable JSON skip result. Text-mode behavior and exit codes are unchanged, and the change is covered by tests and documentation. No merge-blocking issue was found.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: emitting a JSON result when ci run skips the gate.
Linked Issues check Passed Issue #671 requires parseable JSON on both skip paths, the skipped flag, the notice text in reason, and a zeroed summary. The supplied PR evidence reports these fields in skipCiRun for draft p…
Out of Scope Changes check Passed The reported changes are limited to skip-path JSON output, focused tests, and documentation for issue #671. The output refactor supports the requested behavior. No unrelated change is identified.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #671 requires parseable JSON on both skip paths, the skipped flag, the notice text in reason, and a zeroed summary. The supplied PR evidence reports these fields in skipCiRun for draft pull requests and deployment events without an open pull request. It also reports unchanged text-mode output and no summary file, job summary, or JUnit report on skips. The added parameterized tests cover both paths and text mode. DOCUMENTATION.md records the JSON behavior.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown

Thanks for the PR, @Yazan-O! It links an issue, but that issue isn't assigned to you yet: #671 (unassigned). Per our workflow, claim the issue first by commenting /assign on it (the triage bot assigns you automatically). If it's already assigned to someone else, please coordinate with them or pick another issue — unclaimed-issue PRs are not reviewed. After fixing it, edit the PR description or push a commit to re-run this check. See CONTRIBUTING → Contribution model.

@github-actions github-actions Bot added the needs-issue PR not linked to an issue yet — please open one first and claim it (see CONTRIBUTING) label Oct 29, 2026
@github-actions

Copy link
Copy Markdown

🏆 Season 4 CLI Improvement Bonus: entry recorded. Thanks, @Yazan-O!

To be counted, this PR needs the following by Oct 29, 11:59 PM PT:

  • ⬜ A linked issue assigned to you: the issue this PR links isn't assigned to you yet. Claim it by commenting /assign on it.
  • ✅ Out of draft.
  • ✅ A Discord username in the description.

Rewards go to merged PRs judged a genuine improvement, and up to three bonus-eligible PRs count per person. Untick the box to withdraw the entry. This comment refreshes when you edit the PR. Full rules.

@github-actions github-actions Bot added the s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus label Oct 29, 2026
@jangjos-128 jangjos-128 added the hackathon CLI hackathon submissions label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hackathon CLI hackathon submissions needs-issue PR not linked to an issue yet — please open one first and claim it (see CONTRIBUTING) s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] fix(ci): ci run --output json prints nothing on stdout when it skips a draft PR or a deployment with no PR

3 participants