Add FreeBSD support to CI test workflow #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As you mentioned in PR #5, it would be useful to run the tests on FreeBSD in the CI. I have put together a Docker image based on QEMU and the official FreeBSD VM image to solve this:
https://github.com/tunedal/freebsd-qemu-container
It runs the tests on Python 3.8 and 3.11 (instead of 3.12) because that's what's packaged in FreeBSD, but I could update the image to include 3.12 built from source.
Enabling hardware virtualization support substantially speeds up the
pip install
step (from 2.5 minutes to 20 seconds or so), but initializing the VM still takes almost 2 minutes, so I'm not sure how meaningful the difference is. Simply remove--device /dev/kvm
from the workflow YAML if you prefer not to trust the container with access to KVM and run it with software emulation instead.There are other implementations of the same idea, for example:
The advantage of my implementation is that it's comparatively simple and easy to audit: It's just a container, with no special GitHub integration. It's all in a single repo with uncomplicated dependencies and not much code. It doesn't require any special setup, so you should be able to build your own image just by cloning the repo.
If the job is too slow, there might be ways to speed it up: Perhaps removing unneeded devices from the emulator, perhaps caching the VM image externally instead of in the container image, perhaps using QEMU's snapshotting to restore an already booted VM, etc. Caching the pip dependencies in all jobs would probably speed up the workflow as a whole.
You can see an example of a test run here:
https://github.com/tunedal/dllist/actions/runs/9100060051/job/25014027490