Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FreeBSD CI #639

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,46 +118,48 @@ jobs:
path: dist

build-freebsd:
runs-on: macos-latest
runs-on: ubuntu-22.04
needs: [lint]
timeout-minutes: 30
strategy:
matrix:
include:
- box: fbsd_13_1
release: FreeBSD-13.1-STABLE
url: https://github.com/rbspy/freebsd-vagrant-box/releases/download/20221112/fbsd_13_1.box
box:
- freebsd-14
steps:
- uses: actions/checkout@v3
- name: Cache Vagrant box
uses: actions/[email protected]
with:
path: ~/.vagrant.d
key: ${{ matrix.box }}-vagrant-boxes-20221112-${{ hashFiles('ci/Vagrantfile') }}
path: .vagrant.d
key: ${{ matrix.box }}-vagrant-boxes-20231115-${{ hashFiles('ci/Vagrantfile') }}
restore-keys: |
${{ matrix.box }}-vagrant-boxes-20221112-
${{ matrix.box }}-vagrant-boxes-20231115-
- name: Cache Cargo and build artifacts
uses: actions/[email protected]
with:
path: build-artifacts.tar
key: ${{ matrix.box }}-cargo-20221112-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.box }}-cargo-20231115-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.box }}-cargo-20221112-
${{ matrix.box }}-cargo-20231115-
- name: Display CPU info
run: lscpu
- name: Install VM tools
run: |
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: |
brew install vagrant
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-scp

ln -sf ci/Vagrantfile Vagrantfile

if [ ! -d ~/.vagrant.d/boxes/rbspy-VAGRANTSLASH-${{ matrix.release }} ]; then
vagrant box add --no-tty rbspy/${{ matrix.release }} ${{ matrix.url }}
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/test_freebsd.sh
- name: Retrieve build artifacts for caching purposes
shell: sudo bash {0}
run: |
vagrant scp ${{ matrix.box }}:/vagrant/build-artifacts.tar build-artifacts.tar
ls -ahl build-artifacts.tar
Expand Down
27 changes: 17 additions & 10 deletions ci/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
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 "freebsd-14" do |c|
c.vm.box = "roboxes/freebsd14"
end
config.vm.define "fbsd_13_1" do |c|
c.vm.box = "rbspy/FreeBSD-13.1-STABLE"

config.vm.boot_timeout = 600

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

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

config.vm.provision "shell", inline: <<~SHELL
pkg install -y python devel/llvm11
set -e
pkg install -y curl bash python 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.73.0
EOF
SHELL

config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
end
11 changes: 7 additions & 4 deletions ci/test_freebsd.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/usr/bin/env bash

source ~/.bash_profile
source "$HOME/.cargo/env"

set -e

python --version
cargo --version

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

cd /vagrant

if [ -f build-artifacts.tar ]; then
echo "Unpacking cached build artifacts..."
tar xf build-artifacts.tar
rm -f build-artifacts.tar
fi

cargo build --release --workspace --all-targets
cargo test --release

set +e
tar cf build-artifacts.tar target
tar rf build-artifacts.tar "$HOME/.cargo/git"
tar rf build-artifacts.tar "$HOME/.cargo/registry"

exit 0
Loading