mainSavannah Administration - Support: sr #110939, Adding push hook for Guix

 
 

sr #110939: Adding push hook for Guix

Submitter:  Ludovic Courtès <civodul>
Submitted:  Mon 02 Oct 2023 09:23:51 PM UTC
   
 
Category:  Source code repositories - developer access Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  rwp
Operating System:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 12 Oct 2023 03:21:01 AM UTC, comment #6: 

I think I have this correct for the additional repos you mentioned.  Try it and let me know if anything needs something more.

And, oops, but in adding these I realized I broke the commit mail message.  Drat!  I had copied the emacs hook and forgot to change the name to match so there was an "emacs" "guix" mismatch which would have prevent the commit email from working.  Fixed now.

Bob Proulx <rwp>
Site Administrator
Sun 08 Oct 2023 08:31:16 PM UTC, comment #5: 

Hello!

> That's never needed for that assignment which is internal to the shell and therefore does not ever do word splitting. I understand the paranoia though. Sometimes the universe is actually out to get you! :-)


Heh, right!  :-)

I now realize there are a few additional repos that could use a similar hook, namely, for guix/guix-cuirass.git, guix/mumi.git, guile.git, skribilo.git, and shepherd.git, with one line like:


wget --post-data="" -O/dev/null -q https://ci.guix.gnu.org/jobset/PROJECT/hook/evaluate && echo "Triggered ci.guix.gnu.org."


where PROJECT is the name of the repo, except for: "guix/guix-cuirass" (should map to "cuirass") and "guix/mumi" (should map to "mumi").

Could you add these as well?

Thanks for your help!

Ludovic Courtès <civodul>
Sat 07 Oct 2023 06:46:26 PM UTC, comment #4: 

Good to hear that it is working!  Excellent!

> Perhaps add double quotes for good measure after branch= and around the URL that includes $branch.


That's never needed for that assignment which is internal to the shell and therefore does not ever do word splitting. I understand the paranoia though. Sometimes the universe is actually out to get you! :-)

But since $ref might in the case of an error contain a shell meta-character that reference should be quoted.  Which I have done now for both of those.  Thanks!


#!/bin/sh
wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/guix/hook/evaluate
while read oldrev newrev ref; do
    branch=$(basename "$ref")
    wget --post-data="" -O/dev/null "https://ci.guix.gnu.org/jobset/$branch/hook/evaluate"
done


And yes, the hook was already installed and ready for you after I had said "I have implemented the following hooks." :-)

Bob Proulx <rwp>
Site Administrator
Thu 05 Oct 2023 08:14:46 PM UTC, comment #3: 

Looks like the hook is in place and from what I see in the logs of our CI system, I can say it works like a charm!

Thank you!

Ludovic Courtès <civodul>
Thu 05 Oct 2023 09:24:33 AM UTC, comment #2: 

Hello Bob!


> File post-receive-ci.guix.gnu.org called from above.
> #!/bin/sh
> wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/guix/hook/evaluate
> while read oldrev newrev ref; do
>     branch=$(basename $ref)
>     wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/$branch/hook/evaluate
> done


Not tested but that looks great to me.  (Perhaps add double quotes for good measure after branch= and around the URL that includes $branch.)

Let me know when it's installed and we'll see if it works according to plan.

Thank you!

Ludo'.

Ludovic Courtès <civodul>
Wed 04 Oct 2023 04:40:26 PM UTC, comment #1: 

Adding git hooks is no problem at all.  But...

> wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/$BRANCH/hook/evaluate


I must ask, What will be the value for $BRANCH?  And I am sure you are
thinking, It's the currently pushed branch of course what a silly
question. :-) But as we know git's post-receive hook receives the
oldrev newrev ref hashes written to it on stdin and that's the direct
information we have available to us at that time.  At one time git
used to ship with a sample that included this next bit of text.


The "post-receive" script is run after receive-pack has accepted a pack
and the repository has been updated.  It is passed arguments in through
stdin in the form
 <oldrev> <newrev> <refname>
For example:
 aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master


The above came from the sample.  By that I conclude that the refname
will be the $BRANCH that you want to see at that time.  Will that
include the refs/heads part?  Probably not since you show it in the
URL.  I will strip that from the name.  With that interpretation I
have implemented the following hooks.


File post-receive hook, which duplicates stdin to the others.
#!/bin/sh
lines=$(cat)
printf "%s\n" "$lines" | ./hooks/post-receive-git_multimail-emacs
printf "%s\n" "$lines" | ./hooks/post-receive-ci.guix.gnu.org




File post-receive-ci.guix.gnu.org called from above.
#!/bin/sh
wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/guix/hook/evaluate
while read oldrev newrev ref; do
    branch=$(basename $ref)
    wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/$branch/hook/evaluate
done


Almost certainly something will need tweaking.  Let me know.

Bob Proulx <rwp>
Site Administrator
Mon 02 Oct 2023 09:23:51 PM UTC, original submission:  

Hello!

Could we have a Git push hook for Guix that would run these two commands (or something to that effect):

wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/guix/hook/evaluate
wget --post-data="" -O/dev/null  https://ci.guix.gnu.org/jobset/$BRANCH/hook/evaluate

This will trigger continuous integration.

Thanks in advance!

Ludovic Courtès <civodul>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rwp (Posted a comment)
  • -email is unavailable- added by civodul (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-04 rwp StatusNone Done
        Assigned toNone rwp
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code