Skip to content

fix(ci): keep smoke-linux host heredoc inert and use host DNS - #2

Draft
knowlet wants to merge 2 commits into
mainfrom
cursor/fix-smoke-linux-heredoc-255d
Draft

knowlet wants to merge 2 commits into
mainfrom
cursor/fix-smoke-linux-heredoc-255d

Conversation

@knowlet

@knowlet knowlet commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Problem / Motivation

Goal: Stop Linux package smoke tests from failing on nightly builds because the CI host expands assertion-script heredocs before they run inside containers.

Nightly smoke-linux-packages jobs occasionally fail even when the built .deb/.rpm artifacts are good. The runner builds install/assert shell by expanding an unquoted heredoc on the host, so backticks and $(…) inside assertion comments execute on the host and corrupt the script sent to Docker.

Why it matters

Without this fix, Linux nightly publication can fail structurally (smoke assertions never reach the container faithfully), blocking release signal for every distro target the job covers.

Not a goal

  • Changing which files the smoke job asserts inside the container.
  • Reintroducing --network host for smoke containers (a one-off DNS flake is not treated as bridge-root-caused).
  • Fixing unrelated macOS nightly runner acquisition timeouts.

What changed (motivation → approach → change)

common_asserts() in scripts/smoke-linux-packages.sh now emits assertions from a quoted heredoc (<<'ASSERTS') and splices only allowlisted package-list commands (dpkg -L \"$pkg\" / rpm -ql \"$pkg\") through a __LIST_CMD__ placeholder. Host expansion cannot interpret backticks or command substitution in comments (including paths like /opt/KiroCrew Nightly/...).

The Fast Gate source-gates job in .github/workflows/fast-gate.yml checks out with fetch-depth: 0 so resolve_base() on fork PRs can compute a real merge-base instead of falling back to the base branch tip (which widens diff-scoped gates incorrectly). That checkout still retains credentials: the job runs git fetch origin for the diff base, and the retention comment above the step is the reason the credential stays.

The regression tests call the shared POSIX shell (Git Bash on Windows) instead of bash on PATH. On a GitHub Windows runner that name is the WSL launcher, which writes a UTF-16 "no installed distributions" line and exits 1. The child's text mode is pinned to UTF-8.

Backwards compatibility

Compatible: smoke behavior and assertions are unchanged; only how the host emits the in-container script and how CI checks out history for diff-base resolution differ. The source-gates checkout credential matches the retention comment that was already on the step.

Removes nothing: no weakening of network isolation on operator machines; checkout depth change is CI-only for source-gates.

Tests

  • test/test_smoke_linux_packages_common_asserts.py — quoted heredoc, allowlist, bash -n, host-substitution sentinel on the old pattern, and a pin that a Git Bash path is not replaced by a PATH lookup.
  • test/test_workflow_checkout_credentials.py::test_no_checkout_both_opts_out_and_claims_retention — source-gates keeps the retention comment and does not also opt out.
  • test/test_check_comment_history.py::TestCiWiring::test_source_gates_checkout_fetches_full_history_for_merge_base — pins full-history checkout for source-gates.
  • Proof: python3 scripts/local-gate.py passed on this tree (602 backend tests, 15736 frontend tests). Head c200748332.

Manual verification

  • Downloaded public build-linux-x64 from nightly run 43032889810 and ran sudo scripts/smoke-linux-packages.sh — exit 0 for deb and rpm install/assert/uninstall paths.
  • Targeted pytest modules above pass locally after rebasing onto current main.

Pattern harvest

Rule candidate: semgrep
Pattern: unquoted bash heredoc delimiter when downstream content is passed to a container/subprocess and may contain shell metacharacters in comments.

Sibling sweep

Swept: git grep -nE "common_asserts|<<ASSERTS" -- scripts/
Siblings: none — common_asserts() is the only host-side heredoc emitter for Linux package smoke.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see CONTRIBUTING.md.

Open in Web Open in Cursor 

Summary by Sourcery

Keep Linux smoke-test scripts inert during host generation and make source-gate diff detection use accurate repository history.

Bug Fixes:

  • Prevent Linux package smoke-test assertion scripts from being corrupted by host-side shell expansion.
  • Ensure fork pull requests use the true merge base for diff-scoped source gates.

CI:

  • Configure the source-gates checkout to fetch full history for accurate merge-base resolution.

Tests:

  • Add regression coverage for quoted smoke-test heredocs, command allowlisting, shell syntax, and full-history source-gates checkout.

Summary by cubic

Fixes recurring Nightly Build failures in the Linux package smoke-install job caused by host-side heredoc expansion.

The common_asserts() function expanded an unquoted heredoc on the CI runner, so backticks in comments ran as command substitution on the host and corrupted the emitted container script. It now uses a quoted heredoc and splices only two allowlisted list commands (dpkg -L "$pkg" / rpm -ql "$pkg") via __LIST_CMD__. New regression tests run on the shared POSIX shell (Git Bash on Windows runners) so the WSL launcher cannot run them. Also deepens the fast-gate source-gates checkout to fetch-depth: 0, retaining credentials since it still fetches origin, so diff-scoped gates on forks compute an exact merge-base instead of falling back to the base TIP. Smoke behavior and assertions are unchanged.

Written for commit c200748. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Make common_asserts() emit its assertion body from a quoted heredoc and substitute only the two allowlisted package-list commands, preventing host-side shell expansion.

  • scripts/smoke-linux-packages.sh L71-85, L93-97, L102-112 (+1 small edits)

Configuration

Give the source-gates checkout full history so diff-base resolution can find the actual merge base.

  • .github/workflows/fast-gate.yml L96-101

Tests

Add regression tests for inert heredoc generation, supported list commands, shell syntax, and using the correct Bash executable.

  • test/test_smoke_linux_packages_common_asserts.py L1-142

Assert that the source-gates checkout is configured to fetch full history.

  • test/test_check_comment_history.py L49-55

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 11, 2026
Use a quoted heredoc in smoke-linux common_asserts() so the CI host
cannot expand backticks or command substitution inside assertion
comments. Splice only allowlisted dpkg/rpm list commands.

Set source-gates checkout fetch-depth to 0 so fork merge-base resolution
does not fall back to base TIP. Regression tests pin both behaviors.

Signed-off-by: Albert Hsieh <knowlet@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/fix-smoke-linux-heredoc-255d branch from 84537f9 to ed690d3 Compare November 17, 2026 09:44
The smoke assert tests invoked PATH bash, which on a Windows runner is
the WSL launcher: it prints a UTF-16 "no distributions" line and exits
1, so the new suite failed every Windows shard and the subprocess
encoding ratchet. Run them with the shared POSIX shell (Git Bash there)
and pin the child's encoding.

source-gates still fetches origin for the diff base, so the checkout
keeps its credential. The opt-out contradicted the retention comment
and failed the checkout ratchet, which failed Coverage Gate closed.

Signed-off-by: Albert Hsieh <knowlet@pm.me>

This branch has not been deployed

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

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant