diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2023-11-12 20:43:24 +0200 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2023-11-19 21:30:18 +0200 |
commit | bea88937f4564e282063fb44aeac485012cfae87 (patch) | |
tree | 51c60f83d52d394974d8c6d805db661b96c8e67b | |
parent | 1fdf240aec17b6525ee2ebc76152ea8109f83595 (diff) | |
download | bindfs-bea88937f4564e282063fb44aeac485012cfae87.tar.gz |
CI: run Vagrant tests.
-rw-r--r-- | .github/workflows/linux.yml | 95 | ||||
-rw-r--r-- | .github/workflows/tests.yml | 159 | ||||
-rw-r--r-- | vagrant/centos8/Vagrantfile | 5 | ||||
-rw-r--r-- | vagrant/debian10/Vagrantfile | 3 | ||||
-rw-r--r-- | vagrant/debian11/Vagrantfile | 3 | ||||
-rw-r--r-- | vagrant/freebsd12/Vagrantfile | 3 | ||||
-rwxr-xr-x | vagrant/test.rb | 12 | ||||
-rw-r--r-- | vagrant/ubuntu1804/Vagrantfile (renamed from vagrant/bionic64/Vagrantfile) | 7 | ||||
-rw-r--r-- | vagrant/ubuntu2004/Vagrantfile (renamed from vagrant/xenial64/Vagrantfile) | 7 | ||||
-rw-r--r-- | vagrant/ubuntu2204/Vagrantfile | 28 |
10 files changed, 220 insertions, 102 deletions
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index cef2939..0000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright (c) 2023 Sebastian Pipping <sebastian@pipping.org> -# Licensed under GPL v2 or later - -name: Build on Linux - -on: - pull_request: - push: - schedule: - - cron: '0 3 * * 5' # Every Friday at 3am - workflow_dispatch: - -jobs: - linux: - name: Build (${{ matrix.cc }} on ${{ matrix.runs-on }}) - runs-on: ${{ matrix.runs-on }} - strategy: - fail-fast: false - matrix: - include: - - cc: gcc-13 - cxx: g++-13 - clang_major_version: null - clang_repo_suffix: null - runs-on: ubuntu-22.04 - - cc: clang-17 - cxx: clang++-17 - clang_major_version: 17 - clang_repo_suffix: -17 - runs-on: ubuntu-22.04 - - cc: clang-18 - cxx: clang++-18 - clang_major_version: 18 - clang_repo_suffix: - runs-on: ubuntu-22.04 - steps: - - name: Add Clang/LLVM repositories - if: "${{ contains(matrix.cxx, 'clang') }}" - run: |- - set -x - source /etc/os-release - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}${{ matrix.clang_repo_suffix }} main" - - - name: Install build dependencies - run: |- - sudo apt-get update - sudo apt-get install --yes --no-install-recommends \ - autoconf \ - automake \ - libfuse3-dev \ - libtool \ - pkg-config - - - name: Install build dependency Clang ${{ matrix.clang_major_version }} - if: "${{ contains(matrix.cxx, 'clang') }}" - run: |- - sudo apt-get install --yes --no-install-recommends -V \ - clang-${{ matrix.clang_major_version }} - - - name: Checkout Git branch - uses: actions/checkout@v4 - - - name: 'Bootstrap with ./autogen.sh' - run: |- - ./autogen.sh - - - name: 'Configure' - env: - CFLAGS: -Werror - run: |- - set -x - ./configure - - - name: 'Build' - run: |- - set -x - make -j$(nproc) VERBOSE=1 - - - name: 'Test as non-root' - run: |- - set -x - whoami - make check - - - name: 'Test as root' - run: |- - set -x - sudo make check - - - name: 'Install' - run: |- - set -x -o pipefail - make install DESTDIR="${PWD}"/ROOT/ - find ROOT/ | sort | xargs ls -ld diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c7a3317 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,159 @@ +# Copyright (c) 2023 Sebastian Pipping <sebastian@pipping.org> +# Licensed under GPL v2 or later + +name: Build and test + +on: + pull_request: + push: + schedule: + - cron: '0 3 * * 5' # Every Friday at 3am + workflow_dispatch: + +jobs: + linux: + name: Build and test (${{ matrix.cc }} on ${{ matrix.runs-on }}) + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + - cc: gcc-13 + cxx: g++-13 + clang_major_version: null + clang_repo_suffix: null + runs-on: ubuntu-22.04 + - cc: clang-17 + cxx: clang++-17 + clang_major_version: 17 + clang_repo_suffix: -17 + runs-on: ubuntu-22.04 + - cc: clang-18 + cxx: clang++-18 + clang_major_version: 18 + clang_repo_suffix: + runs-on: ubuntu-22.04 + steps: + - name: Add Clang/LLVM repositories + if: "${{ contains(matrix.cxx, 'clang') }}" + run: |- + set -x + source /etc/os-release + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}${{ matrix.clang_repo_suffix }} main" + + - name: Install build dependencies + run: |- + sudo apt-get update + sudo apt-get install --yes --no-install-recommends \ + autoconf \ + automake \ + libfuse3-dev \ + libtool \ + pkg-config + + - name: Install build dependency Clang ${{ matrix.clang_major_version }} + if: "${{ contains(matrix.cxx, 'clang') }}" + run: |- + sudo apt-get install --yes --no-install-recommends -V \ + clang-${{ matrix.clang_major_version }} + + - name: Checkout Git branch + uses: actions/checkout@v4 + + - name: 'Bootstrap with ./autogen.sh' + run: |- + ./autogen.sh + + - name: 'Configure' + env: + CFLAGS: -Werror + run: |- + set -x + ./configure + + - name: 'Build' + run: |- + set -x + make -j$(nproc) VERBOSE=1 + + - name: 'Test as non-root' + run: |- + set -x + whoami + make check + + - name: 'Test as root' + run: |- + set -x + sudo make check + + - name: 'Install' + run: |- + set -x -o pipefail + make install DESTDIR="${PWD}"/ROOT/ + find ROOT/ | sort | xargs ls -ld + + vagrant: + name: Run Vagrant tests + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + # TODO: automatically check that this list is up-to-date + box: + - centos8 + - debian10 + - debian11 + #- freebsd12 # https://github.com/mpartel/bindfs/issues/144#issuecomment-1807258383 + - ubuntu1804 + - ubuntu2004 + - ubuntu2204 + steps: + - name: Install dependencies + run: |- + set -x + for FILE in /etc/apt/sources.list /etc/apt/sources.list.d/*; do + if [[ -e "${FILE}" ]]; then + sudo sed -i 's/# deb-src /deb-src /' "${FILE}" + fi + done + + # The following is based on these instructions: + # https://developer.hashicorp.com/vagrant/install?product_intent=vagrant + # https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html + + wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg + 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 + sudo apt-get update + sudo apt-get build-dep vagrant ruby-libvirt + sudo apt-get install -y vagrant \ + qemu-system-x86 \ + autoconf automake libtool pkg-config \ + qemu libvirt-daemon-system ebtables libguestfs-tools \ + libxslt-dev libxml2-dev zlib1g-dev ruby-dev + vagrant plugin install vagrant-libvirt + sudo adduser "${USER}" libvirt + + - name: Checkout Git branch + uses: actions/checkout@v4 + + - name: 'Generate build files with ./autogen.sh' + run: |- + ./autogen.sh + + - name: Check for KVM + run: |- + if [[ -e /dev/kvm ]]; then + echo "This GitHub Action runner has KVM. This run will be fast." + else + echo "This GitHub Action runner does NOT have KVM. This run will be slow." + fi + + - name: Test with Vagrant box ${{ matrix.box }} + env: + VAGRANT_DEFAULT_PROVIDER: libvirt + run: |- + # sudo needed because the current shell is not yet in group "libvirt" + # https://github.com/actions/runner-images/discussions/5981 + sudo -E -s -u "${USER}" vagrant/test.rb --print-logs ${{ matrix.box }} diff --git a/vagrant/centos8/Vagrantfile b/vagrant/centos8/Vagrantfile index af2cba8..1793dd6 100644 --- a/vagrant/centos8/Vagrantfile +++ b/vagrant/centos8/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : Vagrant.configure("2") do |config| - config.vm.box = "centos/8" + config.vm.box = "roboxes/centos8" config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder "../../", "/bindfs", @@ -14,6 +14,9 @@ Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |v| v.name = "bindfs-centos8" end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end + end config.vm.provision "shell", inline: <<-SHELL # CentOS 8 is EOL diff --git a/vagrant/debian10/Vagrantfile b/vagrant/debian10/Vagrantfile index d56a8f2..f42dbab 100644 --- a/vagrant/debian10/Vagrantfile +++ b/vagrant/debian10/Vagrantfile @@ -14,6 +14,9 @@ Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |v| v.name = "bindfs-debian10" end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end + end config.vm.provision "shell", reboot: true, inline: <<-SHELL export DEBIAN_FRONTEND='noninteractive' diff --git a/vagrant/debian11/Vagrantfile b/vagrant/debian11/Vagrantfile index 138da49..61c3298 100644 --- a/vagrant/debian11/Vagrantfile +++ b/vagrant/debian11/Vagrantfile @@ -14,6 +14,9 @@ Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |v| v.name = "bindfs-debian11" end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end + end config.vm.provision "shell", reboot: true, inline: <<-SHELL export DEBIAN_FRONTEND='noninteractive' diff --git a/vagrant/freebsd12/Vagrantfile b/vagrant/freebsd12/Vagrantfile index 213c18c..d48bc11 100644 --- a/vagrant/freebsd12/Vagrantfile +++ b/vagrant/freebsd12/Vagrantfile @@ -14,6 +14,9 @@ Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |v| v.name = "bindfs-freebsd12" end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end + end config.vm.provision "shell", inline: <<-SHELL pkg update diff --git a/vagrant/test.rb b/vagrant/test.rb index de4ffcc..e7a08f6 100755 --- a/vagrant/test.rb +++ b/vagrant/test.rb @@ -6,6 +6,7 @@ Usage: test.rb [--nohalt] [vm1 [...]] Options: -h --help Print this and exit. --nohalt Don't halt VMs when done. + --print-logs Prints each VM's logs when it completes. If VM names are given, only those are tested. @@ -19,6 +20,7 @@ require 'fileutils' Dir.chdir(File.dirname(__FILE__)) halt_vms = true +print_logs = false specifically_selected_vms = [] ARGV.each do |arg| if arg == '-h' || arg == '--help' @@ -26,6 +28,8 @@ ARGV.each do |arg| exit elsif arg == '--nohalt' halt_vms = false + elsif arg == '--print-logs' + print_logs = true elsif !arg.start_with?('-') specifically_selected_vms << arg else @@ -63,12 +67,12 @@ errors = [] threads = dirs.map do |dir| Thread.new do begin - File.open(dir + "/test.log", "wb") do |logfile| + File.open(dir + "/test.log", "w+b") do |logfile| run_and_log = -> (command) do logfile.puts "" logfile.puts "##### #{command} #####" logfile.flush - pid = Process.spawn(command, chdir: dir, out: logfile, err: :out) + pid = Process.spawn(command, chdir: dir, out: logfile, err: logfile) Process.waitpid(pid) $?.success? end @@ -101,6 +105,10 @@ threads = dirs.map do |dir| mutex.synchronize do puts "Finished VM: #{dir}" end + if print_logs + puts File.read(dir + "/test.log") + puts + end end end end diff --git a/vagrant/bionic64/Vagrantfile b/vagrant/ubuntu1804/Vagrantfile index aab9518..6626a1c 100644 --- a/vagrant/bionic64/Vagrantfile +++ b/vagrant/ubuntu1804/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/bionic64" + config.vm.box = "roboxes/ubuntu1804" config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder "../../", "/bindfs", @@ -12,7 +12,10 @@ Vagrant.configure("2") do |config| rsync__args: ["-av", "--delete-after"] config.vm.provider "virtualbox" do |v| - v.name = "bindfs-bionic64" + v.name = "bindfs-ubuntu1804" + end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end end config.vm.provision "shell", inline: <<-SHELL diff --git a/vagrant/xenial64/Vagrantfile b/vagrant/ubuntu2004/Vagrantfile index 2e79925..c37e5be 100644 --- a/vagrant/xenial64/Vagrantfile +++ b/vagrant/ubuntu2004/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/xenial64" + config.vm.box = "roboxes/ubuntu2004" config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder "../../", "/bindfs", @@ -12,7 +12,10 @@ Vagrant.configure("2") do |config| rsync__args: ["-av", "--delete-after"] config.vm.provider "virtualbox" do |v| - v.name = "bindfs-xenial64" + v.name = "bindfs-ubuntu2004" + end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end end config.vm.provision "shell", inline: <<-SHELL diff --git a/vagrant/ubuntu2204/Vagrantfile b/vagrant/ubuntu2204/Vagrantfile new file mode 100644 index 0000000..06be5fd --- /dev/null +++ b/vagrant/ubuntu2204/Vagrantfile @@ -0,0 +1,28 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "roboxes/ubuntu2204" + + config.vm.synced_folder ".", "/vagrant", disabled: true + config.vm.synced_folder "../../", "/bindfs", + type: "rsync", + rsync__auto: false, + rsync__exclude: ["vagrant"], + rsync__args: ["-av", "--delete-after"] + + config.vm.provider "virtualbox" do |v| + v.name = "bindfs-ubuntu2204" + end + config.vm.provider "libvirt" do |v| + v.driver = if File.exist?('/dev/kvm') then 'kvm' else 'qemu' end + end + + config.vm.provision "shell", inline: <<-SHELL + apt-get update + apt-get install -y fuse libfuse-dev build-essential pkg-config ruby valgrind + apt-get clean + adduser vagrant fuse + echo user_allow_other > /etc/fuse.conf + SHELL +end |