diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da9cff3..2f39da6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,9 +25,9 @@ on: required: false env: - HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }} - HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }} - PACKER_LOG: 1 + VAGRANT_BOX_UPDATE_CHECK_DISABLE: 1 + VAGRANT_CHECKPOINT_DISABLE: 1 + VAGRANT_FORCE_COLOR: 1 jobs: build: @@ -55,6 +55,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + path: src - run: >- wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg @@ -62,7 +63,7 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list - run: sudo apt-get update - - run: sudo apt-get install -y --no-install-recommends packer qemu-system-x86 qemu-utils + - run: sudo apt-get install -y --no-install-recommends packer qemu-system-x86 qemu-system-modules-spice qemu-utils vagrant libvirt-daemon-system libvirt-dev dnsmasq - run: sudo apt-get clean -y - run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc - run: sudo docker image prune --all --force @@ -71,8 +72,30 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - run: packer init . + working-directory: src - run: >- packer build ${{ !inputs.publish && '-except vagrant-registry' || '' }} -only qemu.${{ matrix.build }} . + working-directory: src + env: + HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }} + HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }} + PACKER_LOG: 1 + - run: mkdir test + - run: vagrant plugin install --verbose vagrant-libvirt + working-directory: test + - run: vagrant box add --clean --force --no-tty --name ${{ matrix.build }} ../src/*.box + working-directory: test + - run: rm src/*.box + - run: vagrant init --template ../src/test/Vagrantfile.erb ${{ matrix.build }} + working-directory: test + - run: | + sudo mkdir -p /etc/qemu + echo "allow virbr0" | sudo tee /etc/qemu/bridge.conf + sudo chmod u+s /usr/lib/qemu/qemu-bridge-helper + - run: vagrant up --no-tty + working-directory: test + - run: vagrant destroy --force --graceful + working-directory: test diff --git a/Vagrantfile b/Vagrantfile index d49993d..53b4830 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,5 +1,5 @@ Vagrant.configure(2) do |config| - config.vm.provider 'libvirt' do |libvirt, override| + config.vm.provider :libvirt do |libvirt| libvirt.memory = 4096 if File.exist?('/dev/kvm') @@ -34,4 +34,8 @@ Vagrant.configure(2) do |config| end config.vm.synced_folder '.', '/vagrant', disabled: true + + if /^alpine\d+$/ =~ '{{build_name}}' + config.ssh.sudo_command = 'doas -n -u root %c' + end end diff --git a/test/Vagrantfile.erb b/test/Vagrantfile.erb new file mode 100644 index 0000000..d8c31cc --- /dev/null +++ b/test/Vagrantfile.erb @@ -0,0 +1,13 @@ +Vagrant.configure("2") do |config| + config.vm.box = "<%= box_name %>" + <% if box_version -%> + config.vm.box_version = "<%= box_version %>" + <% end -%> + <% if box_url -%> + config.vm.box_url = "<%= box_url %>" + <% end -%> + config.vm.provider :libvirt do |libvirt| + libvirt.qemu_use_session = true + libvirt.video_accel3d = false + end +end