Skip to content

Shared nix checks - #7

Open
Mshehu5 wants to merge 1 commit into
commit-validationfrom
shared-nix-checks
Open

Mshehu5 wants to merge 1 commit into
commit-validationfrom
shared-nix-checks

Conversation

@Mshehu5

@Mshehu5 Mshehu5 commented Oct 15, 2026

Copy link
Copy Markdown

Adds a reusable flake-parts module so Fungi repositories can share build, lint, test, coverage, and mutation checks instead of maintaining separate copies.
Adds two negative patch checks:

  • Cargo Shear must reject an unused dependency.
  • Cargo Sort must reject dependencies in the wrong order.
    Nix applies each patch to a separate source copy. testBuildFailure' verifies the expected exit code and error message. The working checkout stays unchanged.

Related to fungi-protocol/fungi#24.

Please reviewrs state the exact nix checks that should be added and also wwhould workflows be added or any neccessary CI work that is shared across all fungi repos a

Export shared Rust checks as a flake-parts module. Add Cargo Shear
and Cargo Sort patch fixtures whose expected failures are asserted
by Nix.
@Mshehu5
Mshehu5 changed the base branch from main to commit-validation October 15, 2026 22:51
Comment thread nix/checks/coverage.nix
pkgs.cargo-nextest
];
buildPhaseCargoCommand = ''
cargo llvm-cov nextest --workspace --no-report --remap-path-prefix

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo llvm-cov nextest aborts with "failed to find llvm-tools-preview, please install llvm-tools-preview, or set LLVM_COV and LLVM_PROFDATA environment variables": the repo toolchain is rust-bin.stable.latest.default (no llvm-tools component), coverage.nix sets neither env var nor adds pkgs.llvm, and the Nix sandbox has no rustup for cargo-llvm-cov's fallback, so checks.coverage cannot build at all.

Comment thread nix/checks/coverage.nix
checks.coverage = pkgs.runCommand "coverage" { nativeBuildInputs = [ pkgs.lcov ]; } ''
mkdir -p "$out"
cp ${collection}/coverage.lcov "$out/coverage.lcov"
lcov --summary "$out/coverage.lcov" --fail-under-lines 100

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lcov --summary --fail-under-lines 100 requires 100% line coverage, but the collected tracefile falls short of it: tests/cli.rs spawns the binary with env_clear(), dropping LLVM_PROFILE_FILE so the children's profiles are lost before cargo llvm-cov report merges them, and the check fails even when llvm-tools are available.

Comment thread nix/checks/mutants.nix
pkgs.cargo-mutants
pkgs.cargo-nextest
];
buildPhaseCargoCommand = "cargo mutants --workspace --in-place --test-tool nextest";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo mutants --workspace --in-place --test-tool nextest leaves match-guard and operator mutants in resolve_commits/add_revision in src/history.rs surviving the test suite, so cargo-mutants exits non-zero and the checks.mutants buildPhase fails.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, is the per-commit diff from cpsbt#21 planned on top of this?

Comment thread flake.nix
"aarch64-linux"
"x86_64-linux"
];
flake.flakeModules.checks = import ./nix/checks;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake.flakeModules.checks is only exported, never imported: of the check files, flake.nix's imports pull in only cargo-shear.nix, cargo-sort.nix and negative-tests.nix, so checks.build, checks.tests, checks.doctests, checks.clippy, checks.doc, checks.coverage, checks.mutants and the quick/lint/nightly aggregates never appear in the flake's checks output, and nix flake check — the per-commit validation this repo's CI runs via validate-commits-bootstrap — never evaluates them.

@bc1cindy bc1cindy left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on which checks: #24 already scopes this, the parts that are the same in concurrent-psbt and fungi, or where fungi improves on them

we should extract flake-parts that are already the same between both, or where this repo's version improves upon the concurrent psbt repo, and extract them into a separate repo

could that comparison go in #24, with the PR body saying which ones this extracts?

hartig could be the first consumer

Comment thread nix/checks/mutants.nix
pkgs.cargo-mutants
pkgs.cargo-nextest
];
buildPhaseCargoCommand = "cargo mutants --workspace --in-place --test-tool nextest";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, is the per-commit diff from cpsbt#21 planned on top of this?

Comment thread nix/checks/default.nix
@@ -0,0 +1,13 @@
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fungi runs these per workspace (cargoWorkspaces), while this expects a single one, so fungi couldn't import it as is

@Mshehu5

Mshehu5 commented Oct 21, 2026

Copy link
Copy Markdown
Author

on which checks: fungi#24 already scopes this, the parts that are the same in concurrent-psbt and fungi, or where fungi improves on them

we should extract flake-parts that are already the same between both, or where this repo's version improves upon the concurrent psbt repo, and extract them into a separate repo

could that comparison go in fungi#24, with the PR body saying which ones this extracts?

hartig could be the first consumer

Yes, Hartig is the intened first consumer per talks with yuval on signal
yeah a table would help for comparison

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.

3 participants