Skip to content

feat(release): check internal Rust crates in the production dependency check (ENG-3570) - #106

Merged
Frudrax Cheng (auroursa) merged 1 commit into
mainfrom
ursa/eng-3570-check-internal-crates
Oct 10, 2026
Merged

Frudrax Cheng (auroursa) merged 1 commit into
mainfrom
ursa/eng-3570-check-internal-crates

Conversation

@auroursa

@auroursa Frudrax Cheng (auroursa) commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Part of ENG-3570

check-production-dependencies reads a pnpm workspace and nothing else, so a Rust source has no production dependency policy to run: the action fails on the missing pnpm-workspace.yaml before it looks at anything. #103 gave internal crates a release (a vX.Y.Z tag of their repository, with an exact crate version), and promotion already refuses a crate that depends on an unreleased one. This change applies the same rule to a source that consumes those crates.

Behavior

The action audits what the selected commit has at its root: a pnpm workspace, a Cargo workspace (Cargo.toml with its committed Cargo.lock), or both. A commit with neither fails with a message that says so. The npm rules and the npm report are unchanged.

For a Cargo workspace:

  • Resolved crates. Every package in Cargo.lock whose source is a GitHub repository of the owner must resolve from a vX.Y.Z tag at an exact stable version. A rev, a branch, the default branch or a staging tag fails. Reading the lockfile covers transitive crates, as reading pnpm-lock.yaml does for packages.
  • Published release. The tag must be a release that is neither a draft nor a prerelease, and must still point at the commit Cargo.lock recorded. A tag moved after the lockfile was written fails.
  • Declared pins. Each workspace package's own declarations (normal, dev, build and target dependencies, with workspace = true resolved from the root manifest, and renames through package) must pin the tag and an exact =X.Y.Z version, and Cargo.lock must hold that crate at that tag and version. This is the line the release notes print and the rule crateDependencyFindings enforces at promotion. Dev dependencies are included here, as they are for npm.
  • Path dependencies and workspace members are source in the same commit. Their dependencies are audited through their manifests; a lockfile package with no manifest in the commit fails.
  • A Cargo.lock that is not version 3 or 4 fails, so a future format cannot make internal sources unrecognizable and pass.

The checker reads manifests and lockfiles from Git and never runs Cargo.

Reading releases in other repositories

The job token reads only the calling repository. The new optional crates-token input is a token with contents: read in the repositories the internal crates come from; it defaults to github-token. The README shows minting one with actions/create-github-app-token and an explicit repository list, the way publish-image scopes its build token.

GitHub answers 404 both for a tag with no release and for a private repository the token cannot read. On a 404 the checker asks for the repository itself: if that succeeds the crate is reported as Not released, otherwise as Unknown with a finding that names the missing access. Either result fails the check. A source with no internal crates makes no request and needs no token.

Report

A Cargo workspace adds its own table; a Rust-only source shows only that one.

| Internal crate | Version | Source | Prod? | Reason |
| --- | --- | --- | --- | --- |
| photon-error | 0.1.0 | photon-hq/error tag v0.3.0 | ✅ Yes | Production release |
| photon-example | 1.2.0 | photon-hq/example rev 646e6b9… | ❌ No | Not a release tag |

### Findings
- Cargo.toml: photon-example must pin a release tag vX.Y.Z of photon-hq/example, not rev 646e6b9…
- photon-example@1.2.0: Cargo.lock resolves photon-hq/example at rev 646e6b9…, not a release tag vX.Y.Z

Design notes

  • Workspace members are found by matching the lockfile's source-less package names against every Cargo.toml in the commit, not by evaluating workspace.members globs. It needs no glob or path-dependency semantics, it cannot miss a package Cargo builds, and a manifest outside the workspace (a compatibility fixture with its own lockfile) is ignored.
  • Only the root Cargo.lock is read, as only the root pnpm-lock.yaml is.
  • A release is not required to carry an attested .crate. A Rust-only repository cannot adopt package-stage yet, so its tags are cut by its own workflow; requiring the asset would fail every consumer of such a crate. The check can be tightened once those repositories have a way in.
  • Crates vendored into the consuming repository are path dependencies and are treated as source in the same commit. Whether a vendored copy matches a release is outside this check.
  • New dependency: smol-toml 1.9.0, the version package-release already pins.

Compatibility

Existing callers pin the action by commit and are unaffected until they move the pin. After that, a pnpm-only source gets the same report as before. A source that has both a pnpm workspace and a root Cargo.toml starts being audited for crates too.

Verification

