Skip to content

Commit

Permalink
CI: Upgrade to FreeBSD 14 and faster virtualization
Browse files Browse the repository at this point in the history
  • Loading branch information
acj committed Dec 31, 2023
1 parent 49441f9 commit 3e78bcc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 51 deletions.
41 changes: 16 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,43 +79,34 @@ jobs:

build-freebsd:
name: Build and test (freebsd-x86_64)
runs-on: macos-12
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
box:
- fbsd_12_2
- fbsd_14
steps:
- uses: actions/checkout@v3
- name: Cache Vagrant box
uses: actions/cache@v3
with:
path: ~/.vagrant.d
key: ${{ matrix.box }}-vagrant-boxes-${{ hashFiles('ci/Vagrantfile') }}
restore-keys: |
${{ matrix.box }}-vagrant-boxes-
- name: Cache Cargo and build artifacts
uses: actions/cache@v3
with:
path: build-artifacts.tar
key: ${{ matrix.box }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ matrix.box }}-cargo-
- name: Display CPU info
run: lscpu
- name: Install VM tools
run: |
sudo apt-get update -qq
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 moreutils
sudo chronic apt-get install -qq -o=Dpkg::Use-Pty=0 vagrant virtualbox qemu libvirt-daemon-system
- name: Set up VM
shell: sudo bash {0}
run: |
vagrant plugin install vagrant-libvirt
ln -sf ci/Vagrantfile Vagrantfile
if [ ! -d ~/.vagrant.d/boxes/rbspy-VAGRANTSLASH-FreeBSD-12.2-STABLE ]; then
vagrant box add rbspy/FreeBSD-12.2-STABLE https://github.com/rbspy/freebsd-vagrant-box/releases/download/20220115-2/fbsd_12_2.box
fi
vagrant up ${{ matrix.box }}
vagrant status
vagrant up --no-tty --provider libvirt ${{ matrix.box }}
- name: Build and test
shell: sudo bash {0}
run: vagrant ssh ${{ matrix.box }} -- bash /vagrant/ci/freebsd-build.sh
- name: Retrieve build artifacts for caching purposes
run: |
vagrant ssh-config --host "default" > config.txt
scp -F config.txt default:/vagrant/build-artifacts.tar .
ls -ahl build-artifacts.tar

release:
name: Create draft release
Expand Down
29 changes: 23 additions & 6 deletions ci/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
Vagrant.configure("2") do |config|
config.vm.define "fbsd_12_2" do |fbsd_12_2|
fbsd_12_2.vm.box = "rbspy/FreeBSD-12.2-STABLE"
config.vm.define "fbsd_14" do |c|
c.vm.box = "roboxes/freebsd14"
end

config.vm.provider "libvirt" do |qe|
# https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html
qe.driver = "kvm"
qe.cpus = 2
qe.memory = 8192
end

config.vm.boot_timeout = 600

config.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__exclude: [".git", ".vagrant.d"]

config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
config.vm.provision "shell", inline: <<~SHELL
set -e
pkg install -y curl bash llvm
chsh -s /usr/local/bin/bash vagrant
pw groupmod wheel -m vagrant
su -l vagrant <<'EOF'
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.74.1
EOF
SHELL
end
23 changes: 3 additions & 20 deletions ci/freebsd-build.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
#!/usr/bin/env bash

source ~/.bash_profile

set -e

ruby -v
cargo --version

sudo pkg install -y llvm

export CARGO_HOME="/vagrant/.cargo"
mkdir -p $CARGO_HOME
source "$HOME/.cargo/env"

cd /vagrant

if [ -f build-artifacts.tar ]; then
tar xf build-artifacts.tar
rm -f build-artifacts.tar
fi

cargo build --release
cargo test --release

tar cf build-artifacts.tar target
tar rf build-artifacts.tar .cargo/git || true
tar rf build-artifacts.tar .cargo/registry || true
cargo build --no-default-features --release --workspace --all-targets
cargo test --no-default-features --release

0 comments on commit 3e78bcc

Please sign in to comment.