-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: master
Are you sure you want to change the base?
Conversation
Using graphql is not a big deal. Just use whatever endpoint that works. Think there are a few non graphql commands used. |
Ah okay, functionality wise, do you have any feedback? |
I will give it a try when I can! |
Think it looks good. Would you want to make use of the pickers instead of the new, custom buffer? I have been using telescope recently. What do you use? Some items:
|
|
You still want there to be a buffer when you press |
Thanks for the PR @GustavEikaas! I like the idea of showing the status of the run in the preview buffer and perhaps show the logs of the run upon opening the item with |
IIRC the sequential jobs is already supported but yes I was thinking the same. |
@pwntester |
Doesnt seem like there is a good structured output for workflow logs. Will probably be tricky to have the same UI as github web. |
Nice, perhaps we can do a nested telescope selection where the use first chooses the run and then the job, that should get us a shorter log to show to the user and it should easier to print since we dont need to care about job's dependencies, just sequential steps |
Finally found it. Its a POSIX quirk. From the lua docs for os.tmpname In POSIX systems, this function also creates a file with that name, to avoid security risks. (Someone else might create the file with wrong permissions in the time between getting the name and creating the file.) You still have to open the file to use it and to remove it (even if you do not use it). |
Latest commit works fine on arch (btw), and windows. Should work just fine for you now @wd60622. |
Thanks for the updates. will give it a try when I can |
Okay. I am able to get it to work (for a few) now. I am still getting this traceback:
Maybe there is something with the filename then. Overall it looks really awesome @GustavEikaas. Thanks for the final push here! |
Yeah ill take a last look at escaping/normalizing filenames |
Great. Thank you! |
I am also noticing that the folders are being created off of my cwd. Is that as expected? |
Good catch ill fix that, happened after i migrated away from os.tmpname. |
Still a couple of rough edges in this PR but I think its getting ready to merge. Given that it stops giving you errors For any future issues/prs/discussions feel free to tag me, I would like to keep working on this |
I'm having a lot better luck with it now. Really cool feature. I am running into this:
Also, could you bind to the buffer to get the URL of the run? Think that could be pretty convenient. Or at least in the picker if it isn't already! |
I did bind Are you testing against open repositories, can you link a workflow run that fails? Seems like it complains about |
I managed to repro your issue @wd60622 and I might have found a bug in github... Not really sure how to proceed here. Will make an issue with github to gather some more info. I enabled longpaths on my windows system and still not working EDIT: Did some more digging and it seems like unzip is the reason it fails. When unzipping the folder with the long path name it just corrupts... Will do more digging EDIT2 local sanitized_name = node.id:gsub("/", ""):gsub(":", ""):gsub(">","")
--Make more than 3 consecutive dots at the end of line into ...
local sanitized_job_id = node.job_id:gsub("/", ""):gsub(":", ""):gsub("%.%.%.%.+$", "...") |
Was still having issues with this. Does it have something to do with the file / folder names. Should we use a hash or something? |
Darn, really? Well the problem is I do api calls to get the workflow and based on the dynamic info there I request an archive with an arbitary number of files with names that can be built up using the workflow but with |
Thanks for all of the digging. Feel free to ping me to try again. Maybe @GuillaumeLagrange can try as well! |
Ill keep digging! It would be easier if anyone could link me a specific workflow run that causes it to error out |
lua/octo/workflow_runs.lua
Outdated
M.refresh() | ||
return | ||
end | ||
local cmd = string.format("gh run view %s --json %s", id, fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to use existing code here?
Might look like this:
gh = require "octo.gh"
gh.run.view {
id,
json=fields,
opts = {
cb = function(output, stderr)
end,
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like this?
Or did you want me to create the gh.run.view
?
gh.run {
args = { "run", "view", id, "--json", fields },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
vim.api.nvim_err_writeln(stderr)
octo_error("Failed to get workflow run for " .. id)
elseif output then
job_details = vim.fn.json_decode(output)
M.wf_cache[id] = job_details
M.current_wf = job_details
M.tree = generate_workflow_tree(job_details)
M.refresh()
end
end,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arbitrary CLI commands are already supported with this logic:
octo.nvim/lua/octo/gh/init.lua
Lines 329 to 367 in c689dd5
local create_subcommand = function(command) | |
local subcommand = {} | |
subcommand.command = command | |
setmetatable(subcommand, { | |
__index = function(t, key) | |
return function(opts) | |
opts = opts or {} | |
local run_opts = opts.opts or {} | |
local args = { | |
t.command, | |
key, | |
} | |
opts.opts = nil | |
args = M.insert_args(args, opts, { ["_"] = "-" }) | |
return M.run { | |
args = args, | |
mode = run_opts.mode, | |
cb = run_opts.cb, | |
stream_cb = run_opts.stream_cb, | |
headers = run_opts.headers, | |
hostname = run_opts.hostname, | |
} | |
end | |
end, | |
}) | |
return subcommand | |
end | |
setmetatable(M, { | |
__index = function(_, key) | |
return create_subcommand(key) | |
end, | |
}) |
So no need to write it. Just use what I wrote and fill in the callback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments.
Also, been thinking about the use of zip files (Still don't have working in all cases for me)...
Do the logs have to stored to file system? There are other items that are just stored in the local variable M
. Can that strategy also be used?
end | ||
|
||
M.list = function() | ||
vim.notify "Fetching workflow runs (this may take a while) ..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use utils.info over vim.notify
local co = coroutine.running() | ||
local wf_runs = get_workflow_runs_sync(co) | ||
|
||
require("octo.pickers.telescope.provider").workflow_runs(wf_runs, "Workflow runs", render) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use require "octo.picker" instead. Feel free to have M.not_implemented for the other two pickers
local function get_workflow_runs_sync(co) | ||
local lines = {} | ||
vim.fn.jobstart( | ||
"gh run list --json conclusion,displayTitle,event,headBranch,name,number,status,updatedAt,databaseId -L " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to use gh.run / gh.run.list here as well?
Using that ensures that the environment variables are correct
Important
This is a draft PR
Im making this draft PR so I can get reviews/suggestions during development
I will fill out the PR template when the PR is ready for review
Resolves: #149
Describe what this PR does / why we need it
First PR in a series of PRs to add support for github actions
Does this pull request fix one issue?
Describe how you did it
Describe how to verify it
Special notes for reviews
Checklist
Feature checklist
##[group]
[command]
Remaining
Look into using graphql in favor of gh cli commands (not sure if strictly necessary but conforms to the repo standard)