Local, on macOS with Node 24:

  • node --test .github/blocks/check-production-dependencies/*.test.mjs: 30 pass (20 before). The new cases cover resolved and declared pins, inheritance, renames, target tables, release states, lookup failures, a mixed source, reading a Rust-only commit from Git, and the release lookup against a stubbed API.
  • Nine mutations of the new rules (dropping the commit comparison, the prerelease check, inheritance, target tables, dev dependencies, renames, the 404 disambiguation, the lockfile reference, case-insensitive owner matching) each fail at least one test.
  • Ran the CLI with --ref against four Rust service repositories, with a token that can read their dependencies: two with no internal crates pass; one fails on a crate pinned by rev; one fails on a declaration without an exact version. Without a token, the crate rows are Unknown and the run fails.
  • Ran the checker from main and from this branch against two pnpm service repositories: the reports are byte-identical.
  • python3 -m unittest discover -s test: 21 pass.
  • node --test test/*.test.mjs: 44 pass and 23 fail, the same as on main. The failures are the crate packaging tests calling tar --format=gnu, which macOS's tar does not have; this change does not touch them, and CI runs them on Linux.

The action's composite steps were not run in Actions; the first real run is the first caller that pins this commit. CI on this PR is pending.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Production dependency checks now support pnpm workspaces, Cargo workspaces, or both, and report results for JavaScript packages and Rust crates together.
    • Checks validate internal Rust crates against stable release tags, including transitive dependencies.
    • An optional read-only token can be provided to check crates in private repositories; otherwise, those crates may be reported as unknown.
  • Documentation
    • Updated guidance explains supported workspaces, crate checks, and configuring access to private repositories.

…y check (ENG-3570)

The check read only a pnpm workspace, so a Rust source had nothing it
could gate on. It now also audits a Cargo workspace: every crate
Cargo.lock resolves from the owner's GitHub repositories must come from
a vX.Y.Z release tag at an exact stable version, that tag must be a
published release at the resolved commit, and the workspace's own
declarations must pin the tag with an exact =X.Y.Z version.

Verifying a release reads the crate's repository, so the action takes an
optional crates-token for repositories the job token cannot read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 17111cde-ac82-4314-88ba-c64bd779de61

📥 Commits

Reviewing files that changed from the base of the PR and between 6bbaf8b and 927630b.


⛔ Files ignored due to path filters (1)
  • .github/blocks/check-production-dependencies/package-lock.json is excluded by !**/package-lock.json

📒 Files selected for processing (6)
  • .github/blocks/check-production-dependencies/action.yaml
  • .github/blocks/check-production-dependencies/check-production-dependencies.mjs
  • .github/blocks/check-production-dependencies/check-production-dependencies.test.mjs
  • .github/blocks/check-production-dependencies/internal-crates.mjs
  • .github/blocks/check-production-dependencies/package.json
  • README.md

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📜 Recent review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: check-skills / check-skills
  • GitHub Check: check-readme / check-readme
  • GitHub Check: test-release-workflows

🔇 Additional comments (6)
.github/blocks/check-production-dependencies/check-production-dependencies.mjs (1)

2-9: LGTM!

Also applies to: 49-71, 83-86, 113-145, 313-339, 385-402, 415-450, 460-460


.github/blocks/check-production-dependencies/package.json (1)

10-10: LGTM!


.github/blocks/check-production-dependencies/check-production-dependencies.test.mjs (1)

482-759: LGTM!


.github/blocks/check-production-dependencies/internal-crates.mjs (1)

1-262: LGTM!


.github/blocks/check-production-dependencies/action.yaml (1)

2-2: LGTM!

Also applies to: 13-15, 39-39


README.md (1)

464-494: LGTM!

Also applies to: 504-524





📝 Walkthrough

Walkthrough

The production dependency check now supports pnpm workspaces, Cargo workspaces, or both. It validates internal Cargo crate pins against GitHub releases and combines package and crate results in its audit and report.

Changes

Production dependency audit

Layer / File(s) Summary
Workspace input discovery
.github/blocks/check-production-dependencies/check-production-dependencies.mjs, .github/blocks/check-production-dependencies/package.json, .github/blocks/check-production-dependencies/check-production-dependencies.test.mjs
The checker reads pnpm and Cargo inputs from a selected Git ref or the working tree. It requires at least one supported workspace and requires readable root Cargo manifests and lockfiles when Cargo inputs are present.
Internal crate pin and release validation
.github/blocks/check-production-dependencies/internal-crates.mjs, .github/blocks/check-production-dependencies/check-production-dependencies.test.mjs
The crate audit checks internal Git-sourced packages, workspace declarations, stable version requirements, release tags, and locked commits. It records crate-level results and errors, including release lookup failures.
Combined audit, reporting, and action setup
.github/blocks/check-production-dependencies/action.yaml, .github/blocks/check-production-dependencies/check-production-dependencies.mjs, .github/blocks/check-production-dependencies/check-production-dependencies.test.mjs, README.md
The checker combines package and crate audits and renders ecosystem-specific tables. The action accepts crates-token and falls back to github-token; the documentation describes this input and shows an example workflow.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Action
  participant Checker
  participant auditCrates
  participant fetchCrateRelease
  participant GitHubAPI
  Action->>Checker: Set CRATES_TOKEN and run dependency check
  Checker->>auditCrates: Audit Cargo inputs
  auditCrates->>fetchCrateRelease: Look up repository and tag
  fetchCrateRelease->>GitHubAPI: Request release and tag commit
  GitHubAPI-->>fetchCrateRelease: Return release data and commit
  fetchCrateRelease-->>auditCrates: Return release status and commit
  auditCrates-->>Checker: Return crate records and errors
  Checker-->>Action: Return combined results or errors
Loading

Merge Risk: ⚪ Minimal · up to 92763

The production dependency check now also audits internal Cargo crates alongside pnpm packages. No merge-blocking risk was identified. The action's composite steps have not yet run in Actions, so check CI before merging.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 3 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: adding checks for internal Rust crates to the production dependency check. The release scope and issue reference are relevant.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 3 files. (3 skipped: 3 unsupported.)



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

I’m a rabbit with a crate to inspect,
I check every tag and pin for effect.
Through workspace paths I hop along,
Then package and crate reports join the song.
A stable release earns a bright carrot today!

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

@auroursa
Frudrax Cheng (auroursa) merged commit 84c04f8 into main Oct 10, 2026
5 checks passed
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