mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
Merge pull request #11303 from NixOS/always-quick-build
Use nixosTest.quickBuild behavior by default
This commit is contained in:
commit
15a2457607
3 changed files with 12 additions and 56 deletions
|
@ -276,14 +276,12 @@ To ensure that characterisation testing doesn't make it harder to intentionally
|
|||
We run the functional tests not just in the build, but also in VM tests.
|
||||
This helps us ensure that Nix works correctly on NixOS, and environments that have similar characteristics that are hard to reproduce in a build environment.
|
||||
|
||||
The recommended way to run these tests during development is:
|
||||
These can be run with:
|
||||
|
||||
```shell
|
||||
nix build .#hydraJobs.tests.functional_user.quickBuild
|
||||
nix build .#hydraJobs.tests.functional_user
|
||||
```
|
||||
|
||||
The `quickBuild` attribute configures the test to use a `nix` package that's built without integration tests, so that you can iterate on the tests without performing recompilations due to the changed sources for `installCheck`.
|
||||
|
||||
Generally, this build is sufficient, but in nightly or CI we also test the attributes `functional_root` and `functional_trusted`, in which the test suite is run with different levels of authorization.
|
||||
|
||||
## Integration tests
|
||||
|
@ -294,8 +292,6 @@ Because these tests are expensive and require more than what the standard github
|
|||
|
||||
You can run them manually with `nix build .#hydraJobs.tests.{testName}` or `nix-build -A hydraJobs.tests.{testName}`.
|
||||
|
||||
If you are testing a build of `nix` that you haven't compiled yet, you may iterate faster by appending the `quickBuild` attribute: `nix build .#hydraJobs.tests.{testName}.quickBuild`.
|
||||
|
||||
## Installer tests
|
||||
|
||||
After a one-time setup, the Nix repository's GitHub Actions continuous integration (CI) workflow can test the installer each time you push to a branch.
|
||||
|
|
|
@ -4,20 +4,24 @@ let
|
|||
|
||||
nixos-lib = import (nixpkgs + "/nixos/lib") { };
|
||||
|
||||
noTests = pkg: pkg.overrideAttrs (
|
||||
finalAttrs: prevAttrs: {
|
||||
doCheck = false;
|
||||
doInstallCheck = false;
|
||||
});
|
||||
|
||||
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
||||
runNixOSTestFor = system: test:
|
||||
(nixos-lib.runTest {
|
||||
imports = [
|
||||
test
|
||||
|
||||
# Add the quickBuild attribute to the check packages
|
||||
./quick-build.nix
|
||||
];
|
||||
|
||||
hostPkgs = nixpkgsFor.${system}.native;
|
||||
defaults = {
|
||||
nixpkgs.pkgs = nixpkgsFor.${system}.native;
|
||||
nix.checkAllErrors = false;
|
||||
nix.package = noTests nixpkgsFor.${system}.native.nix;
|
||||
};
|
||||
_module.args.nixpkgs = nixpkgs;
|
||||
_module.args.system = system;
|
||||
|
@ -29,6 +33,9 @@ let
|
|||
forNix = nixVersion: runNixOSTestFor system {
|
||||
imports = [test];
|
||||
defaults.nixpkgs.overlays = [(curr: prev: {
|
||||
# NOTE: noTests pkg might not have been built yet for some older versions of the package
|
||||
# and in versions before 2.25, the untested build wasn't shared with the tested build yet
|
||||
# Add noTests here when those versions become irrelevant.
|
||||
nix = (builtins.getFlake "nix/${nixVersion}").packages.${system}.nix;
|
||||
})];
|
||||
};
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
test@{ lib, extendModules, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
quickBuild = mkOption {
|
||||
description = ''
|
||||
Whether to perform a "quick" build of the Nix package to test.
|
||||
|
||||
When iterating on the functional tests, it's recommended to "set" this
|
||||
to `true`, so that changes to the functional tests don't require any
|
||||
recompilation of the package.
|
||||
You can do so by building the `.quickBuild` attribute on the check package,
|
||||
e.g:
|
||||
```console
|
||||
nix build .#hydraJobs.functional_user.quickBuild
|
||||
```
|
||||
|
||||
We don't enable this by default to avoid the mostly unnecessary work of
|
||||
performing an additional build of the package in cases where we build
|
||||
the package normally anyway, such as in our pre-merge CI.
|
||||
'';
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
passthru.quickBuild =
|
||||
let withQuickBuild = extendModules { modules = [{ quickBuild = true; }]; };
|
||||
in withQuickBuild.config.test;
|
||||
|
||||
defaults = { pkgs, ... }: {
|
||||
config = lib.mkIf test.config.quickBuild {
|
||||
nix.package = pkgs.nixComponents.nix-cli;
|
||||
|
||||
system.forbiddenDependenciesRegexes = [
|
||||
# This would indicate that the quickBuild feature is broken.
|
||||
# It could happen if NixOS has a dependency on pkgs.nix instead of
|
||||
# config.nix.package somewhere.
|
||||
(builtins.unsafeDiscardStringContext pkgs.nix.outPath)
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue