Skip to content

docs(ci): fix both Sourcery findings on the two-step gate and artifact recipe - #18

Merged
modusensus merged 1 commit into
mainfrom
fix/ci-doc-review
Sep 24, 2026
Merged

modusensus merged 1 commit into
mainfrom
fix/ci-doc-review

Conversation

@modusensus

@modusensus modusensus commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Both Sourcery review comments on #17 are correct; verified locally before fixing:

  1. Two-step variant blurred 10 vs 1/2 — outcome collapses every non-zero result into one boolean, so the enforcement step blocked flagged audits (10) exactly like measurement failures (2), contradicting its own stated purpose. Fix: the audit step now publishes exit_code=$? to ``, and enforcement passes 0 and 10, fails 1 and 2. Logic table tested in bash: 0→pass, 10→pass, 1→fail, 2→fail.

  2. | tee ate the audit's exit code — Actions' default shell is bash -e without pipefail, so the step's status was tee's (always 0) and a 1/2/10 audit turned the gate green. Fix: set -o pipefail added to the artifact recipe in both languages, with a note on why. Reproduced locally: without pipefail the pipeline returns 0 on a failing left side; with it, 10 propagates.

Docs-only change; npm test 207 pass / 0 fail.

Summary by Sourcery

Fix the CI integration guidance so audit exit codes are preserved and correctly enforced across two-step gates and artifact pipelines.

Bug Fixes:

  • Correct the two-step CI gate so audit exit codes 0 and 10 pass while codes 1 and 2 fail.
  • Preserve audit failures in piped report-generation steps by enabling pipefail in both English and Chinese CI documentation.

Enhancements:

  • Clarify how GitHub Actions exposes audit exit codes and how the two-step enforcement contract should interpret them.

Documentation:

  • Update English and Chinese CI integration guides with accurate two-step gating and artifact-reporting examples.

@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Updates the English and Chinese CI integration recipes to preserve audit exit codes in two-step gates and enable pipefail in artifact pipelines, preventing flagged or failed audits from being misclassified or silently producing green workflow steps.

Sequence diagram for the corrected two-step audit gate

sequenceDiagram
    participant Audit as Audit step
    participant Output as GITHUB_OUTPUT
    participant Gate as Enforcement step
    participant Actions as GitHub Actions

    Audit->>Audit: euthyna audit
    Audit->>Output: echo exit_code=$? >> $GITHUB_OUTPUT
    Audit-->>Actions: continue-on-error
    Actions->>Gate: steps.audit.outcome and steps.audit.outputs.exit_code
    Gate->>Gate: evaluate code
    alt code is 0 or 10
        Gate-->>Actions: exit 0
    else code is 1 or 2
        Gate-->>Actions: exit 1
    end
Loading

Flow diagram for preserving audit status through a tee pipeline

flowchart LR
    Audit[euthyna audit] --> Tee[tee audit-report.txt]
    Tee --> Artifact[audit-report.txt artifact]
    Audit -. exit status .-> Pipefail[set -o pipefail]
    Pipefail --> StepStatus[Workflow step status]
    StepStatus --> Gate[CI gate]
Loading

File-Level Changes

Change Details Files
Preserve and enforce the audit tool’s distinct exit-code contract in the two-step workflow.
  • Publish the audit command’s exit code through GITHUB_OUTPUT.
  • Treat exit codes 0 and 10 as passing while failing on 1 and 2.
  • Document why step.outcome alone cannot distinguish flagged audits from errors.
docs/ci-integration.md
docs/ci-integration-zh.md
Ensure artifact-producing audit pipelines propagate failures instead of reporting tee’s success.
  • Enable shell pipefail before piping audit output to tee.
  • Explain that GitHub Actions’ bash -e default does not enable pipefail and document the resulting status behavior.
docs/ci-integration.md
docs/ci-integration-zh.md

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

@modusensus
modusensus merged commit 1782974 into main Sep 24, 2026
10 checks passed
@modusensus
modusensus deleted the fix/ci-doc-review branch September 24, 2026 05:11

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/ci-integration-zh.md" line_range="72" />
<code_context>
           npx --yes euthyna@latest audit --base "origin/${{ github.base_ref }}" --head HEAD
         continue-on-error: true
         id: audit
-      - name: 执行契约(10 = 留给人工审阅,其余非零失败)
+      - name: 执行契约(0 和 10 通过——10 留给人工审阅;1 和 2 失败)
</code_context>
<issue_to_address>
**issue (bug_risk):** The `echo "exit_code=$?"` line is never reached when `audit` exits with 10, 1, or 2 because Actions runs the script with `bash -e`; the shell exits immediately after the failing audit command. Consequently `steps.audit.outputs.exit_code` is unset and the enforcement step cannot distinguish flagged audits from measurement or usage failures, so exit 10 is rejected instead of passing.

**Triggers:** When the audit returns any non-zero exit code, including the documented 10 review result.

**Suggested fix:** Disable errexit around the audit, capture `$?`, publish it, and then exit with the captured code so `continue-on-error` preserves the result for the enforcement step.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: docs/ci-integration-zh.md:72


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/ci-integration-zh.md
run: |
npx --yes euthyna@latest audit --base "origin/${{ github.base_ref }}" --head HEAD
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
id: audit

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The echo "exit_code=$?" line is never reached when audit exits with 10, 1, or 2 because Actions runs the script with bash -e; the shell exits immediately after the failing audit command. Consequently steps.audit.outputs.exit_code is unset and the enforcement step cannot distinguish flagged audits from measurement or usage failures, so exit 10 is rejected instead of passing.

Triggers: When the audit returns any non-zero exit code, including the documented 10 review result.

Suggested fix: Disable errexit around the audit, capture $?, publish it, and then exit with the captured code so continue-on-error preserves the result for the enforcement step.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant