docs(ci): fix both Sourcery findings on the two-step gate and artifact recipe - #18
Conversation
Reviewer's GuideUpdates 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 gatesequenceDiagram
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
Flow diagram for preserving audit status through a tee pipelineflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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
| run: | | ||
| npx --yes euthyna@latest audit --base "origin/${{ github.base_ref }}" --head HEAD | ||
| echo "exit_code=$?" >> "$GITHUB_OUTPUT" | ||
| id: audit |
There was a problem hiding this comment.
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.
Both Sourcery review comments on #17 are correct; verified locally before fixing:
Two-step variant blurred
10vs1/2—outcomecollapses 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 publishesexit_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.| teeate the audit's exit code — Actions' default shell isbash -ewithout pipefail, so the step's status wastee's (always 0) and a1/2/10audit turned the gate green. Fix:set -o pipefailadded 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 test207 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:
Enhancements:
Documentation: