CI for opam overlay repositories with day10 and GitHub merge queue
This post describes how to set up a CI for an opam overlay repository using day10 on a self-hosted GitHub Actions runner, with GitHub’s merge queue to gate PRs on build regressions.

Setting up Continuous Integration for Opam Overlay Repositories with Day10 and GitHub Merge Queue
In the world of software development, maintaining a robust continuous integration (CI) pipeline is crucial for ensuring code quality and reliability. For those working with Opam, the OCaml package manager, setting up a CI system for overlay repositories can be particularly challenging. This article will guide you through the process of establishing a CI setup using Day10, a self-hosted GitHub Actions runner, and GitHub’s merge queue to gate pull requests (PRs) on build regressions.
Opam overlay repositories are a powerful feature that allows users to extend the default package repository by adding custom packages or modified versions of existing ones. However, managing these overlay repositories can be complex, especially when it comes to ensuring that new changes do not introduce build errors or regressions. By implementing a CI pipeline, developers can automate the testing process, providing immediate feedback on potential issues and maintaining a high standard of code quality.
To begin, you will need to set up a self-hosted GitHub Actions runner. This runner will execute the CI tasks for your Opam overlay repository. Day10, a lightweight alternative to GitHub Actions, is an excellent choice for this purpose. It offers a simple and efficient way to run your CI workflows without relying on the complex infrastructure of the official GitHub Actions platform.
Once your runner is set up, the next step is to configure the CI workflow for your Opam overlay repository. This involves creating a `.github/workflows/ci.yml` file in your repository, which will define the steps to be executed during the CI process. The workflow should include tasks such as cloning the repository, installing dependencies, building the overlay packages, and running tests.
Here’s an example configuration for the CI workflow:
```yaml
name: CI for Opam Overlay
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: [ self-hosted ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up OCaml
uses: ocaml-opam/setup@master
with:
opam-version: 2.2.0
- name: Install dependencies
run: opam install -y -install-deps-as-needed -repository https://opam.ocaml.org/ -repository $(pwd)/overlay
- name: Build overlay packages
run: opam update
- name: Run tests
run: opam test
```
This configuration assumes that your overlay repository is located in a subdirectory named `overlay`. Adjust the paths and repository URLs as needed for your specific setup.
Now that the CI workflow is in place, the next important aspect is to integrate GitHub’s merge queue to gate PRs on build regressions. The merge queue is a feature that allows you to pause the merging of pull requests until certain conditions are met, such as passing CI tests. By enabling the merge queue for your repository, you can ensure that only PRs with successful CI builds are allowed to proceed, preventing regressions from being merged into the main branch.
To enable the merge queue, navigate to your repository settings in GitHub and locate the "Merge Queue" section. Enable the merge queue and configure it to require a successful CI build before allowing PRs to be merged. This will ensure that all PRs are automatically tested and only those that pass the CI checks will be eligible for merging.
In addition to the merge queue, you may also want to consider setting up notifications for failed CI builds. This can be done by configuring the CI workflow to send notifications to your preferred communication channels, such as Slack or email. This will alert you immediately when a PR fails the build, allowing you to address the issue promptly and prevent potential disruptions.
Finally, it’s important to note that while this CI setup is designed for Opam overlay repositories, the principles and tools used can be applied to other package managers and repository types as well. By automating the build and testing process, you can maintain a high level of code quality and ensure that your software remains stable and reliable.
In conclusion, setting up a CI pipeline for an Opam overlay repository using Day10 and GitHub’s merge queue is a powerful way to automate the build and testing process. By following these steps, you can ensure that your overlay repository remains stable, free of regressions, and ready for integration with other projects. With the merge queue and CI workflows in place, developers can confidently contribute to the repository, knowing that their changes will be thoroughly tested before being merged.










