Report the number of nix builds that passed / failed#196
Conversation
WalkthroughAdded DEvent to imports and introduced a new public method reportPassFailCount to tally build outcomes from recent events. Integrated this tally into the summarization flow by invoking it after fetching events, recording three facts: nix_builds_succeeded, nix_builds_failed, and nix_builds_unknown_event. Changes
Sequence Diagram(s)sequenceDiagram
actor Caller
participant NixInstallerAction as NixInstallerAction
participant Events as events.js
participant Facts as Fact Recorder
Caller->>NixInstallerAction: summarizeExecution()
NixInstallerAction->>Events: getRecentEvents()
Events-->>NixInstallerAction: events: DEvent[]
rect rgba(200, 235, 255, 0.3)
note right of NixInstallerAction: New step: tally build outcomes
NixInstallerAction->>NixInstallerAction: reportPassFailCount(events)
loop For each DEvent
alt BuiltPathResponseEventV1
NixInstallerAction->>Facts: record("nix_builds_succeeded", +1)
else BuildFailureResponseEventV1
NixInstallerAction->>Facts: record("nix_builds_failed", +1)
else Other
NixInstallerAction->>Facts: record("nix_builds_unknown_event", +1)
end
end
end
NixInstallerAction-->>Caller: summary (includes recorded facts)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/index.ts (2)
15-15: Use a type-only import for DEvent.Minor clarity/perf nit: mark DEvent as a type-only import.
-import { DEvent, getRecentEvents } from "./events.js"; +import type { DEvent } from "./events.js"; +import { getRecentEvents } from "./events.js";
671-693: Hoist fact keys to constants and consider exposing totals/success rate.
- Define FACT_* constants for the new facts (consistency with existing facts block).
- Optionally add total and success rate to ease downstream analysis.
- Rename
unknownto avoid confusion with the TSunknowntype.Add constants near the existing “Facts”:
const FACT_SENT_SIGTERM = "sent_sigterm"; +const FACT_NIX_BUILDS_SUCCEEDED = "nix_builds_succeeded"; +const FACT_NIX_BUILDS_FAILED = "nix_builds_failed"; +const FACT_NIX_BUILDS_UNKNOWN_EVENT = "nix_builds_unknown_event"; +const FACT_NIX_BUILDS_TOTAL = "nix_builds_total"; +const FACT_NIX_BUILDS_SUCCESS_RATE = "nix_builds_success_rate";Refactor the method:
- async reportPassFailCount(events: DEvent[]): Promise<void> { - let built = 0; - let failed = 0; - let unknown = 0; + async reportPassFailCount(events: DEvent[]): Promise<void> { + let built = 0; + let failed = 0; + let unknownCount = 0; for (const event of events) { switch (event.c) { case "BuiltPathResponseEventV1": built++; break; case "BuildFailureResponseEventV1": failed++; break; default: - unknown++; + unknownCount++; } } - this.addFact("nix_builds_succeeded", built); - this.addFact("nix_builds_failed", failed); - this.addFact("nix_builds_unknown_event", unknown); + const total = built + failed + unknownCount; + const successRate = total > 0 ? built / total : 0; + this.addFact(FACT_NIX_BUILDS_SUCCEEDED, built); + this.addFact(FACT_NIX_BUILDS_FAILED, failed); + this.addFact(FACT_NIX_BUILDS_UNKNOWN_EVENT, unknownCount); + this.addFact(FACT_NIX_BUILDS_TOTAL, total); + this.addFact(FACT_NIX_BUILDS_SUCCESS_RATE, successRate); }If desired, I can also add a small block to the job summary showing these counts.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (2)
dist/index.jsis excluded by!**/dist/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
package.json(2 hunks)src/index.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/index.ts (2)
dist/index.js (6)
events(4339-4339)events(99647-99672)events(99727-99731)built(100390-100390)failed(100391-100391)unknown(100392-100392)src/events.ts (1)
DEvent(3-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Test: macos-14-xlarge with determinate
- GitHub Check: Test: namespace-profile-default-arm64
- GitHub Check: Test: macos-14-large
- GitHub Check: Test: macos-14-xlarge
- GitHub Check: Test: nscloud-ubuntu-22.04-amd64-4x16
- GitHub Check: Test: macos-14-large with determinate
- GitHub Check: Test: macos-13-large
- GitHub Check: Test: macos-13-large with determinate
- GitHub Check: Test: namespace-profile-default-arm64 with determinate
- GitHub Check: Test: ubuntu-latest
- GitHub Check: Check the dist/ folder is up to date
🔇 Additional comments (2)
package.json (1)
52-52: No-op formatting change looks fine.No functional impact.
src/index.ts (1)
619-620: Good placement for metrics collection.Calling the counter before generating summaries ensures facts are recorded even if later steps are skipped.
873f5c2 to
69c59dd
Compare
69c59dd to
6687d88
Compare
Description
This gives us more signal in our rollout of new versions.
Checklist
Summary by CodeRabbit