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

Support for CI status #92

Open
vermiculus opened this issue Jan 26, 2019 · 16 comments
Open

Support for CI status #92

vermiculus opened this issue Jan 26, 2019 · 16 comments
Labels
enhancement New feature or request

Comments

@vermiculus
Copy link
Contributor

Most forges support some sort of build/testing status from the various CI solutions out there (Gitlab's own, Travis CI, CircleCI, ...?) -- this information should have a home in Forge.

vermiculus/magithub#399

I am unsure how this should be done. Really, it's a property of a commit, but there is no current structure for these objects. We could get around that by having a map of commit identifiers to status objects in a forge-repository.

@vermiculus
Copy link
Contributor Author

I seem to remember talking about this before, but I don't recall where ☹️ No implementation specifics -- just more Forge philosophy that it's not necessarily opposed to storing information available from only one Forge.

@vermiculus
Copy link
Contributor Author

Also, have you considered moving ghub-get-repository into Forge? It does make it inconvenient to add information like this. AFAICT, I'll have to submit a PR to add status information to the relevant queries.

@tarsius tarsius added the enhancement New feature or request label Jan 28, 2019
@tarsius
Copy link
Member

tarsius commented Jan 28, 2019

While I would like CI support too, I think this is one of those features we should delay until have settled down more. It's a whole new cans of worms.

@tarsius
Copy link
Member

tarsius commented Jan 28, 2019

Also, have you considered moving ghub-get-repository into Forge?

Did you mean "forge-get-repository into Ghub"?

@vermiculus
Copy link
Contributor Author

I did mean from ghub -> forge, but I botched the variable name; my bad.

Referring to constant ghub-fetch-repository:

https://github.com/magit/ghub/blob/f1b8aebf99a7de298de6333a82c9b714609f2e99/ghub-graphql.el#L73

@matthew-piziak
Copy link

Currently I use something like this to cache my PRs into Emacs every twenty seconds or so.

;; load ghubp functions
(use-package magithub
  :straight t
  :init
  (require 'ghub+))

(defun github-get-prs ()
  (let ((repo (ghub-get "<my-repository>"))
        (user "<my-username>"))
    (defun ref-to-status (ref)
      (list ref
            (with-timeout (3 "failure")
              (cdr (assoc 'state (ghubp-get-repos-owner-repo-commits-ref-status repo ref))))))
    (mapcar
     #'ref-to-status
     (mapcar
      (lambda (pr) (cdr (assoc 'ref (assoc 'head pr))))
      (-filter
       (lambda (pr) (s-equals-p user (cdr (assoc 'login (assoc 'user pr)))))
       (ghubp-unpaginate (ghubp-get-repos-owner-repo-pulls repo)))))))

Then that gives me the status, which I can use to prioritize open PRs which have stopped blocking.

I'm hoping to one day replace the magithub dependency here.

@vermiculus
Copy link
Contributor Author

You don't need magithub for the snippet above; just ghub+

@matthew-piziak
Copy link

Ah you're right! Not sure why that didn't work the first time I wrote that snippet. That saves me time in my use-package loads. Thank you.

@micah
Copy link

micah commented Sep 25, 2019

I was just iterating over some code in emacs, using magit to push my code, then having to switch to my browser to go to my gitlab instance, to go to the CI pipelines page, then click on the job and watch the build output. I was having to do this over and over, when I thought... wouldn't it be nice if I could just push via magit, and a little minibuffer window would pop up in emacs with the build output of my gitlab CI job, updating in real-time?

Yes, that would be cool.

I know gitlab has an API that you can pull this from, so it would just need to connect all the pieces and refresh that until it finished.

@yisraeldov
Copy link

yisraeldov commented Sep 26, 2019 via email

@tbinetruy
Copy link

Any news ? This would be such a great feature to have ! It's the last thing preventing me from living in Emacs :)

@sgpthomas
Copy link

I would be interested in implementing this. However, I have never interacted with the forge codebase before. Could anybody familiar give me a few pointers about where I should look to get started?

@tarsius
Copy link
Member

tarsius commented Jul 29, 2023

@sgpthomas I think it is probably going to be pretty hard to implement this for someone who is not familiar with the code base yet. That doesn't mean you should not attempt it, but that you should be prepared to do a lot of reading and experimenting. You'll also find things that are a bit weird; I would like to improve those, but time...

Begin by implementing this just for pull-requests, leaving "tip of branch" aside for now. Forge already stores information about pull-requests in its database, not so for branches.

So for pull-requests you only have to figure out how to add a new field/slot/column and update it. For branches you would have to figure out much more about my adhoc, leaky orm thingy (which I wrote when I first learned about (the very basics of) databases). To learn how to do that, trace (l t in magit) something that changes when a new slot is added, e.g., forge--db-table-schemata. Look for commits that add a single column and look at those to learn what other places have to be adjusted.

Once the data is available locally, you have to figure how to display it, but I suspect that will be more fun.

@sgpthomas
Copy link

Awesome! Thanks for the pointers

@sgpthomas
Copy link

It appears that I will have to make changes to the ghub graph ql queries in order to get information about check suites and workflows. I can of course make this into a separate query and use the ghub-graphql function, but then this adds an additional query to the API. I was wondering if there is a particular reason that these queries live in ghub and not forge.

In the meantime I will continue to mock this up by using an additional query.

@sgpthomas
Copy link

Got the basics working. Will open a draft PR soon.

Sneak peak:
Screenshot 2023-08-04 at 1 17 34 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

7 participants