ohwgiles / laminar

Fast and lightweight Continuous Integration
https://laminar.ohwg.net
GNU General Public License v3.0
304 stars 56 forks source link

Feature request: Markup for headings and links in job output #218

Open cweagans opened 3 months ago

cweagans commented 3 months ago

We use Jenkins extensively in our infrastructure. One concept in particular has been very useful to us, which is the ability to compose a Pipeline out of multiple jobs. When we run one of these Pipelines (composed of different Stages), we get some output that looks like this: (two different job names covered by red and orange boxes)

CleanShot 2024-08-07 at 14 20 12

In that screenshot at location 1 is the name of the Stage of the pipeline. At location 2, there's a link to the specific job that was started by this pipeline at this step.

In Laminar, this is somewhat easily represented with a job that just does something like this:

laminarc run some-job
laminarc run another-job
# etc

I don't think Laminar should have all of the fancy pipeline modeling that Jenkins has, but I do think that with a couple of small features, it'd be easy to compose pipelines in a more laminar-y way.

The output for that might look something like this:

[laminar] Executing cfg/jobs/build-and-release.run

====== [ BUILD ] ======

Builds in progress:
build-linux:123
build-mac:234
build-windows:345

====== [ RELEASE ] ======

Release jobs in progress:
release-linux:321
release-mac:432
release-windows: 543
[laminar] Executing cfg/after

(+ all of the jobname:123 outputs would be HTML links to their respective job/run pages)

If there's some other syntactic sugar that you'd prefer, that's ok too. I was mainly considering ease of implementation. Another option would be something like:

laminarc create-group      # or whatever
laminarc queue my-job:123
laminarc queue another:234
laminarc wait                    # waits for the two jobs queued above to complete, maybe outputs links to the output saying what we're waiting on
ohwgiles commented 1 month ago

Sorry for the much delayed response.

If my-job:123 is in the output for a given job, my-job is a real job, and 123 is a valid run number for my-job, Laminar could simply turn it into a link to that job run in the job output page.

laminar already does something like this. If you launch laminarc run from within laminar, it detects this and emits additional control characters, which the UI converts into links. Does this not work for you?

If # Some heading is in the output, format "Some heading" in a more prominent way in the job output page. This isn't strictly necessary, since I can just as easily echo; echo "====== [SOME HEADING] ======"; echo; or something along those lines

I'm not too keen on this idea as it stands, since it appears to modify the actual text of the console output. I'd be more receptive to a feature that styles the UI in a way that is not representable in terminal output. But that aside, would using a custom wrapper around laminarc run resolve this?

Add a new subcommand to laminarc: laminarc wait my-job:123. This would allow me to have pipeline stages where multiple jobs are running in parallel:

Needs some bash-foo, but an existing way to do this based on your script is

echo "# Build"
exec 3< <(laminarc run build-linux)
read <&3 linuxBuild
exec 4< <(laminarc run build-mac)
read <&4 macBuild
exec 5< <(laminarc run build-windows)
read <&5 windowsBuild

echo "Cross-platform builds in progress:"
echo $linuxBuild
echo $macBuild
echo $windowsBuild
wait

echo "# Release"
echo "Release jobs:"
exec 3< <(laminarc run release-linux buildJob=$linuxBuild)
read <&3 linuxRelease
exec 4< <(laminarc run release-mac buildJob=$macBuild)
read <&4 macRelease
exec 5< <(laminarc run release-windows buildJob=$windowsBuild)
read <&5 windowsRelease
echo "Release jobs in progress:"
echo $linuxRelease
echo $macRelease
echo $windowsRelease
wait