rust/mise.toml
Rama main · réplica de lectura del repositorio original.
# Rust development tasks
#
# Usage: mise run <task> (from this directory) or mise //rust:<task> (from repo root)
[settings]
auto_install = false
[tools]
"github:aya-rs/bpf-linker" = { version = "0.12.0", os = ["linux"] }
"cargo:cargo-deb" = { version = "3.7.0", os = ["linux"] }
"github:taiki-e/cargo-llvm-cov" = "0.6.21"
# Has to match the `gungraun` version in `Cargo.toml`.
"github:gungraun/gungraun" = { version = "0.20.0", os = ["linux"], bin = "gungraun-runner" }
# `matching_regex` skips the npm tarballs the release also carries, so every
# platform gets the bare binary; `bin` gives it a name the shim can use.
"github:getsentry/sentry-cli" = { version = "3.6.2", bin = "sentry-cli", matching_regex = "^sentry-cli-(Darwin|Linux|Windows)-" }
"github:tauri-apps/tauri" = { version = "2.11.2", version_prefix = "tauri-cli-v" }
"aqua:sigstore/cosign" = { version = "3.1.4", os = ["linux"] }
[tools."github:bencherdev/bencher"]
version = "0.6.13"
bin = "bencher"
[tools."github:bencherdev/bencher".platforms]
linux-x64 = { asset_pattern = "bencher-*-linux-x86-64" }
linux-arm64 = { asset_pattern = "bencher-*-linux-arm-64" }
macos-x64 = { asset_pattern = "bencher-*-macos-x86-64" }
macos-arm64 = { asset_pattern = "bencher-*-macos-arm-64" }
windows-x64 = { asset_pattern = "bencher-*-windows-x86-64.exe" }
windows-arm64 = { asset_pattern = "bencher-*-windows-arm-64.exe" }
# The eBPF program is compiled with this exact nightly toolchain: `aya_build`
# invokes it via `rustup run` (see `relay/server/build.rs`; keep the two pins
# in sync). Installing it is a task rather than a `rust` entry in `[tools]`
# because the latter would activate the nightly via `RUSTUP_TOOLCHAIN`,
# overriding `rust-toolchain.toml` for everything else in this directory.
[tasks.install-ebpf-toolchain]
description = "Install the nightly toolchain that the eBPF program is compiled with"
run = "rustup toolchain install nightly-2026-10-17 --profile minimal --component rust-src"
# =============================================================================
# Individual checks (matching CI)
# =============================================================================
[tasks.workspace-crates]
description = "List the name and directory of every crate in the workspace, as JSON"
shell = "bash -c"
hide = true
run = '''
set -euo pipefail
cargo metadata --format-version=1 --no-deps |
jq -ce '[.packages[] | {name, dir: (.manifest_path | sub("/Cargo.toml$"; "") + "/")}]'
'''
[tasks.mobile-test-packages]
description = "Print `-p` flags for `client-ffi` and every workspace crate it depends on for the given target"
usage = 'arg "<triple>"'
shell = "bash -c"
hide = true
run = '''
set -euo pipefail
cargo metadata --format-version=1 --filter-platform "$usage_triple" |
jq -r '
(.resolve.nodes | map({key: .id, value: [.deps[] | select(any(.dep_kinds[]; .kind == null)) | .pkg]}) | from_entries) as $deps
| (.packages | map({key: .id, value: .name}) | from_entries) as $names
| .workspace_members as $members
| [.packages[] | select(.name == "client-ffi") | .id]
| until(. as $s | ($s + [$s[] | $deps[.][]] | unique) == $s; . + [.[] | $deps[.][]] | unique)
| map(select(IN($members[])) | "-p \($names[.])")
| join(" ")'
'''
[tasks.fmt]
description = "Format Rust code"
run = "cargo fmt"
[tasks.fmt-check]
description = "Check Rust formatting (CI check)"
run = "cargo fmt -- --check"
[tasks.clippy]
description = "Run clippy lints (CI check)"
run = "cargo clippy --all-targets --all-features"
[tasks.doc]
description = "Build documentation (CI check)"
run = "cargo doc --all-features --no-deps --document-private-items"
[tasks.shear]
description = "Check for unused dependencies (CI check)"
run = "cargo shear"
[tasks.deny]
description = "Check licenses and security advisories (CI check)"
run = "cargo deny check --hide-inclusion-graph --deny unnecessary-skip --deny no-license-field"
[tasks.test]
description = "Run tests (CI check)"
run = "cargo test --all-features -- --include-ignored --nocapture"
# =============================================================================
# Profiling
# =============================================================================
[tasks.record-perf-client-gateway]
description = "Capture perf data from a locally running headless-client and gateway."
raw = true
run = """
set -u
# Capture every client/gateway process (comma-separated for `perf -p`). Idle ones (e.g. an
# unused `pool-member`) contribute ~no samples, so this avoids guessing which container ran the test.
client=$(pgrep -x firezone-headle | paste -sd, -)
gateway=$(pgrep -x firezone-gatewa | paste -sd, -)
[ -n "$client" ] || { echo "firezone-headless-client is not running" >&2; exit 1; }
freq="${PERF_FREQ:-10000}"
me="$(id -u):$(id -g)"
statpids="$client"; [ -n "$gateway" ] && statpids="$client,$gateway"
echo "Recording: client $client${gateway:+, gateway $gateway}"
echo ">>> run your iperf, then press Ctrl-C to stop <<<"
# Survive Ctrl-C so the EXIT trap can chown; the perf children get the same
# SIGINT and flush their own files.
trap : INT
trap 'for f in perf-client.data perf-gateway.data perf-sched.data perf-stat.txt; do [ -f "$f" ] && sudo chown "$me" "$f" 2>/dev/null; done' EXIT
sudo -v # cache credentials so the background recorders do not each prompt
# Per-process cycles profiles carry the CPU id (--sample-cpu) for migration analysis.
sudo perf record -F "$freq" --call-graph fp --sample-cpu -o perf-client.data -p "$client" &
[ -n "$gateway" ] && sudo perf record -F "$freq" --call-graph fp --sample-cpu -o perf-gateway.data -p "$gateway" &
sudo perf sched record -o perf-sched.data &
sudo perf stat -p "$statpids" -e task-clock,cycles,instructions,cpu-migrations,context-switches,cache-references,cache-misses -o perf-stat.txt &
wait # blocks until Ctrl-C fires the INT trap
wait # reap the recorders once they have flushed
echo "Done: perf-client.data${gateway:+ perf-gateway.data} perf-sched.data perf-stat.txt"
"""
[tasks.setup-perf-env]
description = "Apply the kernel sysctls for connlib perf benchmarking (larger backlog buffers)."
raw = true
run = """
set -u
echo "Applying kernel sysctls ..."
sudo sysctl -w net.core.netdev_max_backlog=100000 # matches the netem limit
sudo sysctl -w net.core.netdev_budget=5000 # drain more per softirq poll
echo "Done (persists until reboot)."
"""
[tasks.pin-cpu]
description = "Pin every CPU core to a fixed frequency (GHz, default 2.5) so boost + thermal throttling stop confounding perf runs."
usage = 'arg "ghz" default="2.5"'
raw = true
run = """
set -u
ghz="${usage_ghz:-2.5}"
khz=$(awk -v g="$ghz" 'BEGIN{printf "%d", g*1000000}')
echo "Pinning all CPUs to ${ghz} GHz (${khz} kHz)..."
# Order-safe: drop the floor, set the ceiling, then raise the floor — works whether
# we are raising or lowering from the current setting. Capping scaling_max disables boost.
for p in /sys/devices/system/cpu/cpu*/cpufreq; do
cat "$p/cpuinfo_min_freq" | sudo tee "$p/scaling_min_freq" >/dev/null
echo "$khz" | sudo tee "$p/scaling_max_freq" >/dev/null
echo "$khz" | sudo tee "$p/scaling_min_freq" >/dev/null
done
echo "Pinned (persists until reboot). Verify the EFFECTIVE clock under load; the chip can"
echo "still throttle below the floor: cycles / task-clock from perf stat, or:"
echo " grep MHz /proc/cpuinfo | sort -u"
"""
# =============================================================================
# Composite tasks
# =============================================================================
[tasks.check]
description = "Run all CI static analysis checks"
depends = ["fmt-check", "clippy", "doc", "deny"]
[tasks.check-all]
description = "Run all CI static analysis checks including unused dependencies"
depends = ["fmt-check", "clippy", "doc", "shear", "deny"]