Skip to content

Commit

Permalink
feat: update flake and integration testing (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikreinert authored Jul 16, 2024
1 parent 1b2ca8d commit a162fda
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 286 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
62 changes: 62 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: integration

on:
push:
branches:
- main
pull_request:

env:
CACHIX_BINARY_CACHE: altf4llc-os

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: ${{ env.CACHIX_BINARY_CACHE }}
- uses: actions/checkout@v4
- run: nix develop -c just check

build:
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
profile:
- default
- neovim
steps:
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: ${{ env.CACHIX_BINARY_CACHE }}
- uses: actions/checkout@v4
- run: nix develop -c just build "${{ matrix.profile }}"

test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
suite:
- lint
- unit
steps:
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: ${{ env.CACHIX_BINARY_CACHE }}
- uses: actions/checkout@v4
- run: nix develop -c just test-${{ matrix.suite }}
28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.direnv

# Compiled Lua sources
luac.out

Expand Down
20 changes: 20 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- vim: ft=lua tw=80

-- Rerun tests only if their modification time changed.
cache = true

ignore = {
"122", -- Setting a read-only field of a global variable.
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
"631", -- max_line_length, vscode pkg URL is too long
}

-- Global objects defined in the plugin
globals = {
"Config"
}

-- Global objects defined by the C code
read_globals = {
"vim",
}
39 changes: 35 additions & 4 deletions flake.lock

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

92 changes: 53 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
{
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
description = "lspcontainers.nvim";

outputs = { self, nixpkgs }:
let
supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system:
import nixpkgs {
overlays = [ ];
inherit system;
});
in {
packages = forAllSystems (system: {
default = pkgs.${system}.vimUtils.buildVimPluginFrom2Nix {
name = "lspcontainers.nvim";
src = ./.;
};
neovim = pkgs.${system}.neovim.override {
configure = {
customRC = ''
lua << EOF
${(builtins.readFile ./init.lua)};
EOF
'';
packages.main = with pkgs.${system}.vimPlugins; {
start = [
nvim-lspconfig
self.packages.${system}.default
];
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];

perSystem = {
config,
pkgs,
system,
...
}: let
inherit (pkgs) just luajitPackages mkShell neovim vimPlugins vimUtils writeShellApplication;
inherit (luajitPackages) luacheck vusted;
in {
packages = {
default = vimUtils.buildVimPlugin {
name = "lspcontainers.nvim";
src = ./.;
};

neovim = neovim.override {
configure = {
customRC = ''
lua << EOF
${(builtins.readFile ./init.lua)};
EOF
'';
packages.main = with vimPlugins; {
start = [
nvim-lspconfig
config.packages.default
];
};
};
};
};
});

devShells = forAllSystems (system: {
default = pkgs.${system}.mkShellNoCC {
buildInputs = [ self.packages.${system}.neovim ];
devShells = {
default = mkShell {
nativeBuildInputs = [just luacheck vusted];
};
};
});

apps = forAllSystems (system: {
neovim = {
program = "${self.packages.${system}.neovim}/bin/nvim";
type = "app";
apps = {
neovim = {
program = "${config.packages.neovim}/bin/nvim";
type = "app";
};

test = {
program = "${config.packages.test}/bin/test";
type = "app";
};
};
});
};
};
}
19 changes: 19 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
_default:
just --list

build profile="default":
nix build --json --no-link --print-build-logs ".#{{ profile }}"

check:
nix flake check

test: test-lint test-unit

test-lint:
luacheck ./lua ./test

test-unit:
#!/usr/bin/env bash
set -euxo pipefail
export VUSTED_NVIM=$(just build 'neovim' | jq -r '.[].outputs.out')/bin/nvim
vusted ./test
Loading

0 comments on commit a162fda

Please sign in to comment.