Skip to content

[CI] Introduce guard job#4047

Open
testableapple wants to merge 8 commits intodevelopfrom
ci/skip-ci
Open

[CI] Introduce guard job#4047
testableapple wants to merge 8 commits intodevelopfrom
ci/skip-ci

Conversation

@testableapple
Copy link
Copy Markdown
Contributor

@testableapple testableapple commented Apr 2, 2026

🔗 Issue Links

Resolve https://linear.app/stream/issue/IOS-1555

🎯 Goal

Skip all CI checks if the PR title contains skip-ci

📜 Summary

Everything works as before. Only if a PR contains skip-ci in title, the checks will be skipped. If you delete skip-ci from title and restart cancelled jobs, they will run.

Summary by CodeRabbit

  • New Features
    • Add a CI guard that lets contributors skip workflows by putting "skip-ci" in a pull request title.
  • Chores
    • Centralize CI gating so workflows wait for the guard check before proceeding.
    • Metrics workflows now run only for non‑PR events or non‑draft pull requests.

@testableapple testableapple added the 🤖 CI/CD Any work related to CI/CD label Apr 2, 2026
@testableapple testableapple requested a review from a team as a code owner April 2, 2026 14:41
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added a new GitHub Actions composite action ci-guard and invoked it across multiple workflows so jobs are gated by the guard; several workflows now use job-level conditionals and a guard step to cancel or skip workflow execution when a pull request title contains skip-ci or PR is a draft.

Changes

Cohort / File(s) Summary
Smoke checks: guard + dependency updates
\.github/workflows/smoke-checks.yml
Added new guard job that runs ./.github/actions/ci-guard with github_token; updated many jobs to include needs: guard or add guard to existing needs arrays so downstream jobs wait for the guard.
Performance metrics: centralized job-level guard
\.github/workflows/sdk-performance-metrics.yml
Added jobs.performance.if conditional to skip on draft PRs, inserted an initial ./.github/actions/ci-guard step (with github_token), moved actions/checkout@v3.1.0 earlier, and removed prior per-step if: checks.
Size metrics: conditional execution added
\.github/workflows/sdk-size-metrics.yml
Added job-level if to gate sdk_size (run for non-PR events or non-draft PRs), added initial ./.github/actions/ci-guard step (with github_token) before checkout/bootstrap.
New composite action: ci-guard
\.github/actions/ci-guard/action.yml
Added composite action ci-guard requiring github_token; on pull_request it fetches PR title via gh pr view, checks for case-insensitive skip-ci, and cancels the running workflow (gh run cancel) if matched.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant PR as "Pull Request"
    participant GH as "GitHub Actions Runner"
    participant Guard as "ci-guard action"
    participant Jobs as "Downstream Jobs"

    PR->>GH: Event (push / pull_request)
    GH->>Guard: Run guard job/step (with GH_TOKEN)
    Guard->>GH: gh pr view -> fetch PR title
    alt PR title contains "skip-ci" (case-insensitive)
        Guard->>GH: gh run cancel (cancel workflow)
        GH->>Jobs: Cancel or skip downstream jobs
    else PR is draft
        Guard-->>GH: exit (job-level if may prevent execution)
        GH->>Jobs: Skip jobs due to job-level condition
    else allowed
        Guard-->>GH: exit successfully
        GH->>Jobs: Start jobs that `need` guard
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
I hop the CI, I sniff the name,
If "skip-ci" glows, I still the flame.
A whisper to runners, soft and neat,
No needless builds, just silent feet.
Guarded hops and tidy logs.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title '[CI] Introduce guard job' directly describes the main change: a new guard job was added to CI workflows to implement the skip-ci functionality.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/skip-ci

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 and usage tips.

Copy link
Copy Markdown

