From 24259b48fc0aaacd521b5aa94b4a79c0e2cd1144 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 11 Nov 2026 14:00:54 +0100 Subject: [PATCH 1/3] tests: drop a pointless cast threads() already returns a u64 and clippy complains about the cast. No functional changes. Signed-off-by: Christian Brauner (Amutable) --- tests/exhaustive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/exhaustive.rs b/tests/exhaustive.rs index 02120a3..c136c45 100644 --- a/tests/exhaustive.rs +++ b/tests/exhaustive.rs @@ -201,7 +201,7 @@ fn every_second_round_trips() { #[test] fn every_timestamp_word_round_trips() { - let n = threads() as u64; + let n = threads(); let span = (1u64 << 32) / n; thread::scope(|s| { for t in 0..n { From 2cf637c57b444dec5e9e69589cf9f7aa982e7961 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 11 Nov 2026 14:00:55 +0100 Subject: [PATCH 2/3] clippy: set the minimum rustc version meson provides a clippy target out of the box. Without a Cargo.toml clippy has no idea that ufat has to build with rustc 1.85 though, so it suggests is_multiple_of() which only became stable in rustc 1.87. Tell it about the minimum version in clippy.toml. clippy looks for clippy.toml in the directory it runs in and in the ones above it. The clippy target runs it in the build directory, so it only finds the file when the build directory is below the source directory. Document that and CLIPPY_CONF_DIR in HACKING.md. Signed-off-by: Christian Brauner (Amutable) --- HACKING.md | 13 +++++++++++++ clippy.toml | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 clippy.toml diff --git a/HACKING.md b/HACKING.md index eefd8b6..7470a6d 100644 --- a/HACKING.md +++ b/HACKING.md @@ -58,6 +58,19 @@ The code is formatted with rustfmt. rustfmt.toml sets the line width to 120 columns. The `rustfmt` target formats the code. The `style` test suite checks the formatting. A plain `meson test` leaves it out. +## Lints + + meson compile -C build + ninja -C build clippy + +The `clippy` target runs clippy on every crate. Run it after the build. +In a build directory set up with `--werror`, every clippy warning fails +the target. clippy.toml sets the oldest rustc ufat builds with, so clippy +does not suggest functions that rustc 1.85 lacks. clippy reads +clippy.toml when the build directory is inside the source directory. For +a build directory elsewhere, set `CLIPPY_CONF_DIR` to the source +directory. + ## The case folding table src/name/fold_table.rs is generated by tools/fold-table.rs. It holds the diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..2d83a3c --- /dev/null +++ b/clippy.toml @@ -0,0 +1,2 @@ +# The oldest rustc ufat builds with, see rust_msrv in meson.build. +msrv = "1.85" From 3413cbdfc79e6822b0e095ff9b4449e62da595e6 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 11 Nov 2026 14:00:56 +0100 Subject: [PATCH 3/3] ci: add GitHub Actions workflows Build and test ufat for every pull request, every push to main and once a week: - build with rustc 1.85 and the current stable rustc on x86_64 and aarch64 with --werror, run the tests and check that the installed binary is a static-pie - check the case folding table with rustc 1.85 - run rustfmt and clippy - run the exhaustive sweeps - run the fuzzing campaign, with 5000 iterations in the weekly run - generate the coverage report and put it into the job summary - build every Kani proof with --only-codegen Everything runs on Ubuntu 26.04 whose meson is new enough and whose varlinkctl knows --push-fd. The tests skip what they can't find. So the build jobs first check that mkfs.fat, fsck.fat, mtools and varlinkctl are there. Otherwise a missing package would make the reference tests skip without anyone noticing. Running the Kani proofs takes far more time and memory than a GitHub runner has. So CI only makes sure that they still build and the real runs stay where they are. The actions are pinned to the same commits systemd uses and dependabot bumps them once a month. Signed-off-by: Christian Brauner (Amutable) --- .github/dependabot.yml | 15 +++ .github/workflows/ci.yml | 254 +++++++++++++++++++++++++++++++++++++++ HACKING.md | 18 +++ 3 files changed, 287 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9d292ea --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + actions: + patterns: + - "*" + cooldown: + default-days: 7 + open-pull-requests-limit: 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d7237a0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,254 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# The build and the tests with the oldest and the newest rustc on x86_64 +# and aarch64, the lints, the exhaustive sweeps, a fuzzing run, the +# coverage report and a compile check of the Kani proofs. See HACKING.md. + +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + # Weekly, which catches a new stable rustc or runner image, with a + # longer fuzzing run. + - cron: '17 3 * * 1' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +defaults: + run: + shell: bash + +jobs: + build: + name: Build and test (${{ matrix.runner }}, rustc ${{ matrix.rust }}) + runs-on: ${{ matrix.runner }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + # Ubuntu 26.04 has meson >= 1.4 and a varlinkctl with --push-fd. + runner: [ubuntu-26.04, ubuntu-26.04-arm] + rust: ['1.85.0', stable] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends meson ninja-build dosfstools mtools + + - name: Install rustc ${{ matrix.rust }} + env: + RUST: ${{ matrix.rust }} + run: | + rustup toolchain install "$RUST" --profile minimal + rustup default "$RUST" + rustc --version + + - name: Check for the reference tools + # The tests skip what they cannot find. Here they must not. + run: | + export PATH=$PATH:/usr/sbin:/sbin + for tool in mkfs.fat fsck.fat mcopy mdir mmd mtype sha256sum mkfifo varlinkctl; do + command -v "$tool" || { echo "::error::$tool is missing"; exit 1; } + done + varlinkctl --help | grep -- --push-fd >/dev/null || { echo "::error::varlinkctl has no --push-fd"; exit 1; } + + - name: Configure + run: meson setup --werror -Dslow-tests=true build + + - name: Build + run: | + meson compile -C build + # The helpers that are not built by default. + ninja -C build tools/fold-table-gen tests/fuzz/fuzz-seeds bench/measure bench/genfile + + - name: Test + run: meson test -C build --no-suite slow --print-errorlogs + + - name: Check the case folding table + if: matrix.rust == '1.85.0' + run: meson compile -C build check-fold-table + + - name: Install + run: | + meson install -C build --destdir "$PWD/destdir" + file destdir/usr/local/bin/ufat | grep static-pie + + - name: Upload the test logs + if: failure() + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: meson-logs-${{ matrix.runner }}-${{ matrix.rust }} + path: build/meson-logs/ + + lint: + name: rustfmt and clippy + runs-on: ubuntu-26.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends meson ninja-build + + - name: Install rustc + run: | + rustup toolchain install stable --profile minimal --component clippy,rustfmt + rustup default stable + rustc --version + + - name: Configure + run: meson setup --werror -Dslow-tests=true build + + - name: rustfmt + run: meson test -C build --suite style --print-errorlogs + + - name: clippy + run: | + meson compile -C build + ninja -C build clippy + + slow: + name: Exhaustive sweeps + runs-on: ubuntu-26.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends meson ninja-build + + - name: Configure + run: meson setup --werror -Dslow-tests=true build + + - name: Test + run: meson test -C build --suite slow --print-errorlogs + + fuzz: + name: Fuzz + runs-on: ubuntu-26.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends meson ninja-build dosfstools mtools + + - name: Configure + run: meson setup build + + - name: Fuzz + env: + ITERATIONS: ${{ github.event_name == 'schedule' && '5000' || '200' }} + run: meson compile -C build fuzz + + - name: Upload the findings + if: failure() + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: fuzz + path: build/fuzz/out/ + + coverage: + name: Coverage + runs-on: ubuntu-26.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends meson ninja-build dosfstools mtools + + - name: Install rustc + run: | + rustup toolchain install stable --profile minimal --component llvm-tools + rustup default stable + rustc --version + + - name: Configure + run: meson setup -Db_coverage=true build + + - name: Test + run: meson test -C build --print-errorlogs + + - name: Report + run: | + # llvm-tools matches the LLVM of rustc. + bin=$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n 's/^host: //p')/bin + LLVM_PROFDATA=$bin/llvm-profdata LLVM_COV=$bin/llvm-cov meson compile -C build coverage-report + { + echo '```' + cat build/coverage/report.txt + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + + - name: Upload the report + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: coverage + path: build/coverage/report.txt + + kani: + name: Kani proofs build + runs-on: ubuntu-26.04 + timeout-minutes: 30 + env: + KANI_VERSION: 0.68.0 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends meson ninja-build + + - name: Install Kani ${{ env.KANI_VERSION }} + run: | + cargo install --locked kani-verifier --version "$KANI_VERSION" + cargo kani setup + + - name: Configure + run: meson setup build + + - name: Build the proofs + # Running them takes more time and memory than a runner has. This + # only checks that every harness builds, the slow ones and the one + # of the directory index included. + env: + SLOW: 1 + DIR: 1 + KANI_FLAGS: -Z stubbing -Z unstable-options --only-codegen + run: meson compile -C build verify diff --git a/HACKING.md b/HACKING.md index 7470a6d..1c2992f 100644 --- a/HACKING.md +++ b/HACKING.md @@ -192,3 +192,21 @@ checks that `ufat assemble` and `mkfs.fat` write the same bytes. `BENCH_CASES=` selects cases by a regular expression. The other settings are described at the top of bench/run.sh. The results are in `$BENCH_DIR/out/summary.txt`. + +## Continuous integration + +GitHub Actions runs .github/workflows/ci.yml for every pull request, for +every push to main and once a week. It runs: + +- the build and the tests with rustc 1.85 and with the current stable + rustc, on x86_64 and aarch64, with `--werror`, +- `check-fold-table` with rustc 1.85, +- rustfmt and clippy, +- the exhaustive sweeps, +- the fuzzing campaign, with 5000 iterations in the weekly run, +- the coverage report, which is shown in the job summary, +- Kani with `--only-codegen`, which checks that every proof builds. The + proofs themselves need more time and memory than the CI has. + +The build jobs fail when mkfs.fat, fsck.fat, mtools or a varlinkctl with +`--push-fd` is missing, instead of skipping the tests that need them.