Skip to content

Commit

Permalink
Use libvirt for macOS and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
hummeltech committed Aug 5, 2024
1 parent 40eb54c commit 8c3d2ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
strategy:
matrix:
box:
- generic/arch
- generic/debian12
fail-fast: false
steps:
- name: Checkout code
Expand Down
55 changes: 17 additions & 38 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,21 @@ runs:
sudo apt-get --yes install \
libvirt-daemon-system \
qemu \
vagrant \
virtualbox
vagrant
shell: bash
if: runner.os == 'Linux'

- name: Install/Upgrade Vagrant (macOS)
run: |
brew install --cask --force --quiet vagrant virtualbox
brew install --cask --force --quiet vagrant
brew install --force --quiet libvirt qemu
shell: bash
if: runner.os == 'macOS'

- name: Start libvirtd (macOS)
run: |
brew services start libvirt
echo "LIBVIRT_DEFAULT_URI=qemu:///session?socket=${HOME}/.cache/libvirt/libvirt-sock" >> ${GITHUB_ENV}
shell: bash
if: runner.os == 'macOS'

Expand All @@ -100,38 +107,18 @@ runs:
fi
shell: bash

- name: Install Vagrant libvirt Plugin (Linux)
- name: Install Vagrant libvirt Plugin
run: |
vagrant plugin install vagrant-libvirt
sudo setfacl -m user:$USER:rw /var/run/libvirt/libvirt-sock
shell: bash
if: runner.os == 'Linux'

- name: Generate Vagrantfile (Linux)
- name: Update libvirt-sock permissions (Linux)
run: |
cat > Vagrantfile <<EOF
Vagrant.configure("2") do |config|
config.ssh.compression = false
config.ssh.connect_timeout = ${{ inputs.connect_timeout }}
config.ssh.forward_env = ["*"]
config.ssh.shell = "bash"
config.ssh.username = "${{ inputs.vagrant_ssh_username }}"
config.vm.boot_timeout = ${{ inputs.boot_timeout }}
config.vm.box = "${{ inputs.box }}"
config.vm.box_check_update = false
config.vm.provider :libvirt do |v|
v.cpus = ${{ inputs.cpus }}
v.driver = "kvm"
v.memory = ${{ inputs.memory }}
end
config.vm.provision "shell", inline: "${{ inputs.provision_commands }}"
config.vm.synced_folder ".", "/vagrant", disabled: true
end
EOF
sudo setfacl -m user:$USER:rw /var/run/libvirt/libvirt-sock
shell: bash
if: runner.os == 'Linux'

- name: Generate Vagrantfile (macOS)
- name: Generate Vagrantfile
run: |
cat > Vagrantfile <<EOF
Vagrant.configure("2") do |config|
Expand All @@ -143,7 +130,7 @@ runs:
config.vm.boot_timeout = ${{ inputs.boot_timeout }}
config.vm.box = "${{ inputs.box }}"
config.vm.box_check_update = false
config.vm.provider :virtualbox do |v|
config.vm.provider :libvirt do |v|
v.cpus = ${{ inputs.cpus }}
v.memory = ${{ inputs.memory }}
end
Expand All @@ -152,24 +139,16 @@ runs:
end
EOF
shell: bash
if: runner.os == 'macOS'

- name: Show Vagrant Status
run: |
vagrant status
shell: bash

- name: Start Vagrant Environment (Linux)
run: |
vagrant up --provider libvirt
shell: bash
if: runner.os == 'Linux'

- name: Start Vagrant Environment (macOS)
- name: Start Vagrant Environment
run: |
vagrant up
time vagrant up --debug --provider libvirt
shell: bash
if: runner.os == 'macOS'

- name: Save OpenSSH configuration to ~/.ssh/config
run: |
Expand Down

0 comments on commit 8c3d2ad

Please sign in to comment.