@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/smoke-checks.yml:
- Around line 29-37: The guard job currently runs gh run cancel but doesn't
declare the required permission; update the guard job definition (job name
"guard") to include a permissions block granting actions: write so the gh run
cancel command can succeed (add permissions: actions: write under the guard
job). Ensure the permissions stanza is set at the job level not just workflow
level so repositories with restrictive GITHUB_TOKEN defaults allow the
cancellation step to run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8be6893c-3d13-48ac-bc34-74853dedb50d

📥 Commits

Reviewing files that changed from the base of the PR and between 438436c and 692527b.

📒 Files selected for processing (1)
  • .github/workflows/smoke-checks.yml

Copy link
Copy Markdown

@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/sdk-size-metrics.yml:
- Line 23: The workflow skips draft PRs that are later marked ready because the
pull_request trigger only uses default types; update the workflow's pull_request
trigger to explicitly include ready_for_review (e.g., add "ready_for_review" to
the types list alongside opened, synchronize, reopened) so the condition if:
github.event_name != 'pull_request' ||
(!contains(github.event.pull_request.title, 'skip-ci') &&
github.event.pull_request.draft == false) will evaluate for PRs that transition
from draft to ready and metrics will be collected; locate the pull_request
trigger block and add ready_for_review to the types array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: af288a7f-9e92-40e3-ad31-aa6f51b4b188

📥 Commits

Reviewing files that changed from the base of the PR and between 692527b and 7d02d70.

📒 Files selected for processing (3)
  • .github/workflows/sdk-performance-metrics.yml
  • .github/workflows/sdk-size-metrics.yml
  • .github/workflows/smoke-checks.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/smoke-checks.yml

@testableapple testableapple changed the title [skip-ci][CI] Introduce guard job [CI] Introduce guard job Apr 2, 2026
@testableapple testableapple changed the title [CI] Introduce guard job [skip-ci][CI] Introduce guard job Apr 2, 2026
Copy link
Copy Markdown

@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.

🧹 Nitpick comments (2)
.github/workflows/smoke-checks.yml (2)

43-44: Optional: Simplify PR title access using context variable.

The PR title is available directly via ${{ github.event.pull_request.title }}, which would eliminate the API call and the need for pull-requests: read permission:

-         PR_TITLE=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" --jq .title)
-         if printf '%s' "$PR_TITLE" | grep -Fqi 'skip-ci'; then
+         if printf '%s' "${{ github.event.pull_request.title }}" | grep -Fqi 'skip-ci'; then

However, the current approach fetches the current title, which handles the case where the title is edited after the workflow starts. If that behavior is intentional, ignore this suggestion.

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

In @.github/workflows/smoke-checks.yml around lines 43 - 44, The workflow
unnecessarily calls the GitHub API to populate PR_TITLE when the pull request
title is already available via the context; replace the command that sets
PR_TITLE using gh api with a direct assignment from the workflow context (use
`${{ github.event.pull_request.title }}`) so you can remove the `pull-requests:
read` permission, unless you intentionally need the live-updated title after
workflow start — in that case keep the `gh api` invocation and retain the
permission.

29-46: Consider adding draft PR handling for consistency with other workflows.

Other workflows (e.g., sdk-size-metrics.yml, sdk-performance-metrics.yml) also skip execution for draft PRs using the condition:

if: github.event_name != 'pull_request' || (!contains(github.event.pull_request.title, 'skip-ci') && github.event.pull_request.draft == false)

If draft PRs should also skip CI in this workflow, the check could be extended:

Suggested enhancement
      - name: Check
        run: |
          if [ "${{ github.event_name }}" != "pull_request" ]; then
            exit 0
          fi
+         if [ "${{ github.event.pull_request.draft }}" = "true" ]; then
+           gh run cancel "${{ github.run_id }}" --repo "${{ github.repository }}"
+           exit 0
+         fi
          PR_TITLE=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" --jq .title)
          if printf '%s' "$PR_TITLE" | grep -Fqi 'skip-ci'; then
            gh run cancel "${{ github.run_id }}" --repo "${{ github.repository }}"
          fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/smoke-checks.yml around lines 29 - 46, The Check step
