Added test for template and fixed check export for lib (#361)

This commit is contained in:
Alexander Nortung 2023-05-15 11:04:52 +02:00 committed by GitHub
parent ecaf80b7fd
commit 3600698aba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 9 deletions

View file

@ -12,3 +12,4 @@ jobs:
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix flake check
- run: nix flake check ./templates/_wrapper/simple

View file

@ -163,6 +163,7 @@
lib = import ./lib {
inherit pkgs;
inherit (pkgs) lib;
makeNixvim = self.legacyPackages."${system}".makeNixvim;
};
});
in

View file

@ -1,6 +1,12 @@
# Args probably only needs pkgs and lib
args: {
{
makeNixvim,
pkgs,
...
} @ args: {
# Add all exported modules here
check = import ./check.nix args;
check = import ../tests/test-derivation.nix {
inherit makeNixvim pkgs;
};
helpers = import ./helpers.nix args;
}

View file

@ -0,0 +1,9 @@
# templates/_wrapper
This directory contains wrapper flakes for the nixvim templates.
The purpose of the wrappers is to be able to run tests on templates deterministically on the branch or PR that is being worked on.
It does this by overwriting the url of nixvim and other dependencies to a path within this repo.
It is also used in the github workflows, so that we can always check if the template is working or not
NOTE: It is important that we do not commit the `flake.lock` files here as that could cause problems with the check once any files are updated outside the wrapper. Also we cannot add `flake.lock` to `.gitignore` since nix will sometimes complain.

View file

@ -0,0 +1,12 @@
{
inputs = {
nixvim.url = "path:../../..";
simple = {
url = "path:../../simple";
inputs.nixvim.follows = "nixvim";
inputs.flake-utils.follows = "nixvim/flake-utils";
};
};
outputs = inputs: inputs.simple;
}

View file

@ -12,10 +12,10 @@
flake-utils,
...
} @ inputs: let
nixvimLib = nixvim.lib;
config = import ./config; # import the module directly
in
flake-utils.lib.eachDefaultSystem (system: let
nixvimLib = nixvim.lib.${system};
pkgs = import nixpkgs {inherit system;};
nixvim' = nixvim.legacyPackages.${system};
nvim = nixvim'.makeNixvimWithModule {
@ -24,8 +24,8 @@
};
in {
checks = {
# Run `nix check .` to verify that your config is not broken
default = nixvim.lib.${system}.check.checkNvim {
# Run `nix flake check .` to verify that your config is not broken
default = nixvimLib.check.mkTestDerivationFromNvim {
inherit nvim;
name = "A nixvim configuration";
};

View file

@ -4,7 +4,8 @@
pkgs,
}: let
fetchTests = import ./fetch-tests.nix;
mkTestDerivation = import ./test-derivation.nix {inherit pkgs makeNixvim;};
test-derivation = import ./test-derivation.nix {inherit pkgs makeNixvim;};
mkTestDerivation = test-derivation.mkTestDerivation;
# List of files containing configurations
testFiles = fetchTests {

View file

@ -7,7 +7,7 @@
mkTestDerivationFromNvim = {
name,
nvim,
dontRun,
dontRun ? false,
...
}:
pkgs.stdenv.mkDerivation {
@ -55,5 +55,6 @@
inherit name nvim;
inherit (testAttributes) dontRun;
};
in
mkTestDerivation
in {
inherit mkTestDerivation mkTestDerivationFromNvim;
}