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

Run Clippy in CI #225

Merged
merged 5 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
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
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ ifneq ($(C),)
cores_args := --cores $(C)
endif

CLIPPY ?= 1

ifeq ($(CLIPPY),1)
nix_clippy_attr_prefix := withClippy.
endif

nix_args := $(keep_going_args) $(jobs_args) $(cores_args)

append_to_nix_config := NIX_CONFIG="$$(printf "%s\n" "$$NIX_CONFIG" && cat hacking/binary-cache/fragment.nix.conf)"
Expand Down Expand Up @@ -98,7 +104,7 @@ try_restore_terminal := tput smam 2> /dev/null || true

.PHONY: run-tests
run-tests:
script=$$($(nix_build) -A runTests --no-out-link) && $$script
script=$$($(nix_build) -A $(nix_clippy_attr_prefix)runTests --no-out-link) && $$script
$(try_restore_terminal)

.PHONY: run-sel4test-for
Expand All @@ -109,17 +115,17 @@ run-sel4test-for:

.PHONY: run-fast-tests
run-fast-tests:
script=$$($(nix_build) -A runFastTests --no-out-link) && $$script
script=$$($(nix_build) -A $(nix_clippy_attr_prefix)runFastTests --no-out-link) && $$script
$(try_restore_terminal)

.PHONY: witness-tests
witness-tests:
$(nix_build) -A witnessTests --no-out-link
$(nix_build) -A $(nix_clippy_attr_prefix)witnessTests --no-out-link
$(try_restore_terminal)

.PHONY: witness-fast-tests
witness-fast-tests:
$(nix_build) -A witnessFastTests --no-out-link
$(nix_build) -A $(nix_clippy_attr_prefix)witnessFastTests --no-out-link
$(try_restore_terminal)

.PHONY: check-kani-proofs
Expand All @@ -134,23 +140,23 @@ check-kani-proofs:

.PHONY: everything-except-non-incremental
everything-except-non-incremental:
$(nix_build) -A everythingExceptNonIncremental --no-out-link
$(nix_build) -A $(nix_clippy_attr_prefix)everythingExceptNonIncremental --no-out-link

.PHONY: everything
everything:
$(nix_build) -A everything --no-out-link
$(nix_build) -A $(nix_clippy_attr_prefix)everything --no-out-link

.PHONY: everything-with-excess
everything-with-excess:
$(nix_build) -A everythingWithExcess --no-out-link
$(nix_build) -A $(nix_clippy_attr_prefix)everythingWithExcess --no-out-link

.PHONY: html-links
html-links:
$(nix_build) -A html -o $(out)/$@
$(nix_build) -A $(nix_clippy_attr_prefix)html -o $(out)/$@

.PHONY: html
html: | $(out)
src=$$($(nix_build) -A html --no-out-link) && \
src=$$($(nix_build) -A $(nix_clippy_attr_prefix)html --no-out-link) && \
dst=$(out)/html && \
rm -rf $$dst && \
cp -rL --no-preserve=owner,mode $$src $$dst
Expand Down
41 changes: 13 additions & 28 deletions hacking/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ let

treeHelpers = import ./tree-helpers.nix { inherit lib; };

makeOverridableWith = f: g: x: (g x) // {
makeOverridableWith = f: g: x: lib.fix (self: (g self x) // {
override = x': makeOverridableWith f g (f x' x);
};
});

crossSystems =
with treeHelpers;
Expand Down Expand Up @@ -157,35 +157,20 @@ let
(import ./overlay)
];
};
attrs = {};
};

mkThis =
with treeHelpers;
args: lib.fix (self:
let
concreteArgs = args self;
pkgs = untree (mapLeaves (crossSystem:
nixpkgsFn (concreteArgs.nixpkgsArgsFor crossSystem)
) crossSystems);
in {
inherit lib pkgs;
} // import ./top-level self);
mkThis = self: args:
let
concreteArgs = args self;
pkgs = treeHelpers.untree (treeHelpers.mapLeaves (crossSystem:
nixpkgsFn (concreteArgs.nixpkgsArgsFor crossSystem)
) crossSystems);
in {
inherit lib pkgs;
} // import ./top-level self // concreteArgs.attrs;

this = lib.fix (self: makeOverridableWith lib.id mkThis baseArgs // rec {
overrideNixpkgsArgs = f: self.override (superArgs: selfBase:
let
concreteSuperArgs = superArgs selfBase;
in
concreteSuperArgs // {
nixpkgsArgsFor = crossSystem: f (concreteSuperArgs.nixpkgsArgsFor crossSystem);
}
);
withOverlays = overlays: self.overrideNixpkgsArgs (superNixpkgsArgs:
superNixpkgsArgs // {
overlays = superNixpkgsArgs.overlays ++ overlays;
}
);
});
this = makeOverridableWith lib.id mkThis baseArgs;

in
this
11 changes: 5 additions & 6 deletions hacking/nix/rust-utils/build-crates-in-layers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
, vendorLockfile, pruneLockfile
, defaultRustEnvironment, defaultRustTargetTriple
, verus
, scopeConfig
}:

let
defaultStdenv = stdenv;
in

let
inherit (scopeConfig) runClippyDefault;

# TODO not actually resulting in errors
denyWarningsDefault =
# true
false
;

runClippyDefault =
# true
false
;

in

{ stdenv ? defaultStdenv
Expand Down
15 changes: 15 additions & 0 deletions hacking/nix/scope/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,25 @@ let
fenix = import fenixSource {};
in

let
elaborateScopeConfig =
{ runClippyDefault ? false
}:
{
inherit
runClippyDefault
;
};
in

superCallPackage ../rust-utils {} self //

(with self; {

overridableScopeConfig = {};

scopeConfig = elaborateScopeConfig overridableScopeConfig;

sources = callPackage ./sources.nix {};

seL4Arch = with hostPlatform;
Expand Down
26 changes: 26 additions & 0 deletions hacking/nix/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@ let
aggregate = name: drvs: pkgs.build.writeText "aggregate-${name}" (toString (lib.flatten drvs));

in {
overrideNixpkgsArgs = f: self.override (superArgs: selfBase:
let
concreteSuperArgs = superArgs selfBase;
in
concreteSuperArgs // {
nixpkgsArgsFor = crossSystem: f (concreteSuperArgs.nixpkgsArgsFor crossSystem);
}
);

withOverlays = overlays: self.overrideNixpkgsArgs (superNixpkgsArgs:
superNixpkgsArgs // {
overlays = superNixpkgsArgs.overlays ++ overlays;
}
);

withConfigOverride = f: self.withOverlays [
(self': super': {
this = super'.this.overrideScope (self'': super'': {
overridableScopeConfig = f super''.overridableScopeConfig;
});
})
];

withClippy = self.withConfigOverride (super: super // {
runClippyDefault = true;
});

inherit (pkgs.build.this) shellForMakefile shellForHacking;

Expand Down
Loading