Skip to content

Commit

Permalink
feat(os): added windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinKennedy committed Jan 25, 2025
1 parent 95a4044 commit 7a3c6c7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .busted
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua;spec/?.lua",
lua = "nlua",
lua = "nvim -u NONE -U NONE -N -i NONE -l",
},
default = {
helper = "./spec/minimal_init.lua",
Expand Down
46 changes: 30 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,54 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
neovim: [v0.10.0, stable, nightly]
luaVersion: ["luajit-openresty"]
include:
- os: "windows-latest"
toolchain: "msvc"
luaVersion: "5.1"
neovim: "v0.10.0"
- os: "windows-latest"
toolchain: "msvc"
luaVersion: "5.1"
neovim: "stable"
- os: "windows-latest"
toolchain: "msvc"
luaVersion: "5.1"
neovim: "nightly"

runs-on: ${{ matrix.os }}
name: "OS: ${{ matrix.os }} - Neovim: ${{ matrix.neovim }}"
name: "OS: ${{ matrix.os }} - Neovim: ${{ matrix.neovim }} - Lua: ${{ matrix.luaVersion }}"

steps:
- name: Checkout
uses: actions/checkout@master

- name: Install A Lua Interpreter
uses: leafo/gh-actions-lua@v10
with:
# Neovim is compiled with LuaJIT so we might as well match. But it
# doesn't look like we can match it exactly.
#
# Reference:
# https://github.com/leafo/gh-actions-lua/issues/49#issuecomment-2295071198
#
luaVersion: "luajit-openresty"

- name: Install Luarocks
uses: leafo/gh-actions-luarocks@v4

- name: Install Neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim }}

- name: Setup MSVC
# the 'luarocks/gh-actions-lua' step requires msvc to build PUC-Rio Lua
# versions on Windows (LuaJIT will be build using MinGW/gcc).
if: ${{ matrix.toolchain == 'msvc' }}
uses: ilammy/msvc-dev-cmd@v1

- name: Install Lua
uses: luarocks/gh-actions-lua@master
with:
luaVersion: "${{ matrix.luaVersion }}"

- name: Install LuaRocks
uses: luarocks/gh-actions-luarocks@v5

# We need this hack until a better solution is available.
#
# Reference: https://github.com/nvim-neorocks/luarocks-tag-release/issues/435
#
- name: Expand The Template Rockspec
uses: ColinKennedy/luarocks-rockspec-expander@v1.0.0
uses: ColinKennedy/luarocks-rockspec-expander@v1.0.1
with:
input: template.rockspec
output: nvim-best-practices-plugin-template-scm-1.rockspec
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ A template repository used to create Neovim plugins.
- [RSS feed support](https://github.com/ColinKennedy/nvim-best-practices-plugin-template/commits/main/doc/news.txt.atom)
- Built-in logging to stdout / files
- Unittests use the full power of native [busted](https://github.com/lunarmodules/busted)
- Automated testing matrix supports 6 Neovim/OS combinations
- Automated testing matrix supports 9 Neovim/OS combinations
- neovim: `[v0.10.0, stable, nightly]`
- os: `[ubuntu-latest, macos-latest]`
- os: `[ubuntu-latest, macos-latest, windows-latest]`
- 100% Lua
- Uses [Semantic Versioning](https://semver.org)
- Integrations
Expand Down
23 changes: 10 additions & 13 deletions spec/plugin_template/plugin_template_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ end

--- Write a log file so we can query its later later.
local function _make_fake_log(path)
configuration.DATA.logging.output_path = path
local logging_configuration = configuration.DATA.logging or {}
---@cast logging_configuration mega.logging.SparseLoggerOptions
logging.set_configuration("plugin_template", logging_configuration)

local file = io.open(path, "w") -- Open the file in write mode

if not file then
Expand Down Expand Up @@ -135,10 +140,6 @@ describe("copy logs API", function()

it("runs with default arguments", function()
local expected = vim.fn.tempname() .. "_copy_logs_default_test.log"
configuration.DATA.logging.output_path = expected
local logging_configuration = configuration.DATA.logging or {}
---@cast logging_configuration mega.logging.SparseLoggerOptions
logging.set_configuration("plugin_template", logging_configuration)
_make_fake_log(expected)

plugin_template.run_copy_logs()
Expand All @@ -153,21 +154,17 @@ describe("copy logs command", function()
after_each(_reset_copy_log)

it("runs with an explicit file path", function()
local path = vim.fn.tempname() .. "copy_logs_test.log"
_make_fake_log(path)
local expected = vim.fn.tempname() .. "_copy_logs_explicit_file_path_test.log"
_make_fake_log(expected)

vim.cmd(string.format('PluginTemplate copy-logs "%s"', path))
vim.cmd(string.format('PluginTemplate copy-logs "%s"', expected))
_wait_for_result()

assert.same({ path }, _DATA)
assert.same({ expected }, _DATA)
end)

it("runs with default arguments", function()
local expected = vim.fn.tempname() .. "_copy_logs_default_test.log"
configuration.DATA.logging.output_path = expected
local logging_configuration = configuration.DATA.logging or {}
---@cast logging_configuration mega.logging.SparseLoggerOptions
logging.set_configuration("plugin_template", logging_configuration)
local expected = vim.fn.tempname() .. "_copy_logs_default_arguments_test.log"
_make_fake_log(expected)

vim.cmd([[PluginTemplate copy-logs]])
Expand Down

0 comments on commit 7a3c6c7

Please sign in to comment.