Skip to content

feat(repopo): Add Rust project structure policies #613

@tylerbutler

Description

@tylerbutler

Summary

Add policies for validating Rust project file structure and build configuration.

Proposed Policies

RustToolchainExists

Require rust-toolchain.toml for reproducible builds:

makePolicy(RustToolchainExists, {
  requiredComponents: ["rustfmt", "clippy"],
  channel: "stable", // or allow "nightly"
})

RustfmtConfigExists

Require rustfmt.toml for consistent formatting:

makePolicy(RustfmtConfigExists, {
  requiredSettings: {
    edition: "2021",
  },
})

CrateStructureValid

Validate crate structure matches Cargo.toml:

  • If src/lib.rs exists, validate it's configured as a library
  • If src/main.rs exists, validate binary configuration
  • Ensure [[bin]] entries have corresponding files

CargoLockPolicy

Context-aware Cargo.lock validation:

makePolicy(CargoLockPolicy, {
  binaries: "require",    // Binaries should commit Cargo.lock
  libraries: "warn",      // Libraries typically shouldn't
})

NoTargetArtifacts

Prevent accidental commits of build artifacts:

  • Detect .rlib, .rmeta, .d, .so, .dylib files outside /target/
  • Could extend NoLargeBinaryFiles or be standalone

Use Case

Ensuring Rust projects follow best practices for reproducible builds and proper crate organization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions