Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Nix flake checks in test mode #5491

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[profile.ci]
slow-timeout = { period = "5s", terminate-after = 20 }
fail-fast = false
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ jobs:
run: cargo build --workspace --all-targets --verbose ${{ matrix.cargo_flags }}
- name: Test
run: |
cargo nextest run --workspace --all-targets --verbose ${{ matrix.cargo_flags }}
cargo nextest run --workspace --profile ci --all-targets --verbose ${{ matrix.cargo_flags }}
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
53 changes: 36 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -40,13 +40,26 @@
pkgs.lib.all (re: builtins.match re relPath == null) regexes;
};

ourRustVersion = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);

ourRustPlatform = pkgs.makeRustPlatform {
rustc = ourRustVersion;
cargo = ourRustVersion;
# When we're running in the shell, we want to use rustc with a bunch
# of extra junk to ensure that rust-analyzer works, clippy etc are all
# installed.
rustShellToolchain = (pkgs.rust-bin.selectLatestNightlyWith (t: t.default)).override {
# NOTE (aseipp): explicitly add rust-src to the rustc compiler only in
# devShell. this in turn causes a dependency on the rust compiler src,
# which bloats the closure size by several GiB. but doing this here and
# not by default avoids the default flake install from including that
# dependency, so it's worth it
#
# relevant PR: https://github.com/rust-lang/rust/pull/129687
extensions = ["rust-src" "rust-analyzer"];
};

# But, whenever we are running CI builds or checks, we want to use a
# smaller closure. This reduces the CI impact on fresh clones/VMs, etc.
rustMinimalPlatform =
let platform = pkgs.rust-bin.selectLatestNightlyWith (t: t.minimal);
in pkgs.makeRustPlatform { rustc = platform; cargo = platform; };

nativeBuildInputs = with pkgs;
[
gzip
@@ -87,16 +100,16 @@
};
in {
formatter = pkgs.alejandra;
checks.jujutsu = self.packages.${system}.jujutsu;

packages = {
jujutsu = ourRustPlatform.buildRustPackage {
jujutsu = rustMinimalPlatform.buildRustPackage {
pname = "jujutsu";
version = "unstable-${self.shortRev or "dirty"}";

buildFeatures = ["packaging"];
cargoBuildFlags = ["--bin" "jj"]; # don't build and install the fake editors
useNextest = true;
cargoTestFlags = ["--profile" "ci"];
src = filterSrc ./. [
".*\\.nix$"
"^.jj/"
@@ -136,18 +149,24 @@
default = self.packages.${system}.jujutsu;
};

checks.jujutsu = self.packages.${system}.jujutsu.overrideAttrs ({...}: {
# The default Rust infrastructure runs all builds in the release
# profile, which is significantly slower. Run this under the `test`
# profile instead, which matches all our other CI systems, Cargo, etc.
cargoBuildType = "test";
cargoCheckType = "test";

# By default, `flake check` will want to run the install phase, but
# because we override the cargoBuildType, it fails to find the proper
# binary. But we don't even care about the binary or even the buildPhase
# in this case; just remove them both.
buildPhase = "true";
installPhase = "touch $out";
thoughtpolice marked this conversation as resolved.
Show resolved Hide resolved
});

devShells.default = let
packages = with pkgs; [
# NOTE (aseipp): explicitly add rust-src to the rustc compiler only in
# devShell. this in turn causes a dependency on the rust compiler src,
# which bloats the closure size by several GiB. but doing this here
# and not by default avoids the default flake install from including
# that dependency, so it's worth it
#
# relevant PR: https://github.com/rust-lang/rust/pull/129687
(ourRustVersion.override {
extensions = ["rust-src" "rust-analyzer"];
})
rustShellToolchain

# Additional tools recommended by contributing.md
bacon