From d454efa5550ea9d70ddb059e9500e9e2b7f89d44 Mon Sep 17 00:00:00 2001 From: Jonathan Apodaca Date: Mon, 19 May 2025 16:33:40 -0600 Subject: [PATCH] Use nix for testing environment --- .busted | 13 +++++++++++++ .github/workflows/ci.yaml | 21 +++++++++++++++------ Makefile | 16 +++++++--------- shell.nix | 19 +++++++++++++++++++ 4 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 .busted create mode 100644 shell.nix diff --git a/.busted b/.busted new file mode 100644 index 0000000..8c64018 --- /dev/null +++ b/.busted @@ -0,0 +1,13 @@ +return { + _all = { + coverage = false, + lpath = "lua/?.lua;lua/?/init.lua", + lua = "nlua", + }, + default = { + verbose = true + }, + tests = { + verbose = true + }, +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ef4ab02..33ad587 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,15 +2,24 @@ name: NeoVim tests on: [push] jobs: - plenary-tests: + code-quality: runs-on: ubuntu-latest env: XDG_CONFIG_HOME: ${{ github.workspace }}/.config/ steps: - uses: actions/checkout@v4 - - uses: rhysd/action-setup-vim@v1 + - uses: cachix/install-nix-action@v31 with: - neovim: true - version: v0.11.0 - arch: 'x86_64' - - run: make test + nix_path: nixpkgs=channel:nixos-unstable + + - name: Type-check with lua-language-server + run: + nix-shell --run 'make lint' + + - name: Check formatting with stylua + run: + nix-shell --run 'make fmt-check' + + - name: Run busted tests + run: + nix-shell --run 'make test' diff --git a/Makefile b/Makefile index fe9d0eb..f1934b3 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,14 @@ -PLENARY_DIR=~/.local/share/nvim/site/pack/test/opt/plenary.nvim - -all: lint test +all: lint fmt-check test lint: lua-language-server --check=lua/u/ --checklevel=Error - lx check + @# lx check + +fmt-check: + stylua --check . fmt: stylua . -test: $(PLENARY_DIR) - NVIM_APPNAME=noplugstest nvim -u NORC --headless -c 'set packpath+=~/.local/share/nvim/site' -c 'packadd plenary.nvim' -c "PlenaryBustedDirectory spec/" - -$(PLENARY_DIR): - git clone https://github.com/nvim-lua/plenary.nvim/ $(PLENARY_DIR) +test: + busted diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..222223f --- /dev/null +++ b/shell.nix @@ -0,0 +1,19 @@ +{ + pkgs ? import (fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; + # neovim@0.11.1: + sha256 = "171wlwhw8sqkc6p1nzhs6rl1c4zhvlv2w4xrdp7h7sj9v6g9k8qr"; + }) { }, +}: +pkgs.mkShell { + packages = [ + pkgs.git + pkgs.gnumake + pkgs.lua-language-server + pkgs.lua51Packages.busted + pkgs.lua51Packages.luarocks + pkgs.lua51Packages.nlua + pkgs.neovim + pkgs.stylua + ]; +}