Skip to content

Report the number of nix builds that passed / failed#196

Merged
grahamc merged 2 commits intomainfrom
push-yzqxmymrzovs
Sep 3, 2025
Merged

Report the number of nix builds that passed / failed#196
grahamc merged 2 commits intomainfrom
push-yzqxmymrzovs

Conversation

@grahamc
Copy link
Copy Markdown
Member

@grahamc grahamc commented Sep 3, 2025

Description

This gives us more signal in our rollout of new versions.

Checklist
  • Tested changes against a test repository
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • (If this PR is for a release) Updated README to point to the new tag (leave unchecked if not applicable)

Summary by CodeRabbit

  • New Features
    • Summaries now display counts of successful, failed, and unknown build outcomes for recent activity.
    • Build outcome counts are recorded as facts for reporting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 3, 2025

Walkthrough

Added 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

Cohort / File(s) Summary
Public API updates
src/index.ts
Added public method reportPassFailCount(events: DEvent[]): Promise. Updated import to include DEvent from ./events.js.
Summarization flow updates
src/index.ts
After fetching recent events, now calls reportPassFailCount(events) in two summarization paths. Records facts: nix_builds_succeeded, nix_builds_failed, nix_builds_unknown_event.

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)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I counted builds by moonlit logs, hop-hop, tally true,
Successes in a carrot row, and failures in a few.
Unknowns? I nudge aside—“perhaps another clue.”
With ears up high I file the facts, crisp as morning dew,
Then bound away—summary done, for you. 🥕🐇


📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 69c59dd and 6687d88.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/index.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/index.ts
⏰ 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)
  • GitHub Check: Test: macos-14-xlarge with determinate
  • GitHub Check: Test: macos-14-large
  • GitHub Check: Test: macos-14-xlarge
  • GitHub Check: Test: namespace-profile-default-arm64
  • GitHub Check: Test: macos-14-large with determinate
  • GitHub Check: Test: macos-13-large with determinate
  • GitHub Check: Test: ubuntu-latest
  • GitHub Check: Test: namespace-profile-default-arm64 with determinate
  • GitHub Check: Test: macos-13-large
  • GitHub Check: Test: nscloud-ubuntu-22.04-amd64-4x16
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch push-yzqxmymrzovs

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 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 unknown to avoid confusion with the TS unknown type.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 428f3c6 and f9c1c37.

⛔ Files ignored due to path filters (2)
  • dist/index.js is excluded by !**/dist/**
  • pnpm-lock.yaml is 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.

@grahamc grahamc merged commit 2c3a298 into main Sep 3, 2025
18 checks passed
@grahamc grahamc deleted the push-yzqxmymrzovs branch September 3, 2025 16:03
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.

2 participants