Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FreeBSD support to CI test workflow #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tunedal
Copy link
Contributor

@tunedal tunedal commented May 15, 2024

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

@WardBrian
Copy link
Owner

This is very cool!

I think I am going to explore if the cpython team would accept this functionality into the stdlib. If not, then I suppose I will be maintaining this package for the long haul, and using something like this would be good for that. Do you think something equivalent for OpenBSD is possible?

@tunedal
Copy link
Contributor Author

tunedal commented May 16, 2024

I don't have any experience with OpenBSD (or Solaris), but I'm pretty sure the same approach should work there. The interface to the CI pipeline is just a Docker container that accepts SSH connections, and any VM should be possible to package that way. So it should be possible to add CI support for those platforms later.

Even if library gets integrated into the standard library (which I hope it will), the CI will probably be useful while getting the code ready for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants