diff --git a/.gitignore b/.gitignore index e62860e..c1be013 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -lua/gh_actions_native/deps -lua/gh_actions_native/yaml.so +lua/pipeline_native/deps +lua/pipeline_native/yaml.so target diff --git a/Cargo.lock b/Cargo.lock index 758ef55..a4cab52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,15 +61,6 @@ dependencies = [ "typeid", ] -[[package]] -name = "gh-actions-rust" -version = "0.0.1" -dependencies = [ - "mlua", - "serde", - "serde_yaml", -] - [[package]] name = "hashbrown" version = "0.15.1" @@ -195,6 +186,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "pipeline_native" +version = "0.0.1" +dependencies = [ + "mlua", + "serde", + "serde_yaml", +] + [[package]] name = "pkg-config" version = "0.3.31" diff --git a/Cargo.toml b/Cargo.toml index 95f33b0..fc14f74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = 'gh-actions-rust' +name = 'pipeline_native' version = '0.0.1' edition = '2021' @@ -7,6 +7,6 @@ edition = '2021' 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" diff --git a/Makefile b/Makefile index 8e343ec..7dd872d 100644 --- a/Makefile +++ b/Makefile @@ -3,18 +3,18 @@ all: build copy clean: - rm -rf ./lua/gh_actions_native/yaml.so ./lua/gh_actions_native/deps + rm -rf ./lua/pipeline_native/yaml.so ./lua/pipeline_native/deps depsdir: - mkdir -p ./lua/gh_actions_native/deps + mkdir -p ./lua/pipeline_native/deps build: cargo build --release copy: clean depsdir - cp ./target/release/libgh_actions_rust.dylib ./lua/gh_actions_native/yaml.so || true - cp ./target/release/libgh_actions_rust.so ./lua/gh_actions_native/yaml.so || true - cp ./target/release/deps/*.rlib ./lua/gh_actions_native/deps/ + cp ./target/release/libpipeline_rust.dylib ./lua/pipeline_native/yaml.so || true + cp ./target/release/libpipeline_rust.so ./lua/pipeline_native/yaml.so || true + cp ./target/release/deps/*.rlib ./lua/pipeline_native/deps/ plugin_dir := ./.tests/site/pack/deps/start plugins := $(plugin_dir)/plenary.nvim $(plugin_dir)/nui.nvim diff --git a/README.md b/README.md index 8a37910..e8940ad 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The pipeline.nvim plugin for Neovim allows developers to easily manage and dispatch their CI/CD Pipelines, like GitHub Actions or Gitlab CI, directly from within the editor.
- +
## Features @@ -61,15 +61,15 @@ The plugin interacts with Gitlab via the `glab` cli, all that is needed is being ### Commands -- `:Pipeline` or `:Pipeline toggle` toggles the `gh-actions` split -- `:Pipeline open` opens the `gh-actions` split -- `:Pipeline close` closes the `gh-actions` split +- `:Pipeline` or `:Pipeline toggle` toggles the `pipeline.nvim` split +- `:Pipeline open` opens the `pipeline.nvim` split +- `:Pipeline close` closes the `pipeline.nvim` split ### Keybindings The following keybindings are provided by the plugin: -- `q` - closes the `gh-actions` the split +- `q` - closes the `pipeline.nvim` the split - `gp` - open the pipeline below the cursor on GitHub - `gr` - open the run below the cursor on GitHub - `gj` - open the job of the workflow run below the cursor on GitHub @@ -77,7 +77,7 @@ The following keybindings are provided by the plugin: ### Options -The default options (as defined in [lua/config.lua](./blob/main/lua/gh-actions/config.lua)) +The default options (as defined in [lua/config.lua](./blob/main/lua/pipeline/config.lua)) ```lua { diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 5c8d9e0..0000000 --- a/TODO.md +++ /dev/null @@ -1,9 +0,0 @@ -# TODO - -1. ~Map github responses to internal data structures~ -2. ~Update render to use the new data structures~ -3. Move highlight and icon mapping into provider -4. ~Move github specific code from `init.lua` into provider~ -5. Implement Gitlab Provider -6. Rename anything gh-actions related to pipeline.nvim -7. Rename types from GhActions to pipeline.\* diff --git a/lazy.lua b/lazy.lua index c9e575b..d76df74 100644 --- a/lazy.lua +++ b/lazy.lua @@ -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, }, } diff --git a/lua/gh-actions/command.lua b/lua/gh-actions/command.lua deleted file mode 100644 index 1291750..0000000 --- a/lua/gh-actions/command.lua +++ /dev/null @@ -1,32 +0,0 @@ -local M = {} - -local function handle_gh_actions_command(a) - local gha = require('gh-actions') - - local action = a.fargs[1] or 'toggle' - - if action == 'open' then - return gha.open() - elseif action == 'close' then - return gha.close() - elseif action == 'toggle' then - return gha.toggle() - end -end - -local function completion_customlist() - return { - 'open', - 'close', - 'toggle', - } -end - -function M.setup() - vim.api.nvim_create_user_command('GhActions', handle_gh_actions_command, { - nargs = '?', - complete = completion_customlist, - }) -end - -return M diff --git a/lua/gh-actions/init.lua b/lua/gh-actions/init.lua index 9437e66..7ae8fae 100644 --- a/lua/gh-actions/init.lua +++ b/lua/gh-actions/init.lua @@ -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 diff --git a/lua/lualine/components/pipeline.lua b/lua/lualine/components/pipeline.lua index 4b29190..49d6343 100644 --- a/lua/lualine/components/pipeline.lua +++ b/lua/lualine/components/pipeline.lua @@ -6,7 +6,7 @@ local Component = require('lualine.component'):extend() local default_options = { icon = '', ---@param component pipeline.lualine.Component - ---@param state GhActionsState + ---@param state pipeline.State ---@return string format = function(component, state) local latest_run = state.latest_run @@ -21,7 +21,7 @@ local default_options = { end, on_click = function() - require('gh-actions').toggle() + require('pipeline').toggle() end, } @@ -32,16 +32,16 @@ function Component:init(options) Component.super.init(self, self.options) - self.store = require('gh-actions.store') - self.icons = require('gh-actions.utils.icons') + self.store = require('pipeline.store') + self.icons = require('pipeline.utils.icons') - local server, repo = require('gh-actions.git').get_current_repository() + local server, repo = require('pipeline.git').get_current_repository() if not server or not repo then return end - require('gh-actions').start_polling() + require('pipeline').start_polling() self.store.on_update(function() require('lualine').refresh() diff --git a/lua/pipeline/command.lua b/lua/pipeline/command.lua new file mode 100644 index 0000000..81ac07a --- /dev/null +++ b/lua/pipeline/command.lua @@ -0,0 +1,43 @@ +local M = {} + +local function handle_pipeline_command(a) + local pipeline = require('pipeline') + + if a.name == 'GhActions' then + vim.notify_once( + 'GhActions command is deprecated, use Pipeline instead', + vim.log.levels.WARN + ) + end + + local action = a.fargs[1] or 'toggle' + + if action == 'open' then + return pipeline.open() + elseif action == 'close' then + return pipeline.close() + elseif action == 'toggle' then + return pipeline.toggle() + end +end + +local function completion_customlist() + return { + 'open', + 'close', + 'toggle', + } +end + +function M.setup() + vim.api.nvim_create_user_command('Pipeline', handle_pipeline_command, { + nargs = '?', + complete = completion_customlist, + }) + vim.api.nvim_create_user_command('GhActions', handle_pipeline_command, { + nargs = '?', + complete = completion_customlist, + }) +end + +return M diff --git a/lua/gh-actions/config.lua b/lua/pipeline/config.lua similarity index 73% rename from lua/gh-actions/config.lua rename to lua/pipeline/config.lua index a4f499f..397f6cf 100644 --- a/lua/gh-actions/config.lua +++ b/lua/pipeline/config.lua @@ -41,37 +41,37 @@ local defaultConfig = { ---@class pipeline.config.Highlights highlights = { ---@type vim.api.keyset.highlight - GhActionsRunIconSuccess = { link = 'LspDiagnosticsVirtualTextHint' }, + PipelineRunIconSuccess = { link = 'LspDiagnosticsVirtualTextHint' }, ---@type vim.api.keyset.highlight - GhActionsRunIconFailure = { link = 'LspDiagnosticsVirtualTextError' }, + PipelineRunIconFailure = { link = 'LspDiagnosticsVirtualTextError' }, ---@type vim.api.keyset.highlight - GhActionsRunIconStartup_failure = { + PipelineRunIconStartup_failure = { link = 'LspDiagnosticsVirtualTextError', }, ---@type vim.api.keyset.highlight - GhActionsRunIconPending = { link = 'LspDiagnosticsVirtualTextWarning' }, + PipelineRunIconPending = { link = 'LspDiagnosticsVirtualTextWarning' }, ---@type vim.api.keyset.highlight - GhActionsRunIconRequested = { link = 'LspDiagnosticsVirtualTextWarning' }, + PipelineRunIconRequested = { link = 'LspDiagnosticsVirtualTextWarning' }, ---@type vim.api.keyset.highlight - GhActionsRunIconWaiting = { link = 'LspDiagnosticsVirtualTextWarning' }, + PipelineRunIconWaiting = { link = 'LspDiagnosticsVirtualTextWarning' }, ---@type vim.api.keyset.highlight - GhActionsRunIconIn_progress = { link = 'LspDiagnosticsVirtualTextWarning' }, + PipelineRunIconIn_progress = { link = 'LspDiagnosticsVirtualTextWarning' }, ---@type vim.api.keyset.highlight - GhActionsRunIconCancelled = { link = 'Comment' }, + PipelineRunIconCancelled = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsRunIconSkipped = { link = 'Comment' }, + PipelineRunIconSkipped = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsRunCancelled = { link = 'Comment' }, + PipelineRunCancelled = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsRunSkipped = { link = 'Comment' }, + PipelineRunSkipped = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsJobCancelled = { link = 'Comment' }, + PipelineJobCancelled = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsJobSkipped = { link = 'Comment' }, + PipelineJobSkipped = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsStepCancelled = { link = 'Comment' }, + PipelineStepCancelled = { link = 'Comment' }, ---@type vim.api.keyset.highlight - GhActionsStepSkipped = { link = 'Comment' }, + PipelineStepSkipped = { link = 'Comment' }, }, ---@type nui_split_options split = { diff --git a/lua/gh-actions/git.lua b/lua/pipeline/git.lua similarity index 100% rename from lua/gh-actions/git.lua rename to lua/pipeline/git.lua diff --git a/lua/gh-actions/health.lua b/lua/pipeline/health.lua similarity index 74% rename from lua/gh-actions/health.lua rename to lua/pipeline/health.lua index 6a664d9..b0fc737 100644 --- a/lua/gh-actions/health.lua +++ b/lua/pipeline/health.lua @@ -5,7 +5,7 @@ function M.check() health.start('Checking ability to parse yaml files') - local has_native_module = pcall(require, 'gh_actions_native.yaml') + local has_native_module = pcall(require, 'pipeline_native.yaml') if has_native_module then health.ok('Found native module') @@ -27,8 +27,8 @@ function M.check() health.error('No yaml parser found') end - require('gh-actions.providers.github.rest.health').check() - require('gh-actions.providers.gitlab.graphql.health').check() + require('pipeline.providers.github.rest.health').check() + require('pipeline.providers.gitlab.graphql.health').check() end return M diff --git a/lua/pipeline/init.lua b/lua/pipeline/init.lua new file mode 100644 index 0000000..4f1434e --- /dev/null +++ b/lua/pipeline/init.lua @@ -0,0 +1,156 @@ +local M = { + init_root = '', +} + +---@param opts? pipeline.Config +function M.setup(opts) + opts = opts or {} + + M.init_root = vim.fn.getcwd() + + require('pipeline.config').setup(opts) + require('pipeline.ui').setup() + require('pipeline.command').setup() + + M.setup_provider() +end + +function M.setup_provider() + if M.pipeline then + return + end + + local config = require('pipeline.config') + local store = require('pipeline.store') + + M.pipeline = require('pipeline.providers.provider'):new(config.options, store) + for provider, provider_options in pairs(config.options.providers) do + local Provider = require('pipeline.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 pipeline.State +function M.update_workflow_configs(state) + local gh_utils = require('pipeline.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('pipeline.utils').open(pipeline_object.url) +end + +function M.open() + local ui = require('pipeline.ui') + local store = require('pipeline.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('pipeline.ui') + local store = require('pipeline.store') + + ui.close() + M.stop_polling() + store.off_update(M.update_workflow_configs) +end + +function M.toggle() + local ui = require('pipeline.ui') + + if ui.split.winid then + return M.close() + else + return M.open() + end +end + +return M diff --git a/lua/gh-actions/providers/github/rest/_api.lua b/lua/pipeline/providers/github/rest/_api.lua similarity index 99% rename from lua/gh-actions/providers/github/rest/_api.lua rename to lua/pipeline/providers/github/rest/_api.lua index 4557523..a997efc 100644 --- a/lua/gh-actions/providers/github/rest/_api.lua +++ b/lua/pipeline/providers/github/rest/_api.lua @@ -1,5 +1,5 @@ function gh_utils() - return require('gh-actions.providers.github.utils') + return require('pipeline.providers.github.utils') end ---@class pipeline.providers.github.rest.Api diff --git a/lua/gh-actions/providers/github/rest/_mapper.lua b/lua/pipeline/providers/github/rest/_mapper.lua similarity index 90% rename from lua/gh-actions/providers/github/rest/_mapper.lua rename to lua/pipeline/providers/github/rest/_mapper.lua index c2d5077..db362c4 100644 --- a/lua/gh-actions/providers/github/rest/_mapper.lua +++ b/lua/pipeline/providers/github/rest/_mapper.lua @@ -4,8 +4,8 @@ local M = {} ---By default the workflow.html_url points to the workflow definition file. ---We want to jump to the UI of all the workflow runs instead. ---Example: ---- input: https://github.com/topaxi/gh-actions.nvim/blob/main/.github/workflows/dispatch-echo.yaml ---- output: https://github.com/topaxi/gh-actions.nvim/actions/workflows/dispatch-echo.yaml +--- input: https://github.com/topaxi/pipeline.nvim/blob/main/.github/workflows/dispatch-echo.yaml +--- output: https://github.com/topaxi/pipeline.nvim/actions/workflows/dispatch-echo.yaml ---@param workflow GhWorkflow local function workflow_url(workflow) return workflow.html_url:gsub('blob/main/%.github', 'actions') diff --git a/lua/gh-actions/providers/github/rest/health.lua b/lua/pipeline/providers/github/rest/health.lua similarity index 77% rename from lua/gh-actions/providers/github/rest/health.lua rename to lua/pipeline/providers/github/rest/health.lua index 7c99f05..14f1489 100644 --- a/lua/gh-actions/providers/github/rest/health.lua +++ b/lua/pipeline/providers/github/rest/health.lua @@ -6,7 +6,7 @@ function M.check() health.start('Github REST provider') local k, token = - pcall(require('gh-actions.providers.github.utils').get_github_token) + pcall(require('pipeline.providers.github.utils').get_github_token) if k and token then health.ok('Found GitHub token') diff --git a/lua/gh-actions/providers/github/rest/init.lua b/lua/pipeline/providers/github/rest/init.lua similarity index 90% rename from lua/gh-actions/providers/github/rest/init.lua rename to lua/pipeline/providers/github/rest/init.lua index 67e981c..8e01c2a 100644 --- a/lua/gh-actions/providers/github/rest/init.lua +++ b/lua/pipeline/providers/github/rest/init.lua @@ -1,12 +1,12 @@ -local utils = require('gh-actions.utils') -local Provider = require('gh-actions.providers.provider') +local utils = require('pipeline.utils') +local Provider = require('pipeline.providers.provider') local function git() - return require('gh-actions.git') + return require('pipeline.git') end local function gh_api() - return require('gh-actions.providers.github.rest._api') + return require('pipeline.providers.github.rest._api') end ---@class pipeline.providers.github.rest.Options @@ -26,7 +26,7 @@ function GithubRestProvider.detect() return false end - local config = require('gh-actions.config') + local config = require('pipeline.config') local server, repo = git().get_current_repository() if not config.is_host_allowed(server) then @@ -58,7 +58,7 @@ end --TODO Maybe send lsp progress events when fetching, to interact -- with fidget.nvim function GithubRestProvider:fetch() - local Mapper = require('gh-actions.providers.github.rest._mapper') + local Mapper = require('pipeline.providers.github.rest._mapper') gh_api().get_workflows(self.server, self.repo, { callback = function(workflows) @@ -116,7 +116,7 @@ function GithubRestProvider:dispatch(pipeline) return end - local store = require('gh-actions.store') + local store = require('pipeline.store') if pipeline then local server = store.get_state().server @@ -124,10 +124,10 @@ function GithubRestProvider:dispatch(pipeline) -- TODO should we get current ref instead or show an input with the -- default branch or current ref preselected? - local default_branch = require('gh-actions.git').get_default_branch() + local default_branch = require('pipeline.git').get_default_branch() ---@type pipeline.providers.github.WorkflowDef|nil local workflow_config = - require('gh-actions.yaml').read_yaml_file(pipeline.meta.workflow_path) + require('pipeline.yaml').read_yaml_file(pipeline.meta.workflow_path) if not workflow_config or not workflow_config.on.workflow_dispatch then return @@ -169,7 +169,7 @@ function GithubRestProvider:dispatch(pipeline) { callback = function(workflow_runs) local Mapper = - require('gh-actions.providers.github.rest._mapper') + require('pipeline.providers.github.rest._mapper') local runs = vim.tbl_map(Mapper.to_run, workflow_runs) store.update_state(function(state) @@ -212,7 +212,7 @@ function GithubRestProvider:dispatch(pipeline) local prompt = string.format('%s: ', input.description or name) if input.type == 'choice' then - local question = require('gh-actions.ui.components.select') { + local question = require('pipeline.ui.components.select') { prompt = prompt, title = pipeline.name, options = input.options, @@ -228,7 +228,7 @@ function GithubRestProvider:dispatch(pipeline) table.insert(questions, question) else - local question = require('gh-actions.ui.components.input') { + local question = require('pipeline.ui.components.input') { prompt = prompt, title = pipeline.name, default_value = input.default, diff --git a/lua/gh-actions/providers/github/types.lua b/lua/pipeline/providers/github/types.lua similarity index 100% rename from lua/gh-actions/providers/github/types.lua rename to lua/pipeline/providers/github/types.lua diff --git a/lua/gh-actions/providers/github/utils.lua b/lua/pipeline/providers/github/utils.lua similarity index 96% rename from lua/gh-actions/providers/github/utils.lua rename to lua/pipeline/providers/github/utils.lua index a86645c..4c3e28c 100644 --- a/lua/gh-actions/providers/github/utils.lua +++ b/lua/pipeline/providers/github/utils.lua @@ -45,7 +45,7 @@ end function M.get_workflow_config(path) path = vim.fn.expand(path) - local utils = require('gh-actions.utils') + local utils = require('pipeline.utils') local workflow_yaml = utils.read_file(path) or '' local config = { on = { diff --git a/lua/gh-actions/providers/gitlab/graphql/_api.lua b/lua/pipeline/providers/gitlab/graphql/_api.lua similarity index 100% rename from lua/gh-actions/providers/gitlab/graphql/_api.lua rename to lua/pipeline/providers/gitlab/graphql/_api.lua diff --git a/lua/gh-actions/providers/gitlab/graphql/_mapper.lua b/lua/pipeline/providers/gitlab/graphql/_mapper.lua similarity index 100% rename from lua/gh-actions/providers/gitlab/graphql/_mapper.lua rename to lua/pipeline/providers/gitlab/graphql/_mapper.lua diff --git a/lua/gh-actions/providers/gitlab/graphql/health.lua b/lua/pipeline/providers/gitlab/graphql/health.lua similarity index 100% rename from lua/gh-actions/providers/gitlab/graphql/health.lua rename to lua/pipeline/providers/gitlab/graphql/health.lua diff --git a/lua/gh-actions/providers/gitlab/graphql/init.lua b/lua/pipeline/providers/gitlab/graphql/init.lua similarity index 81% rename from lua/gh-actions/providers/gitlab/graphql/init.lua rename to lua/pipeline/providers/gitlab/graphql/init.lua index 981b544..2f0d097 100644 --- a/lua/gh-actions/providers/gitlab/graphql/init.lua +++ b/lua/pipeline/providers/gitlab/graphql/init.lua @@ -1,12 +1,12 @@ -local utils = require('gh-actions.utils') -local Provider = require('gh-actions.providers.provider') +local utils = require('pipeline.utils') +local Provider = require('pipeline.providers.provider') local function git() - return require('gh-actions.git') + return require('pipeline.git') end local function glab_api() - return require('gh-actions.providers.gitlab.graphql._api') + return require('pipeline.providers.gitlab.graphql._api') end ---@class pipeline.providers.gitlab.graphql.Options @@ -26,7 +26,7 @@ function GitlabGraphQLProvider.detect() return false end - local config = require('gh-actions.config') + local config = require('pipeline.config') local server, repo = git().get_current_repository() if not config.is_host_allowed(server) then @@ -52,7 +52,7 @@ function GitlabGraphQLProvider:init(opts) end function GitlabGraphQLProvider:fetch() - local Mapper = require('gh-actions.providers.gitlab.graphql._mapper') + local Mapper = require('pipeline.providers.gitlab.graphql._mapper') glab_api().get_project_pipelines(self.repo, 10, function(response) if @@ -98,17 +98,11 @@ function GitlabGraphQLProvider:dispatch(pipeline) return end - local store = require('gh-actions.store') - if pipeline then - local server = store.get_state().server - local repo = store.get_state().repo - - local default_branch = require('gh-actions.git').get_default_branch() - local ci_config = - require('gh-actions.yaml').read_yaml_file(pipeline.meta.ci_config_path) - - -- TODO + vim.notify( + 'Gitlab Pipeline dispatch is not yet implemented', + vim.log.levels.INFO + ) end end diff --git a/lua/gh-actions/providers/init.lua b/lua/pipeline/providers/init.lua similarity index 81% rename from lua/gh-actions/providers/init.lua rename to lua/pipeline/providers/init.lua index ed5a5e5..34e4234 100644 --- a/lua/gh-actions/providers/init.lua +++ b/lua/pipeline/providers/init.lua @@ -7,7 +7,7 @@ local providers = { ---@field github pipeline.providers.github.rest.Provider local M = setmetatable({}, { __index = function(_, key) - return require('gh-actions.providers.' .. providers[key]) + return require('pipeline.providers.' .. providers[key]) end, }) diff --git a/lua/gh-actions/providers/provider.lua b/lua/pipeline/providers/provider.lua similarity index 97% rename from lua/gh-actions/providers/provider.lua rename to lua/pipeline/providers/provider.lua index 987f124..6093200 100644 --- a/lua/gh-actions/providers/provider.lua +++ b/lua/pipeline/providers/provider.lua @@ -25,7 +25,7 @@ ---@class pipeline.Provider ---@field protected config pipeline.Config ----@field protected store GhActionsStore +---@field protected store pipeline.Store ---@field private listener_count integer local Provider = {} @@ -44,7 +44,7 @@ end ---@generic T: pipeline.Provider ---@param config pipeline.Config ----@param store GhActionsStore +---@param store pipeline.Store ---@param opts? table ---@return self function Provider:new(config, store, opts) diff --git a/lua/gh-actions/providers/types.lua b/lua/pipeline/providers/types.lua similarity index 100% rename from lua/gh-actions/providers/types.lua rename to lua/pipeline/providers/types.lua diff --git a/lua/gh-actions/store.lua b/lua/pipeline/store.lua similarity index 70% rename from lua/gh-actions/store.lua rename to lua/pipeline/store.lua index 07a67ad..e9ed5b2 100644 --- a/lua/gh-actions/store.lua +++ b/lua/pipeline/store.lua @@ -1,10 +1,10 @@ -local utils = require('gh-actions.utils') +local utils = require('pipeline.utils') ----@class GhActionsStateWorkflowConfig +---@class pipeline.StatePipelineConfig ---@field last_read integer ---@field config table ----@class GhActionsState +---@class pipeline.State ---@field title string ---@field repo string ---@field server string @@ -12,7 +12,7 @@ local utils = require('gh-actions.utils') ---@field runs table