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

feat: kinda better ci checks? #9

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 6 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ name: Build and test example flake

on:
pull_request:
push:
branches:
- main

jobs:
check-pr:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
- uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix run .#check-local
- run: nix flake check
25 changes: 0 additions & 25 deletions .github/workflows/update-example.yaml

This file was deleted.

36 changes: 15 additions & 21 deletions example/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions example/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
systems = ["x86_64-linux"];
perSystem = {
config,
lib,
pkgs,
...
}: {
Expand All @@ -38,6 +39,11 @@
plugins = {
example = {
src = ./example;
init = ''
function()
vim.g.loaded_example_init = true
end
'';
config = ./example.lua;
lazy = false;
priority = 1000;
Expand All @@ -59,16 +65,9 @@
};
};

packages = {
default = config.neovim.final;
test = pkgs.writeShellApplication {
name = "neovim-nix-spec";
runtimeInputs = [config.neovim.final];
text = ''
nvim --headless -c "PlenaryBustedDirectory ${./.}/spec { init = '${config.neovim.build.initlua}' }"
'';
};
};
checks = config.packages.ci;

packages.default = config.neovim.final;
};
};
}
4 changes: 4 additions & 0 deletions example/spec/features_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ describe("neovim", function()
assert.is_table(require "plenary")
end)

it("(init) configures plugins", function()
assert.is_true(vim.g.loaded_example_init)
end)

it("(config) configures plugins", function()
assert.is_true(vim.g.loaded_example)
end)
Expand Down
40 changes: 31 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 25 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
example = {
url = "path:./example";
inputs = {
flake-parts.follows = "flake-parts";
neovim-nix.follows = "/";
nixpkgs.follows = "nixpkgs";
};
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand All @@ -29,27 +37,30 @@
perSystem = {
config,
inputs',
lib,
pkgs,
system,
...
}:
{
apps = {
check.program = pkgs.writeShellApplication {
name = "check";
text = ''
nix run ./example#test
'';
};
check-local.program = pkgs.writeShellApplication {
name = "check-local";
text = ''
nix run --override-input neovim-nix path:./. ./example#test
'';
};
checks.ci = pkgs.stdenvNoCC.mkDerivation {
name = "neovim-nix-ci";
dontUnpack = true;
dontPatch = true;
dontConfigure = true;
dontBuild = true;
doCheck = true;
checkPhase = let
pkg = config.packages.example;
in ''
HOME=$TMP ${lib.getExe pkg} --headless -n -c "PlenaryBustedDirectory ${./example/spec} { init = '${pkg.initlua}' }"
'';
installPhase = ''
touch $out
'';
};

formatter = pkgs.alejandra;
packages.example = inputs'.example.packages.default;
}
// inputs.nixpkgs.lib.optionalAttrs (inputs.git-hooks ? flakeModule) {
devShells.default = pkgs.mkShell {
Expand Down
Loading