Skip to content

Commit

Permalink
feat(ci): Added better GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinKennedy committed Oct 26, 2024
1 parent 08b9a9c commit da48f5a
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reference: https://commitlint.js.org/guides/ci-setup
name: lintcommit
name: Commitlint

on: [pull_request]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: documentation
name: Documentation

on:
push:
Expand All @@ -7,6 +7,7 @@ on:

jobs:
documentation:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down Expand Up @@ -41,4 +42,3 @@ jobs:
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

2 changes: 1 addition & 1 deletion .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: luacheck
name: Luacheck

on:
pull_request: {}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/news.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reference: https://github.com/neovim/neovim/blob/9762c5e3406cab8152d8dd161c0178965d841676/.github/workflows/news.yml
name: "news.txt"
name: Check news.txt

on:
pull_request:
Expand All @@ -9,6 +9,7 @@ on:

jobs:
check:
name: Check news.txt
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci:skip-news')
steps:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TODO: (you) - To enable this worflow, you must create a "Personal Access Token".
#
# Reference: https://github.com/nvim-neorocks/sample-luarocks-plugin?tab=readme-ov-file#generating-a-pat-personal-access-token
#
name: Release To GitHub

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release:
name: Release To GitHub
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
release-type: simple
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# TODO: (you) - To enable this workflow, you need to provide a LUAROCKS_API_KEY
#
# Reference: https://github.com/ellisonleao/nvim-plugin-template/blob/922c0d5249076416c5d84e7c0504f1154225a7ab/.github/workflows/release.yml
name: release
#
name: Release To LuaRocks

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stylua.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: stylua
name: StyLua

on:
pull_request:
Expand All @@ -10,7 +10,7 @@ on:

jobs:
stylua:
name: stylua
name: StyLua
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: Test

on:
pull_request:
Expand Down
10 changes: 5 additions & 5 deletions lua/plugin_template/_vendors/vlog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local default_config = {
},

-- Define this path to redirect the log file to wherever you need it to go
outfile = nil,
output_path = nil,

-- Can limit the number of decimals displayed for floats
float_precision = 0.01,
Expand Down Expand Up @@ -67,7 +67,7 @@ log.new = function(config, standalone)

obj._is_logging_to_file_enabled = config.use_file

obj._outfile = config.outfile
obj._output_path = config.output_path
or vim.fs.joinpath(vim.api.nvim_call_function("stdpath", { "data" }), string.format("%s.log", config.plugin))

local levels = {}
Expand Down Expand Up @@ -130,10 +130,10 @@ log.new = function(config, standalone)

-- Output to log file
if obj._is_logging_to_file_enabled then
local fp = io.open(obj._outfile, "a")
local fp = io.open(obj._output_path, "a")

if not fp then
vim.notify(string.format('Unable to log to "%s" path.', obj._outfile), vim.log.levels.ERROR)
vim.notify(string.format('Unable to log to "%s" path.', obj._output_path), vim.log.levels.ERROR)
else
local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg)
fp:write(str)
Expand Down Expand Up @@ -169,7 +169,7 @@ log.new = function(config, standalone)
end

obj["get_log_path"] = function()
return obj._outfile
return obj._output_path
end

obj["toggle_file_logging"] = function()
Expand Down
2 changes: 2 additions & 0 deletions lua/plugin_template/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
--- spammy. You probably don't want to enable this unless you have to.
---@field use_file boolean?
--- Should write to a file.
---@field output_path string?
--- The default path on-disk where log files will be written to.

---@class plugin_template.ConfigurationGoodnightMoonRead
--- The default values when a user calls `:PluginTemplate goodnight-moon read`.
Expand Down
29 changes: 19 additions & 10 deletions plugin-template-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
rockspec_format = '3.0'
package = 'plugin-template'
version = 'scm-1'
rockspec_format = "3.0"
package = "plugin-template"
version = "scm-1"

local user = "ColinKennedy"

description = {
homepage = "https://github.com/" .. user .. "/" .. package,
labels = { "neovim", "neovim-plugin" },
license = "MIT",
summary = 'A "Best Practices" Neovim plugin template',
}

test_dependencies = {
'busted >= 2.0, < 3.0',
'lua >= 5.1, < 6.0',
'nlua >= 0.2, < 1.0',
'nui.nvim >= 0.2, < 1.0',
"busted >= 2.0, < 3.0",
"lua >= 5.1, < 6.0",
"nlua >= 0.2, < 1.0",
"nui.nvim >= 0.2, < 1.0",
}

-- Reference: https://github.com/luarocks/luarocks/wiki/test#test-types
test = {
type = "busted",
flags = {"--helper", "spec/minimal_init.lua"},
flags = { "--helper", "spec/minimal_init.lua" },
}

source = {
url = 'git://github.com/ColinKennedy/' .. package,
url = "git://github.com/" .. user .. "/" .. package,
}

build = {
type = 'builtin',
type = "builtin",
}
4 changes: 2 additions & 2 deletions spec/plugin_template/plugin_template_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("copy logs API", function()

it("runs with default arguments", function()
local expected = vim.fn.tempname() .. "copy_logs_default_test.log"
configuration.DATA.logging.outfile = expected
configuration.DATA.logging.output_path = expected
vlog.new(configuration.DATA.logging or {}, true)
_make_fake_log(expected)

Expand All @@ -162,7 +162,7 @@ describe("copy logs command", function()

it("runs with default arguments", function()
local expected = vim.fn.tempname() .. "copy_logs_default_test.log"
configuration.DATA.logging.outfile = expected
configuration.DATA.logging.output_path = expected
vlog.new(configuration.DATA.logging or {}, true)
_make_fake_log(expected)

Expand Down

0 comments on commit da48f5a

Please sign in to comment.