This repository provides a GitHub action for running builds and tests on a hardenedBSD virtual machine. It is inspired by the vmactions project that provides a similar service for the mainstream BSD operating systems (FreeBSD, OpenBSD, NetBSD, etc). Their work inspired me and it was adapted for hardenedBSD.
The following is an example GitHub workflow that uses this action to run
tests on a hardenedBSD virtual machine. It checks out the code, boots the
VM, installs the Go programming language, and then runs make test on the
virtual machine:
name: My workflow
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run test
uses: 0x1eef/hardenedbsd-vm@v1
with:
release: '16-CURRENT'
run: |
mdo -u root pkg-static install -y go
make testAll GitHub actions accept inputs via the "with" directive. This action provides the following input variables. Some are hardcoded for now but others can be customized:
- run
The command to run on the hardenedBSD virtual machine.
This can be any valid shell command(s). - mem
The amount of memory to allocate for the VM.
This defaults to 6144MB but can be customized. - cpu
The number of CPU cores to allocate for the VM.
This defaults to all available cores but can be customized. - copyback
Whether to copy back the VM content to the host machine after the run.
This defaults to true, and can be customized. - release
The hardenedBSD release to use.
This is always16-CURRENTfor now. - arch
The CPU architecture.
This is always x86_64 for now. - filesystem
The filesystem type.
This is always ufs for now.
At the time of writing, the virtual machine has 4 vCPU cores and 6GB of RAM by default. This can be decreased but not increased unless GitHub increase the resources available on the host machine. The VM image is 80GB in size and that leaves roughly 65GB of free space for the user to use.
The virtual machine is configured to run your commands as the runner
user although root privileges can be obtained with the
mdo(1)
utility (eg mdo -u root <command>).
It is recommended (but not required) to use pkg-static instead of pkg for installing packages because the former is less error prone in the virtual machine environment – where the base system can be more recent than the package repository or vice versa and that can sometimes cause errors related to dynamic libraries or complaints about version mismatches.
This is a quirk of how the virtual machine images and pkg repositories are built manually by two different people, and I try to minimize it happening as much as possible with a long-term solution in the works:
mdo -u root pkg-static install -y <package>