Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: poc octo run list #638

Merged
merged 67 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f109590
feat: poc octo run list
GustavEikaas Oct 15, 2024
b34746c
feat: define octo key mappings
GustavEikaas Oct 15, 2024
75132dd
feat: add customizable icons
GustavEikaas Oct 15, 2024
c45df2d
.
GustavEikaas Oct 15, 2024
a7585c3
revert lint changes
GustavEikaas Oct 15, 2024
af6b3b2
fix lint
GustavEikaas Oct 15, 2024
71160fc
feat: customizable refresh interval
GustavEikaas Oct 16, 2024
86f2989
add space between jobs
GustavEikaas Oct 16, 2024
89adabe
feat: use telescope
GustavEikaas Oct 18, 2024
aabb271
Merge branch 'master' into feat/octo-run-list
GustavEikaas Nov 5, 2024
fa1e079
Merge branch 'master' into feat/octo-run-list
GustavEikaas Nov 6, 2024
4ce3249
open buffer when pressing <cr>
GustavEikaas Nov 6, 2024
4015bb0
.
GustavEikaas Nov 6, 2024
e078e9c
get step logs for single job workflows
GustavEikaas Nov 17, 2024
cbf277a
Merge branch 'master' into feat/octo-run-list
GustavEikaas Nov 17, 2024
40009b7
multi-job-support
GustavEikaas Nov 17, 2024
8c66f4e
cache workflow runs
GustavEikaas Nov 17, 2024
8784bfe
.
GustavEikaas Nov 17, 2024
36cfbc9
add error message for failing to get logs
GustavEikaas Nov 17, 2024
08d6380
refactor: cleanup highlights
GustavEikaas Nov 17, 2024
ea5684d
add refresh keybinding
GustavEikaas Nov 17, 2024
24a17ba
Merge branch 'master' into feat/octo-run-list
GustavEikaas Nov 17, 2024
c5279dd
add notice and strip ansi codes
GustavEikaas Nov 18, 2024
f0484ac
dedupe steps
GustavEikaas Nov 22, 2024
8183618
feat: handle zip archive with logs
GustavEikaas Nov 29, 2024
3d4be42
Merge branch 'master' into feat/octo-run-list
GustavEikaas Nov 29, 2024
04c5852
add open in browser keybind
GustavEikaas Nov 30, 2024
6b705d0
Merge branch 'master' into feat/octo-run-list
GustavEikaas Dec 14, 2024
38bd3d8
cleanup zip archive, keybindings
GustavEikaas Dec 14, 2024
7c05477
.
GustavEikaas Dec 14, 2024
c8c2fc1
normalize
GustavEikaas Dec 14, 2024
11269d6
cr fix
GustavEikaas Dec 15, 2024
42187b2
refactor: move all requires to the top of file
GustavEikaas Dec 15, 2024
5619479
use octo.utils.error
GustavEikaas Dec 15, 2024
73c2588
Merge branch 'feat/octo-run-list' of https://github.com/GustavEikaas/…
GustavEikaas Dec 15, 2024
5dba2f0
refactor: workflow_runs telescope
GustavEikaas Dec 15, 2024
b815036
fix: invalid require
GustavEikaas Dec 15, 2024
a986723
add loading msg for workflow logs, cleanup old files to avoid conflicts
GustavEikaas Dec 15, 2024
b1134b4
fix: nil value
GustavEikaas Dec 18, 2024
2310237
style: lint issues
GustavEikaas Jan 5, 2025
512e73b
Merge branch 'master' into feat/octo-run-list
GustavEikaas Jan 5, 2025
1a90fe5
Merge branch 'master' into feat/octo-run-list
GustavEikaas Jan 14, 2025
53405e9
Merge branch 'master' of https://github.com/pwntester/octo.nvim into …
GustavEikaas Jan 15, 2025
43be49d
try fix unique os.tmpname
GustavEikaas Jan 15, 2025
885b679
.
GustavEikaas Jan 15, 2025
75dd6be
update readme
GustavEikaas Jan 15, 2025
ae36df5
update os.tmpname
GustavEikaas Jan 16, 2025
c63226e
fix: rand filename
GustavEikaas Jan 16, 2025
d5dee36
feat: improve random name seeding
GustavEikaas Jan 16, 2025
f772037
Merge branch 'master' into feat/octo-run-list
wd60622 Jan 25, 2025
b4c3f47
fix: skip logs for skipped steps
GustavEikaas Jan 25, 2025
3cdebb2
feat: show failed and skipped runs in telescope
GustavEikaas Jan 25, 2025
f8b1618
fix: workflow with long names not working
GustavEikaas Jan 26, 2025
d60ee6d
merge upstream
GustavEikaas Feb 20, 2025
511953c
use utils.get_remote_name
GustavEikaas Feb 20, 2025
996cd29
use existing octo.gh
GustavEikaas Feb 20, 2025
ff6ef7c
utils info over vim.notify
GustavEikaas Feb 22, 2025
cc0711d
use octo.picker
GustavEikaas Feb 22, 2025
37e6bf3
refactor: gh run list
GustavEikaas Feb 22, 2025
b84ad7e
Merge branch 'master' into feat/octo-run-list
GustavEikaas Feb 22, 2025
348aabc
add copy_url command
wd60622 Feb 22, 2025
45242a0
Merge branch 'master' into feat/octo-run-list
wd60622 Feb 22, 2025
7f7519f
feat: use ∨ for expanded nodes
GustavEikaas Feb 22, 2025
e998705
feat: close parent
GustavEikaas Feb 22, 2025
71f89d9
fix: some workflow logs cannot be read due to truncating
GustavEikaas Feb 22, 2025
7bfe613
use octo to notify
wd60622 Feb 23, 2025
1dde8cb
Merge branch 'master' into feat/octo-run-list
wd60622 Feb 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ require"octo".setup({
auto_show_threads = true, -- automatically show comment threads on cursor move
focus = "right", -- focus right buffer on diff open
},
runs = {
icons = {
pending = "🕖",
in_progress = "🔄",
failed = "❌",
succeeded = "",
skipped = "⏩",
cancelled = "✖",
},
},
pull_requests = {
order_by = { -- criteria to sort the results of `Octo pr list`
field = "CREATED_AT", -- either COMMENTS, CREATED_AT or UPDATED_AT (https://docs.github.com/en/graphql/reference/enums#issueorderfield)
Expand Down Expand Up @@ -169,6 +179,11 @@ require"octo".setup({
},
mappings_disable_default = false, -- disable default mappings if true, but will still adapt user mappings
mappings = {
runs = {
expand_step = { lhs = "o", desc = "expand workflow step" },
open_in_browser = { lhs = "<C-b>", desc = "open workflow run in browser" },
refresh = { lhs = "<C-r>", desc = "refresh workflow" },
},
issue = {
close_issue = { lhs = "<localleader>ic", desc = "close issue" },
reopen_issue = { lhs = "<localleader>io", desc = "reopen issue" },
Expand Down Expand Up @@ -382,6 +397,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
| | close | Close the review window and return to the PR |
| actions | | Lists all available Octo actions |
| search | <query> | Search GitHub for issues and PRs matching the [query](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) |
| run | list | List workflow runs |
| notification | list | Shows current unread notifications |

0. `[repo]`: If repo is not provided, it will be derived from `<cwd>/.git/config`.
Expand Down
10 changes: 10 additions & 0 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ function M.setup()

-- supported commands
M.commands = {
run = {
list = function()
local function co_wrapper()
require("octo.workflow_runs").list()
end

local co = coroutine.create(co_wrapper)
coroutine.resume(co)
end,
},
actions = function()
M.actions()
end,
Expand Down
29 changes: 28 additions & 1 deletion lua/octo/config.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local vim = vim
local M = {}

---@alias OctoMappingsWindow "issue" | "pull_request" | "review_thread" | "submit_win" | "review_diff" | "file_panel" | "repo" | "notification"
---@alias OctoMappingsWindow "issue" | "pull_request" | "review_thread" | "submit_win" | "review_diff" | "file_panel" | "repo" | "notification" | "runs"
---@alias OctoMappingsList { [string]: table}
---@alias OctoPickers "telescope" | "fzf-lua"
---@alias OctoSplit "right" | "left"
Expand Down Expand Up @@ -43,6 +43,17 @@ local M = {}
---@class OctoConfigDiscussions
---@field order_by OctoConfigOrderBy

---@class OctoConfigWorkflowIcons
---@field pending string
---@field skipped string
---@field in_progress string
---@field failed string
---@field succeeded string
---@field cancelled string

---@class OctoConfigRuns
---@field icons OctoConfigWorkflowIcons

---@class OctoConfigPR
---@field order_by OctoConfigOrderBy
---@field always_select_remote_on_create boolean
Expand Down Expand Up @@ -85,6 +96,7 @@ local M = {}
---@field ui OctoConfigUi
---@field issues OctoConfigIssues
---@field reviews OctoConfigReviews
---@field runs OctoConfigRuns
---@field pull_requests OctoConfigPR
---@field file_panel OctoConfigFilePanel
---@field colors OctoConfigColors
Expand Down Expand Up @@ -154,6 +166,16 @@ function M.get_default_values()
auto_show_threads = true,
focus = "right",
},
runs = {
icons = {
pending = "🕖",
in_progress = "🔄",
failed = "❌",
succeeded = "",
skipped = "⏩",
cancelled = "✖",
},
},
pull_requests = {
order_by = {
field = "CREATED_AT",
Expand Down Expand Up @@ -181,6 +203,11 @@ function M.get_default_values()
},
mappings_disable_default = false,
mappings = {
runs = {
expand_step = { lhs = "o", desc = "expand workflow step" },
open_in_browser = { lhs = "<C-b>", desc = "open workflow run in browser" },
refresh = { lhs = "<C-r>", desc = "refresh workflow" },
},
issue = {
close_issue = { lhs = "<localleader>ic", desc = "close issue" },
reopen_issue = { lhs = "<localleader>io", desc = "reopen issue" },
Expand Down
2 changes: 2 additions & 0 deletions lua/octo/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ M.OCTO_EMPTY_MSG_VT_NS = vim.api.nvim_create_namespace "octo_empty_msg_vt"
M.OCTO_THREAD_HEADER_VT_NS = vim.api.nvim_create_namespace "octo_thread_header_vt"
M.OCTO_EVENT_VT_NS = vim.api.nvim_create_namespace "octo_event_vt"

M.OCTO_WORKFLOW_NS = vim.api.nvim_create_namespace "octo_workflow"

M.NO_BODY_MSG = "No description provided."

M.LONG_ISSUE_PATTERN = "([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)#(%d+)"
Expand Down
2 changes: 2 additions & 0 deletions lua/octo/navigation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function M.open_in_browser(kind, repo, number)
cmd = string.format("gh gist view --web %s", number)
elseif kind == "project" then
cmd = string.format("gh project view --owner %s --web %s", repo, number)
elseif kind == "workflow_run" then
cmd = string.format("gh run view %s --web", number)
end
end
pcall(vim.cmd, "silent !" .. cmd)
Expand Down
10 changes: 10 additions & 0 deletions lua/octo/pickers/telescope/entry_maker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ function M.gen_from_git_changed_files()
end
end

function M.gen_from_workflow_run()
return function(workflow_run)
return {
display = workflow_run.display,
value = workflow_run,
ordinal = workflow_run.display,
}
end
end

function M.gen_from_review_thread(linenr_length)
local make_display = function(entry)
if not entry then
Expand Down
8 changes: 8 additions & 0 deletions lua/octo/pickers/telescope/previewers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local previewers = require "telescope.previewers"
local pv_utils = require "telescope.previewers.utils"
local ts_utils = require "telescope.utils"
local defaulter = ts_utils.make_default_callable
local workflow_runs_previewer = require("octo.workflow_runs").previewer

local vim = vim

Expand Down Expand Up @@ -224,7 +225,14 @@ local issue_template = defaulter(function(opts)
}
end, {})

local workflow_runs = defaulter(function(opts)
return previewers.new_buffer_previewer {
define_preview = workflow_runs_previewer,
}
end, {})

return {
workflow_runs = workflow_runs,
discussion = discussion,
issue = issue,
gist = gist,
Expand Down
24 changes: 24 additions & 0 deletions lua/octo/pickers/telescope/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,30 @@ function M.pending_threads(threads)
:find()
end

function M.workflow_runs(workflow_runs, title, on_select_cb)
pickers
.new({}, {
prompt_title = title or false,
results_title = false,
preview_title = false,
finder = finders.new_table {
results = workflow_runs,
entry_maker = entry_maker.gen_from_workflow_run(),
},
sorter = conf.generic_sorter {},
previewer = previewers.workflow_runs.new {},
attach_mappings = function()
actions.select_default:replace(function(prompt_bufnr)
local selection = action_state.get_selected_entry(prompt_bufnr)
actions.close(prompt_bufnr)
on_select_cb(selection.value)
end)
return true
end,
})
:find()
end

---
-- PROJECTS
---
Expand Down
Loading
Loading