From 7a3c6c794712883399626d3177b6ce93cf0252a4 Mon Sep 17 00:00:00 2001 From: Colin Kennedy Date: Fri, 24 Jan 2025 08:37:36 -0800 Subject: [PATCH] feat(os): added windows support --- .busted | 2 +- .github/workflows/test.yml | 46 ++++++++++++------- README.md | 4 +- spec/plugin_template/plugin_template_spec.lua | 23 ++++------ 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/.busted b/.busted index c4123049..8af367a8 100644 --- a/.busted +++ b/.busted @@ -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", diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 10a3da3b..3bfb641d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index 27d868ba..0f67c355 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/spec/plugin_template/plugin_template_spec.lua b/spec/plugin_template/plugin_template_spec.lua index e8262a6a..6611a923 100644 --- a/spec/plugin_template/plugin_template_spec.lua +++ b/spec/plugin_template/plugin_template_spec.lua @@ -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 @@ -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() @@ -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]])