# Copyright (c) 2023 Sebastian Pipping # 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: # Minimum permissions for security permissions: contents: read jobs: tests: name: Build (${{ matrix.cc }} and ${{ matrix.fuse_package }} on ${{ matrix.runs-on }}) runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false matrix: include: # FUSE 2 - cc: gcc cxx: g++ clang_major_version: null runs-on: ubuntu-22.04 fuse_package: libfuse-dev # FUSE 3 - cc: gcc cxx: g++ clang_major_version: null runs-on: ubuntu-22.04 fuse_package: libfuse3-dev - cc: clang-17 cxx: clang++-17 clang_major_version: 17 runs-on: ubuntu-22.04 fuse_package: libfuse3-dev - cc: clang-18 cxx: clang++-18 clang_major_version: 18 runs-on: ubuntu-22.04 fuse_package: libfuse3-dev # fuse-t, gcc - cc: gcc cxx: g++ clang_major_version: null runs-on: macos-15 fuse_package: fuse-t # fuse-t, clang - cc: clang cxx: clang++ clang_major_version: null runs-on: macos-15 fuse_package: fuse-t steps: - name: Add Clang/LLVM repositories if: "${{ runner.os == 'Linux' && 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_major_version }} main" - name: Install build dependencies if: "${{ runner.os == 'Linux' }}" run: |- sudo apt-get update sudo apt-get install --yes --no-install-recommends \ autoconf \ automake \ ${{ matrix.fuse_package }} \ libtool \ pkg-config \ valgrind - name: Install build dependencies if: "${{ runner.os == 'macOS' }}" run: |- set -x # Installing MacFUSE requires visiting the MacOS recovery environment, # so testing it in CI seems to be hopeless. Therefore we only test with fuse-t. # Apparently the best security is making it so inconvenient that you can't run the thing at all. if [[ ${{ matrix.fuse_package }} = fuse-t ]]; then sudo mkdir -p /usr/local/include # https://github.com/macos-fuse-t/fuse-t/issues/77 brew tap macos-fuse-t/homebrew-cask brew install fuse-t else false # should never get here fi brew install \ autoconf \ automake \ libtool \ pkg-config - name: Install build dependency Clang ${{ matrix.clang_major_version }} if: "${{ runner.os == 'Linux' && contains(matrix.cxx, 'clang') }}" run: |- sudo apt-get install --yes --no-install-recommends -V \ clang-${{ matrix.clang_major_version }} - name: Add versioned aliases for Clang ${{ matrix.clang_major_version }} if: "${{ runner.os == 'macOS' && matrix.clang_major_version != null }}" run: |- set -x sudo ln -s "$(brew --prefix llvm@${{ matrix.clang_major_version }})"/bin/clang /usr/local/bin/clang-${{ matrix.clang_major_version }} sudo ln -s "$(brew --prefix llvm@${{ matrix.clang_major_version }})"/bin/clang++ /usr/local/bin/clang++-${{ matrix.clang_major_version }} - name: Checkout Git branch uses: actions/checkout@v4 - name: 'Bootstrap with ./autogen.sh' run: |- ./autogen.sh - name: 'Configure' env: CC: ${{ matrix.cc }} CXX: ${{ matrix.cxx }} CFLAGS: -Werror run: |- set -x ./configure - name: 'Build' run: |- set -x cpu_threads="$(nproc 2>/dev/null || sysctl -n hw.logicalcpu || echo 4)" make "-j${cpu_threads}" 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-24.04 strategy: fail-fast: false matrix: # TODO: automatically check that this list is up-to-date box: - debian10 - debian11 - freebsd14 - rockylinux9 - ubuntu2004 - ubuntu2204 - ubuntu2404 steps: - name: Install dependencies run: |- set -x sudo sed -i 's/Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources # 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 [arch=$(dpkg --print-architecture) 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 ruby-libvirt sudo apt-get install -y vagrant \ qemu-system-x86 \ autoconf automake libtool pkg-config \ libvirt-daemon-system ebtables libguestfs-tools \ libxslt-dev libxml2-dev zlib1g-dev ruby ruby-dev sudo vagrant plugin install vagrant-libvirt - name: Checkout Git branch uses: actions/checkout@v4 - name: Check for KVM run: |- # This check is probably obsolete now: https://github.com/actions/runner-images/discussions/7191 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: |- # We use vagrant with sudo because it has proven stupendously difficult to # get the current shell into group "libvirt" in a way that Vagrant is happy with. # https://github.com/actions/runner-images/discussions/5981 sudo chmod a+rx /root # Give libvirt access to /root/.vagrant.d which is about to be created sudo ruby vagrant/test.rb --print-logs ${{ matrix.box }}