Set up a development checkout
irsync is developed at github.com/irsync-dev/irsync. Clone it and build the workspace:
git clone https://github.com/irsync-dev/irsync
cd irsync
cargo build --workspace
The workspace holds irsync itself and the tools that test it: fileset
(reference), filegen
(Generating test trees), irsync-stress
(Stress testing) and irsync-netstress
(Network stress).
Requirements
dev-setup.sh sets most of this up and checks the rest. It installs
rustup, the toolchain with rustfmt and clippy, the musl target on Linux, the
Rust targets of every platform tools/ci.sh typecheck checks, the
nightly the fuzz targets build with, uv, and cargo-nextest, cargo-deny,
cargo-fuzz, zizmor, dist, actionlint, shellcheck and mdbook. The nightly
is a large download, and only fuzzing and Miri need it. Those eight tools
are downloaded from their release pages and checked against SHA-256s kept
in the script. Cargo builds a tool only where its project has no binary for
your machine, or when the script’s hashes are for another version than
CI’s. There is no shellcheck binary for FreeBSD; there the script names the
package. They are held to the versions CI uses: if you have another
version, it is replaced. It points git at the repo’s hooks. System tools
such as rsync, Python and a C compiler it only checks, naming the package
to install. tools/dev-setup.sh --check reports without changing anything.
Run it again whenever you like.
It works on Linux, macOS and FreeBSD, and names the package for each one’s
package manager (apt, brew, pkg). It does not run on Windows; see
Windows.
- uv, which runs the repository’s Python programs and fetches the Python
they pin (see The scripts).
dev-setup.shdownloads it at CI’s version and checks it against a SHA-256 kept in the script. A newer uv you already have will do;uv self updateupdates one you installed with uv’s own installer.tools/ci.sh checkstops without it. uv has no build of itself or of Python for FreeBSD: there, install both withpkg(sudo pkg install uv python315), and uv uses that Python. - Rust.
rust-toolchain.tomlpins an exact Rust version, which rustup picks up; CI and releases use the same file. To move to a newer Rust, change the version there and run the full regression. - GNU rsync 3.1 or newer on
PATH, forrsync_compare.rs, which compares irsync’s result with rsync’s. Without it the test prints a line and passes, whichcargo test -qhides, so it checks nothing. With theCIenvironment variable set, the test fails instead of skipping. On macOS the bundled rsync (2.6.9 or openrsync) is too old:brew install rsync. curl, and atarthat writes and reads.tar.xz, forssh_release.rs, which builds a small release tarball and downloads it from a local directory. GNU tar needs thexzprogram for that (sudo apt install xz-utils); macOS’s tar has xz built in.- pandoc and mandoc, for the man pages:
tools/build-man.sh OUTDIRbuilds them from the book with pandoc, and the tests intools/testscheck them with mandoc.dev-setup.shchecks both and says how to install them. Thecheckjob fails without them. - groff, optional.
test_groff_renders_without_warningsrenders each page with it and skips without it. It runs on Linux CI. On a Mac,nix-shell -p groffis one way to get it. - minisign 0.10 or newer, optional. Maintainers sign releases with it
(The release signing key), and it makes the
signature test files. Older versions write a signature format that irsync
refuses. The
sign-release.shtests also run with the real minisign when it is there; with theCIenvironment variable set, they fail instead of skipping without it.
Windows
The workspace builds and tests on Windows, on x86_64 and ARM64, without
stress and netstress, the harnesses that need Unix. The Unix-only tests
are behind #[cfg(unix)]. Leave the two harnesses out:
cargo test -q --workspace --exclude stress --exclude netstress --all-features --no-fail-fast
What you need:
- The MSVC Rust toolchain and the MSVC build tools. Only the
x86_64-pc-windows-msvcandaarch64-pc-windows-msvctargets are used, not the GNU toolchain and not 32-bit Windows. Install rustup, and Visual Studio Build Tools with the C++ tools and a Windows SDK. rustup picks up the version inrust-toolchain.toml. - Git Bash, which comes with Git for Windows, to run
ci.sh. The repository’s.gitattributeskeeps the shell scripts with LF line endings in the working tree, which bash needs. - cargo-nextest and uv, which
tools/ci.sh checkruns. Install them by hand: cargo-nextest withcargo install --locked cargo-nextestor a release download, uv withwinget install astral-sh.uvor uv’s own installer.dev-setup.shdoes not run on Windows.tools/ci.sh checkthere needs no Python (uv fetches the one the scripts pin), pandoc, mandoc or rsync. - Developer Mode, for the symlink tests. Making a symlink needs Developer
Mode, an elevated process or the symlink privilege. Without it, a test that
needs a symlink prints a line that starts
skipping:and passes. With theCIenvironment variable set, it fails instead, as the rsync comparison test does (Requirements).filegenfinds the same thing at the start of a run and leaves the symlink operations out (see On Windows). - A short checkout path and a short
CARGO_TARGET_DIR. The MSVC linker fails on a path over 260 characters. CI setsCARGO_TARGET_DIRtoC:\t. Clone somewhere likeC:\w\irsync. - Trees on an NTFS drive. The tests make their trees in the temporary directory, so that drive has to be NTFS too. ReFS, FAT, exFAT, network shares and the folders a virtual machine shares with its host are not supported.
The full regression, in Git Bash:
tools/ci.sh check
On Windows it runs cargo fmt --all --check, the fuzz lock check, one clippy
run, nextest and the doc tests for those crates, and then a smoke run:
filegen fills and changes a tree, and fileset records it and checks it.
Then an irsync daemon on loopback exports the tree, irsync pulls it into
a copy, and fileset checks the copy against the tree’s manifest. The
daemon and the client keep their config, state and keys in the smoke run’s
temporary directory. Last, it runs each Python program’s .cmd stand-in
with --help. A bare ci.sh runs check only, and prints that
on Windows only check runs.
The scripts
The repository’s scripts are moving from shell to Python
(#389), so that they
behave the same on Linux, macOS, FreeBSD and Windows. Each program foo is
three files:
-
foo.py, the program. It starts with#!/usr/bin/env -S uv run --scriptand an inline script block that pins Python, the same in every program:# /// script # requires-python = "==3.15.*" # dependencies = [] # ///uv reads the block, fetches that Python if it is not there yet, and runs the program with it. Third-party packages go into
dependencies. -
foo.sh, a short stand-in that runsfoo.pyunder uv, so the command people type stays as it was, for exampletools/bench-link.sh. -
foo.cmd, the same stand-in for Windows’cmd.exe. It is not PowerShell, because Windows’ execution policy often blocks.ps1files..gitattributesgives.cmdfiles CRLF line endings, whichcmd.exeneeds.
test_uv_programs.py holds
them to this: every .py file that starts with that line has both
stand-ins, exactly as the test writes them, every program pins the same
Python, and each one answers --help. To move to a newer Python, change the
pin in every program at once.
Two kinds of script stay shell: the installers
(site/install.sh and the one in
packaging/installer), which run on
machines that may have no uv, and are tested under both dash and bash; and
the small fake programs the tests put on PATH.
Continuous integration
The workflow in ci.yml runs on GitHub for every push to
main and every pull request, on Linux, macOS and Windows. The workflow installs
the tools; the checks themselves are in ci.sh, one job there per job
in the workflow, so the same script runs them on your machine:
tools/ci.sh # every job
tools/ci.sh check # one job
tools/ci.sh --help
To change what CI checks, change ci.sh.
The check job installs GNU rsync and runs, in this order:
cargo fmt --all --check
python3 -m unittest discover -s tools/tests # tests tools/dev-setup.sh and the man pages
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
cargo clippy --locked --workspace --all-targets --no-default-features -- -D warnings
cargo nextest run --locked --workspace --all-features --profile ci --run-ignored all
cargo test --locked --workspace --all-features --doc
--locked makes the run fail if Cargo.lock is out of date, as the release
build would.
The windows job runs tools/ci.sh check on windows-latest (x86_64) and
windows-11-arm (ARM64), in Git Bash, with CARGO_TARGET_DIR set to C:\t.
It covers the workspace without stress and netstress, as above. CI result
needs it, so a failure there blocks a merge, as on Linux and macOS. A release
run leaves it out.
The release-build job runs the release build itself for the two
Linux targets (x86_64 and arm64 musl): dist build, which runs
build.sh, on the same runners as a release. It checks that release.yml is what
.github/scripts/release-yml.sh write makes, that each tarball holds the three man pages, and
that our installer, run on the tarball with a temporary home, installs a
working irsync and pages that man finds. A change that
would break a release fails here, before anyone tags it. On your machine it
builds the one musl target that matches it, on Linux only, and needs dist
and musl-gcc.
The freebsd-build job builds the FreeBSD tarball with the same build
script. It runs on FreeBSD x86_64 only, and CI does not run it. GitHub runs
it in a workflow you start by hand: see
Testing a version on FreeBSD.
The fuzz-build job builds the fuzz targets in fuzz/ with their pinned
nightly and runs each on its checked-in inputs. The long fuzz runs are in a
nightly workflow; see Fuzzing.
The miri job runs the tests that can run under Miri, which catches
undefined behaviour in unsafe code. It is slow, so it runs only when you
name it, and every night on GitHub; see
Static analysis.
The deny job checks the dependencies with cargo deny, for the platforms
irsync is built for and for both Windows targets, so it also checks the crates
only a Windows build uses. The deny-license-check job checks the licenses of
every platform’s dependencies; on GitHub its failure blocks a release, not
a pull request. The workflows job runs the workflow rule tests, actionlint
and zizmor, which needs PyYAML, actionlint and zizmor
(Supply chain,
Static analysis). The shell-scripts job runs shellcheck on every shell script, on every pull
request. A warning that is wrong for one line is turned off on that line,
with the reason in a comment.
Two things run only on GitHub: the macOS, Windows and arm64 runs, and the dependency review of a pull request.
The tests run with cargo-nextest, which runs each test
in its own process and tests from all files side by side. That makes the
run faster than cargo test, which runs one test file after another. The
ci profile in nextest.toml runs every test even after a failure
and kills a test that runs longer than 5 minutes, naming it. --run-ignored all adds the slow network-fault tests that an everyday cargo test skips
(Testing). nextest does not run doc tests, so cargo test --doc runs those.
On macOS, CI uses the ci-macos profile instead. It leaves out a few slow
tests that work the same on every OS, which Linux CI still runs (see
Platform skips).
The second clippy run keeps the build without the otel feature compiling
(see Cargo features).
For everyday work you don’t need nextest: cargo test runs the same
tests. tools/ci.sh check needs it; dev-setup.sh installs it.
The pre-push hook
pre-push refuses a push whose commits are not rustfmt-clean, so a
formatting slip is caught before CI sees it. Every commit being pushed is
checked with cargo fmt --all -- --check in a throwaway worktree: what counts
is what the remote receives, not the state of the working tree. Install it
once per clone:
git config core.hooksPath .githooks
Before pushing
Clippy and the tests are not part of the hook. Run them yourself:
tools/ci.sh check
This is the full regression, the same script CI’s check job runs. After
a change under .github/, to the dependencies or to the release build, run
ci.sh with no job, which runs CI’s other jobs too.
After a change to Rust code or its tests, also check that it still compiles on the other platforms:
tools/ci.sh typecheck
This runs clippy, with warnings as errors, for Linux (x86_64 and arm64
musl), macOS, FreeBSD and Windows, each on x86_64 and arm64. It needs no
compiler for those platforms: typecheck-target.sh hands the C
build scripts a stand-in that writes empty files, since a check never
links. It finds code that does not compile there, such as a mistake behind
#[cfg(windows)], in a few minutes instead of a CI round. It runs
nothing, so CI still runs the tests. The list of platforms, and the crates
each one checks, is typecheck-targets; on Windows that is
filegen, fileset and irsync-glob; the windows job checks irsync
there with clippy.
dev-setup.sh installs the Rust targets. A run of every job leaves
typecheck out.