currently only inspects PR_TITLE and 'skip-ci' but doesn't handle draft PRs;
update the guard logic in the "Check" step (the shell block that defines
PR_TITLE) to also fetch and inspect the pull request's draft status
(github.event.pull_request.draft) or use gh api to retrieve the PR JSON and
check the "draft" field, and exit/cancel the run when the PR is a draft (similar
to the pattern used in other workflows) so that the Check step skips/cancels the
run for draft PRs as well as those containing 'skip-ci'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/smoke-checks.yml:
- Around line 43-44: The workflow unnecessarily calls the GitHub API to populate
PR_TITLE when the pull request title is already available via the context;
replace the command that sets PR_TITLE using gh api with a direct assignment
from the workflow context (use `${{ github.event.pull_request.title }}`) so you
can remove the `pull-requests: read` permission, unless you intentionally need
the live-updated title after workflow start — in that case keep the `gh api`
invocation and retain the permission.
- Around line 29-46: The Check step currently only inspects PR_TITLE and
'skip-ci' but doesn't handle draft PRs; update the guard logic in the "Check"
step (the shell block that defines PR_TITLE) to also fetch and inspect the pull
request's draft status (github.event.pull_request.draft) or use gh api to
retrieve the PR JSON and check the "draft" field, and exit/cancel the run when
the PR is a draft (similar to the pattern used in other workflows) so that the
Check step skips/cancels the run for draft PRs as well as those containing
'skip-ci'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9681b516-c785-4667-9335-6d330fe2d988

📥 Commits

Reviewing files that changed from the base of the PR and between 7d02d70 and 5057115.

📒 Files selected for processing (1)
  • .github/workflows/smoke-checks.yml

@testableapple testableapple changed the title [skip-ci][CI] Introduce guard job [CI] Introduce guard job Apr 2, 2026
Copy link
Copy Markdown
Contributor

@laevandus laevandus left a comment

Choose a reason for hiding this comment

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

Love it!

@testableapple testableapple changed the title [CI] Introduce guard job [skip-ci][CI] Introduce guard job Apr 2, 2026
Copy link
Copy Markdown

@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/smoke-checks.yml:
- Around line 35-38: The workflow fails because the job invokes the local
composite action ./.github/actions/ci-guard before the repository is checked
out; add a step that runs actions/checkout (e.g., uses: actions/checkout@v4)
immediately before the step that uses ./.github/actions/ci-guard so the local
action's action.yml and files are available to the runner.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c61fe6d-0e8a-4b35-8859-6e22e7f03184

📥 Commits

Reviewing files that changed from the base of the PR and between 5057115 and f76fe39.

📒 Files selected for processing (4)
  • .github/actions/ci-guard/action.yml
  • .github/workflows/sdk-performance-metrics.yml
  • .github/workflows/sdk-size-metrics.yml
  • .github/workflows/smoke-checks.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/sdk-size-metrics.yml
  • .github/workflows/sdk-performance-metrics.yml

@testableapple testableapple changed the title [skip-ci][CI] Introduce guard job [CI] Introduce guard job Apr 2, 2026
@testableapple testableapple changed the title [CI] Introduce guard job [skip-ci][CI] Introduce guard job Apr 2, 2026
@testableapple testableapple changed the title [skip-ci][CI] Introduce guard job [CI] Introduce guard job Apr 2, 2026
@Stream-SDK-Bot
Copy link
Copy Markdown
Collaborator

SDK Size

title develop branch diff status
StreamChat 6.74 MB 6.74 MB 0 KB 🟢
StreamChatUI 4.29 MB 4.29 MB 0 KB 🟢
StreamChatCommonUI 0.75 MB 0.75 MB 0 KB 🟢

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Public Interface

🚀 No changes affecting the public interface.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 CI/CD Any work related to CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants