Skip to content

Commit

Permalink
ci: add integration tests and break out other checks to separate work…
Browse files Browse the repository at this point in the history
…flow
  • Loading branch information
vhyrro committed May 25, 2024
1 parent 64dfe51 commit 2f4c97e
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 3 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Codebase Checks"

# This workflow runs various checks (type checking, code checks)
# to ensure that Neorg is not breaking.

on:
push:
pull_request:
workflow_dispatch:

jobs:
integration-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v10
- name: Run Checks
run: nix flake check
4 changes: 2 additions & 2 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Nix-based Integration Test"

# This workflow attempts to install Neorg with a kickstart config on all major OSes.
# Uses Nix + devenv for convenience.
# Uses Nix for reproducability.

on:
push:
Expand All @@ -22,4 +22,4 @@ jobs:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v10
- name: Run Checks
run: nix flake check
run: nix run .#integration-test
99 changes: 98 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# General TODOS:
# - Extract into modules for better readability
# - Readd integration tests
# - Add comments explaining the more terse parts of the flake.
{
description = "Flake for Neorg development and testing";
Expand Down Expand Up @@ -91,6 +90,104 @@
};
};

packages.integration-test = let
kickstart-config =
pkgs.writeScript "kickstart.lua"
''
-- Adapted from https://github.com/folke/lazy.nvim#-installation
-- Install lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Set up both the traditional leader (for keymaps) as well as the local leader (for norg files)
vim.g.mapleader = " "
vim.g.maplocalleader = ","
require("lazy").setup({
{
"rebelot/kanagawa.nvim", -- neorg needs a colorscheme with treesitter support
config = function()
vim.cmd.colorscheme("kanagawa")
end,
},
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
opts = {
ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },
highlight = { enable = true },
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
},
{
"vhyrro/luarocks.nvim",
priority = 1000,
config = true,
},
{
"nvim-neorg/neorg",
dependencies = { "luarocks.nvim" },
config = function()
require("neorg").setup {
load = {
["core.defaults"] = {},
["core.concealer"] = {},
["core.dirman"] = {
config = {
workspaces = {
notes = "~/notes",
},
default_workspace = "notes",
},
},
},
}
vim.cmd.e("success")
vim.wo.foldlevel = 99
vim.wo.conceallevel = 2
end,
}
})
'';
in
pkgs.writeShellApplication {
name = "neorg-integration-test";

runtimeInputs = with pkgs; [neovim-unwrapped tree-sitter lua5_1 wget kickstart-config];

text = ''
export NVIM_APPNAME="nvim-neorg"
echo "* Hello World!" > example.norg
nvim --headless -u ${kickstart-config} example.norg -c wq
rm example.norg
if [ ! -f success ]; then
echo "Integration test failed!"
exit 1
fi
rm success
'';
};

devShells.default = pkgs.mkShell {
name = "neorg devShell";

Expand Down

0 comments on commit 2f4c97e

Please sign in to comment.