on: [push]

name: build

jobs:

  msrv:
    name: bcachefs-tools-msrv
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Disable initramfs update
        run: sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
      - name: Disable man-db update
        run: sudo rm -f /var/lib/man-db/auto-update
      - name: Install build-deps
        run: |
          sudo apt-get update && sudo apt-get -y --no-install-recommends install pkg-config libaio-dev libblkid-dev \
              libkeyutils-dev liblz4-dev libsodium-dev liburcu-dev libzstd-dev \
              uuid-dev zlib1g-dev valgrind libudev-dev python3-docutils libclang-dev
      - name: Extract MSRV
        run: |
          MSRV=$(cargo metadata --format-version 1 --no-deps |
                  jq -r '.packages[] | select(.name == "bcachefs-tools") | .rust_version')
          echo "MSRV=$MSRV" >> $GITHUB_ENV
      - name: Install Rust ${{ env.MSRV }} toolchain
        run: |
          rustup install --profile minimal ${{ env.MSRV }}
      - name: Make
        run: |
          CARGO_TOOLCHAIN_VERSION=${{ env.MSRV }} make -j`nproc`
