-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename gh-actions.nvim to pipeline.nvim
- Loading branch information
Showing
43 changed files
with
363 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[package] | ||
name = 'gh-actions-rust' | ||
name = 'pipeline_native' | ||
version = '0.0.1' | ||
edition = '2021' | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
mlua = {version = "0.10", features = ["luajit", "module", "serialize"]} | ||
mlua = { version = "0.10", features = ["luajit", "module", "serialize"] } | ||
serde = "1.0" | ||
serde_yaml = "0.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
return { | ||
{ 'nvim-lua/plenary.nvim', lazy = true }, | ||
{ 'MunifTanjim/nui.nvim', lazy = true }, | ||
{ 'MunifTanjim/nui.nvim', lazy = true }, | ||
{ | ||
'topaxi/gh-actions.nvim', | ||
cmd = 'GhActions', | ||
'topaxi/pipeline.nvim', | ||
cmd = { 'Pipeline', 'GhActions' }, | ||
lazy = true, | ||
dependencies = { 'nvim-lua/plenary.nvim', 'MunifTanjim/nui.nvim' }, | ||
opts = {}, | ||
config = function(_, opts) | ||
require('pipeline').setup(opts) | ||
end, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,13 @@ | ||
local M = { | ||
init_root = '', | ||
} | ||
local gha = setmetatable({}, { __index = require('pipeline') }) | ||
|
||
---@param opts? pipeline.Config | ||
function M.setup(opts) | ||
opts = opts or {} | ||
---@override | ||
function gha.setup(...) | ||
vim.notify_once( | ||
'topaxi/gh-actions.nvim is deprecated, use topaxi/pipeline.nvim instead', | ||
vim.log.levels.WARN | ||
) | ||
|
||
M.init_root = vim.fn.getcwd() | ||
|
||
require('gh-actions.config').setup(opts) | ||
require('gh-actions.ui').setup() | ||
require('gh-actions.command').setup() | ||
|
||
M.setup_provider() | ||
end | ||
|
||
function M.setup_provider() | ||
if M.pipeline then | ||
return | ||
end | ||
|
||
local config = require('gh-actions.config') | ||
local store = require('gh-actions.store') | ||
|
||
M.pipeline = | ||
require('gh-actions.providers.provider'):new(config.options, store) | ||
for provider, provider_options in pairs(config.options.providers) do | ||
local Provider = require('gh-actions.providers')[provider] | ||
|
||
if Provider.detect() then | ||
M.pipeline = Provider:new(config.options, store, provider_options) | ||
end | ||
end | ||
end | ||
|
||
function M.start_polling() | ||
M.pipeline:listen() | ||
end | ||
|
||
function M.stop_polling() | ||
M.pipeline:close() | ||
end | ||
|
||
local function now() | ||
return os.time() | ||
end | ||
|
||
local WORKFLOW_CONFIG_CACHE_TTL_S = 10 | ||
|
||
---TODO We should run this after fetching the workflows instead of within the state update event | ||
---@param state GhActionsState | ||
function M.update_workflow_configs(state) | ||
local gh_utils = require('gh-actions.providers.github.utils') | ||
local n = now() | ||
|
||
for _, pipeline in ipairs(state.pipelines) do | ||
if | ||
not state.workflow_configs[pipeline.pipeline_id] | ||
or (n - state.workflow_configs[pipeline.pipeline_id].last_read) | ||
> WORKFLOW_CONFIG_CACHE_TTL_S | ||
then | ||
state.workflow_configs[pipeline.pipeline_id] = { | ||
last_read = n, | ||
config = gh_utils.get_workflow_config(pipeline.meta.workflow_path), | ||
} | ||
end | ||
end | ||
end | ||
|
||
---@param pipeline_object pipeline.PipelineObject|nil | ||
local function open_pipeline_url(pipeline_object) | ||
if not pipeline_object then | ||
return | ||
end | ||
|
||
if type(pipeline_object.url) ~= 'string' or pipeline_object.url == '' then | ||
return | ||
end | ||
|
||
require('gh-actions.utils').open(pipeline_object.url) | ||
end | ||
|
||
function M.open() | ||
local ui = require('gh-actions.ui') | ||
local store = require('gh-actions.store') | ||
|
||
ui.open() | ||
ui.split:map('n', 'q', M.close, { noremap = true }) | ||
|
||
ui.split:map('n', 'gp', function() | ||
open_pipeline_url(ui.get_pipeline()) | ||
end, { noremap = true, desc = 'Open pipeline URL' }) | ||
|
||
ui.split:map('n', 'gw', function() | ||
vim.notify( | ||
'Keybind gw to jump to workflow is deprecated, use gp instead', | ||
vim.log.levels.WARN | ||
) | ||
|
||
open_pipeline_url(ui.get_pipeline()) | ||
end, { noremap = true, desc = 'Open pipeline URL (deprecated)' }) | ||
|
||
ui.split:map('n', 'gr', function() | ||
open_pipeline_url(ui.get_run()) | ||
end, { noremap = true, desc = 'Open pipeline run URL' }) | ||
|
||
ui.split:map('n', 'gj', function() | ||
open_pipeline_url(ui.get_job()) | ||
end, { noremap = true, desc = 'Open pipeline job URL' }) | ||
|
||
ui.split:map('n', 'gs', function() | ||
open_pipeline_url(ui.get_step()) | ||
end, { noremap = true, desc = 'Open pipeline step URL' }) | ||
|
||
ui.split:map('n', 'd', function() | ||
M.pipeline:dispatch(ui.get_pipeline()) | ||
end, { noremap = true, desc = 'Dispatch pipeline run' }) | ||
|
||
ui.split:map('n', 'rr', function() | ||
M.pipeline:retry(ui.get_run()) | ||
end, { noremap = true, desc = 'Retry pipeline run' }) | ||
|
||
ui.split:map('n', 'rj', function() | ||
M.pipeline:retry(ui.get_job()) | ||
end, { noremap = true, desc = 'Retry pipeline job' }) | ||
|
||
ui.split:map('n', 'rs', function() | ||
M.pipeline:retry(ui.get_step()) | ||
end, { noremap = true, desc = 'Retry pipeline step' }) | ||
|
||
M.start_polling() | ||
|
||
--TODO: This might get called after rendering.. | ||
store.on_update(M.update_workflow_configs) | ||
end | ||
|
||
function M.close() | ||
local ui = require('gh-actions.ui') | ||
local store = require('gh-actions.store') | ||
|
||
ui.close() | ||
M.stop_polling() | ||
store.off_update(M.update_workflow_configs) | ||
end | ||
|
||
function M.toggle() | ||
local ui = require('gh-actions.ui') | ||
|
||
if ui.split.winid then | ||
return M.close() | ||
else | ||
return M.open() | ||
end | ||
require('pipeline').setup(...) | ||
end | ||
|
||
return M | ||
return gha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.