Skip to content

Developing for emulate

Mario Campos edited this page Jun 15, 2022 · 9 revisions

Repository Layout

  • action.yml
    • This file defines the GitHub Action and all of the inputs. It also serves as the starting point when a user adds "mario-campos/emulate" to a workflow and runs it. The starting point is a single Bash run step that resolves some "alias" identifiers and "spins up" the VM with Vagrant.
  • BASH_ENV
    • This file is a Bash shell script that does a few things, but most importantly, it "steals" control of the bash process that is executed whenever a run step is evaluated. It's important that we "hijack" it (with the use of the BASH_ENV environment variable), because it allows us to proxy the contents of the run step to the VM, rather than run it in the runner host.
  • $OS-$OS_VERSION
    • These directories contain all of the scripts/code necessary to build and run the Vagrant box. Note that these directories contains files for both creating the Vagrant box of the same name (with Packer), and also for booting a Vagrant VM for said box later (with Vagrant). Although the files share the same directory, it is only for convenience.
  • $OS-$OS_VERSION/.pkr.hcl
    • This file is the Packer template file which defines the steps and commands necessary to build the Vagrant box for $OS-$OS_VERSION. Note that this file, and any other files it references, are only relevant for building the Vagrant box that will be subsequently downloaded and spun up.
  • $OS-$OS_VERSION/Vagrantfile
    • This file is the Vagrantfile that controls the VM, such as VirtualBox settings, SSH settings, Box download settings, etc. Although this file is stored in the $OS-$OS_VERSION directory, along with the Packer files, it has no impact on the creation of the Box; the impacts of changing this file occurs when the Action is evaluated, after the Box has been created and uploaded.

Development Environment

Tools

Ensure that you are fully authenticated to both GitHub and Vagrant Cloud. For Vagrant Cloud, the environment variable VAGRANT_CLOUD_TOKEN should be set. For GitHub, ensure that gh auth status is successful.

New Release

  1. Make any changes to release files, such as to .pkr.hcl, that might impact the new Vagrant box.
  2. Build the new Vagrant box:
packer build openbsd-7.0
  1. Test the new box:
vagrant box add packer_default_virtualbox.box --name test
cp openbsd-7.0/Vagrantfile /tmp/
# edit /tmp/Vagrantfile so that config.vm.box references "test"
cd /tmp
vagrant up
# test out the new box
vagrant destroy
vagrant box remove test
  1. Generate the SHA256 checksum of the new box.
shasum -a 256 packer_default_virtualbox.box
  1. Upload the new box to Vagrant Cloud.

  2. Update Vagrantfile, modifying box_download_checksum and box_url with the new SHA256 checksum and URLs, respectively. Be mindful of the URL for the GitHub emulate release. Make sure that the git tag matches the URL here, otherwise you'll need to fix this URL later.

  3. Commit the changes to the local git repository.

  4. Create/update git tags for the new release:

git tag openbsd-7.0_0.1.3  # ${OS}-${OS_VERSION}_${EMULATE_OS_RELEASE}
git tag -f v1
  1. Push the commits and tags:
git push origin main
git push origin openbsd-7.0_0.1.3
git push -f origin v1
  1. Create a release from the new tag:
gh release create openbsd-7.0_0.1.3 packer_default_virtualbox.box
Clone this wiki locally