From 37a1fedd2dd8ca4f7f18919a97322bc0a1645dba Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 8 Mar 2023 14:32:56 +0100 Subject: Add post about Laminar --- .../2023-03-08-using-laminar-for-selfhosted-ci.md | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 content/posts/2023/2023-03-08-using-laminar-for-selfhosted-ci.md diff --git a/content/posts/2023/2023-03-08-using-laminar-for-selfhosted-ci.md b/content/posts/2023/2023-03-08-using-laminar-for-selfhosted-ci.md new file mode 100644 index 0000000..7c784b8 --- /dev/null +++ b/content/posts/2023/2023-03-08-using-laminar-for-selfhosted-ci.md @@ -0,0 +1,64 @@ +--- +date: 2023-03-08 +title: Using Laminar for Self-hosted CI +tags: +- Bash +- CI +- Git +- Linux +--- + +I've hosted my [own git repositories](https://git.tyil.nl) for quite a while, +but I hadn't found a simple self-hosted CI solution yet. I've tried several, +and found them to be a bit too cumbersome to setup and actually put to use. The +majority requires you to host a full "git forge", such as GitLab or Gitea, in +order to use their webhook functionality in order to trigger a CI build. This +didn't seem worth the effort to me, so I kept looking for an alternative that +worked well for me. + +I think I've finally found one in [Laminar](https://laminar.ohwg.net/), after a +suggestion from a friend on the Fediverse. I do wonder how I could've spent so +much time searching without ever finding this solution! + +Laminar itself was easy to install from source, but another person chimed in to +let me know they already made an `ebuild` for it, which is available in their +overlay, making it even easier for me to try out. A single `emerge laminar`, +and a couple seconds of building it, and I was ready to start trying it out. + +Configuration of jobs is done through scripts in whichever language you prefer, +giving you quite a bit of power. The documentation seems to mostly use Bash, +and that seemed to be a logical choice for me too, so that's what I've been +playing with as well. + +Running jobs itself is as easy as `laminarc queue `. It can't be much +simpler, and this CLI interface makes it very easy to start a new job from a +git `post-receive` hook. I wrote one which also shows the URL of the job's logs +whenever I push new comments to [the Bashtard +repository](https://git.tyil.nl/bashtard/about/). + +{{}} +while read old new ref +do + laminarc queue bashtard \ + "GIT_BRANCH=$ref" \ + "GIT_COMMIT=$new" \ + | awk -F: '{ print "https://ci.tyil.nl/jobs/"$1"/"$2 }' +done +{{}} + +Using this, I can verify a job started, and immediately go to the page that +shows the logs. I plan to use Laminar's post-job script to leverage `ntfy` to +send me a notification on failed builds. + +Since all the worthwhile configuration for Laminar is just plain text, it is +also very easy to manage in your preferred configuration management system, +which is also something I plan to do in the nearby future. + +One slight annoyance I have so far is that I can't use (sub)directories for all +the job scripts. Since I don't have many yet, this isn't a real problem yet, +but it could pose a minor issue in the far future once I've written more job +scripts. + +Given that that's the only "issue" I've found thus far, after a couple days of +playing with it, I'd highly recommend taking a look at it if you want to set up +a CI system for your self-hosted git repositories! -- cgit v1.1