diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9fab6b02..a4e55bb0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,9 +39,6 @@ jobs: TARGET: ${{ matrix.arch }}-unknown-linux-gnu steps: - uses: actions/checkout@v4 - with: - # package_deb.sh versions the package from the release tag. - fetch-depth: 0 - run: > sudo apt-get update && sudo apt-get install -y clang-15 libelf-dev m4 pkg-config zlib1g-dev @@ -49,7 +46,7 @@ jobs: with: components: rustfmt - uses: Swatinem/rust-cache@v2 - - run: cargo install --locked cargo-deb + - run: cargo install --locked cargo-deb@3.8.0 - run: cargo build --release --locked --package below --target "$TARGET" # Skip tests that require host to have cgroup2 - run: > @@ -64,7 +61,7 @@ jobs: id: package run: | scripts/package_deb.sh "$TARGET" - package=$(ls target/$TARGET/debian/below_*.deb) + package=$(ls "target/$TARGET"/debian/below_*.deb) test "$(dpkg-deb --field "$package" Architecture)" = "${{ matrix.debarch }}" echo "path=$package" >> "$GITHUB_OUTPUT" - run: scripts/test_deb.sh "${{ steps.package.outputs.path }}" ubuntu:22.04 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c14d8d70..3dad89b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: release on: push: - tags: ["v*"] + tags: ["v[0-9]+.[0-9]+.[0-9]+"] permissions: contents: read @@ -12,7 +12,15 @@ concurrency: cancel-in-progress: false jobs: + version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check the tag matches the Cargo.toml version + run: grep -qx "version = \"${GITHUB_REF_NAME#v}\"" below/Cargo.toml + build: + needs: version uses: ./.github/workflows/build.yml with: upload: true diff --git a/Cargo.lock b/Cargo.lock index 76845fab..067e1f08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,7 +108,7 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "below" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "below-common", @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "below-btrfs" -version = "0.11.0" +version = "0.12.0" dependencies = [ "below-common", "libc", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "below-common" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "chrono", @@ -177,7 +177,7 @@ dependencies = [ [[package]] name = "below-config" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "below-btrfs", @@ -190,7 +190,7 @@ dependencies = [ [[package]] name = "below-dump" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "below-common", @@ -209,7 +209,7 @@ dependencies = [ [[package]] name = "below-ethtool" -version = "0.11.0" +version = "0.12.0" dependencies = [ "nix", "serde", @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "below-gpu-stats" -version = "0.11.0" +version = "0.12.0" dependencies = [ "below-common", "serde", @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "below-model" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "async-trait", @@ -251,7 +251,7 @@ dependencies = [ [[package]] name = "below-render" -version = "0.11.0" +version = "0.12.0" dependencies = [ "below-common", "below-model", @@ -259,7 +259,7 @@ dependencies = [ [[package]] name = "below-store" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "below-common", @@ -285,7 +285,7 @@ dependencies = [ [[package]] name = "below-tc" -version = "0.11.0" +version = "0.12.0" dependencies = [ "netlink-packet-core", "netlink-packet-route", @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "below-view" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "below-common", @@ -320,11 +320,11 @@ dependencies = [ [[package]] name = "below-vmlinux" -version = "0.11.0" +version = "0.12.0" [[package]] name = "below_derive" -version = "0.11.0" +version = "0.12.0" dependencies = [ "proc-macro2", "quote", @@ -466,7 +466,7 @@ checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] name = "cgroupfs" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "below-common", @@ -979,7 +979,7 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" [[package]] name = "fb_procfs" -version = "0.11.0" +version = "0.12.0" dependencies = [ "below-common", "libc", @@ -2106,7 +2106,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "resctrlfs" -version = "0.11.0" +version = "0.12.0" dependencies = [ "below-common", "maplit", diff --git a/below/Cargo.toml b/below/Cargo.toml index eb5b4593..71e57042 100644 --- a/below/Cargo.toml +++ b/below/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "An interactive tool to view and record historical system data" @@ -22,21 +22,21 @@ unit-scripts = "../etc" [dependencies] anyhow = "1.0.104" -below-vmlinux = { version = "0.11.0", path = "vmlinux" } -cgroupfs = { version = "0.11.0", path = "cgroupfs" } +below-vmlinux = { version = "0.12.0", path = "vmlinux" } +cgroupfs = { version = "0.12.0", path = "cgroupfs" } clap = { version = "4.6.2", features = ["derive", "env", "string", "unicode", "wrap_help"] } clap_complete = { version = "4.6.11", features = ["unstable-dynamic"] } -common = { package = "below-common", version = "0.11.0", path = "common" } -config = { package = "below-config", version = "0.11.0", path = "config" } +common = { package = "below-common", version = "0.12.0", path = "common" } +config = { package = "below-config", version = "0.12.0", path = "config" } cursive = { version = "0.21.1", features = ["crossterm-backend"], default-features = false } -dump = { package = "below-dump", version = "0.11.0", path = "dump" } +dump = { package = "below-dump", version = "0.12.0", path = "dump" } indicatif = { version = "0.18.6", features = ["futures", "improved_unicode", "rayon", "tokio"] } libbpf-rs = { version = "0.27.2", default-features = false } libc = "0.2.186" -model = { package = "below-model", version = "0.11.0", path = "model" } +model = { package = "below-model", version = "0.12.0", path = "model" } nix = { version = "0.31.3", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] } plain = "0.2" -procfs = { package = "fb_procfs", version = "0.11.0", path = "procfs" } +procfs = { package = "fb_procfs", version = "0.12.0", path = "procfs" } regex = "1.13.1" scopeguard = "1.2.0" sd-notify = "0.4.5" @@ -45,18 +45,18 @@ serde_json = { version = "1.0.154", features = ["alloc", "float_roundtrip", "raw signal-hook = "0.3.18" slog = { version = "2.8.2", features = ["max_level_trace", "nested-values"] } slog-term = "2.9.2" -store = { package = "below-store", version = "0.11.0", path = "store" } +store = { package = "below-store", version = "0.12.0", path = "store" } tar = "0.4.46" tempfile = "3.27.0" tokio = { version = "1.53.2", features = ["full", "test-util", "tracing"] } -view = { package = "below-view", version = "0.11.0", path = "view" } +view = { package = "below-view", version = "0.12.0", path = "view" } [dev-dependencies] maplit = "1.0" portpicker = "0.1.1" [build-dependencies] -below-vmlinux = { version = "0.11.0", path = "vmlinux" } +below-vmlinux = { version = "0.12.0", path = "vmlinux" } libbpf-cargo = { version = "0.27.2", default-features = false } [features] diff --git a/below/below_derive/Cargo.toml b/below/below_derive/Cargo.toml index d0e8a2b2..1ec1621c 100644 --- a/below/below_derive/Cargo.toml +++ b/below/below_derive/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below_derive" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Proc macros for below" diff --git a/below/btrfs/Cargo.toml b/below/btrfs/Cargo.toml index abb6a316..190a1c64 100644 --- a/below/btrfs/Cargo.toml +++ b/below/btrfs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-btrfs" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "A crate for reading btrfs" @@ -11,7 +11,7 @@ repository = "https://github.com/facebookincubator/below" license = "Apache-2.0" [dependencies] -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } libc = "0.2.186" nix = { version = "0.31.3", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] } openat = "0.1.21" diff --git a/below/build.rs b/below/build.rs index 83032e5f..c728aa7b 100644 --- a/below/build.rs +++ b/below/build.rs @@ -15,12 +15,15 @@ use std::env; use std::ffi::OsString; use std::path::PathBuf; +use std::process::Command; use libbpf_cargo::SkeletonBuilder; const SRC: &str = "./src/bpf/exitstat.bpf.c"; fn main() { + set_git_revision_hash(); + let mut out = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR must be set in build script")); out.push("exitstat.skel.rs"); @@ -45,3 +48,29 @@ fn main() { "In order to build without vendored dependencies please disable default features" ); } + +/// Make the commit available to the build as `BELOW_BUILD_GIT_HASH`, unless +/// HEAD is the `v` release tag. +fn set_git_revision_hash() { + let Some(rev) = git(&["rev-parse", "--short=10", "HEAD"]) else { + return; + }; + let branch = git(&["symbolic-ref", "-q", "HEAD"]); + for git_ref in std::iter::once("HEAD").chain(branch.as_deref()) { + if let Some(path) = git(&["rev-parse", "--git-path", git_ref]) { + println!("cargo:rerun-if-changed={path}"); + } + } + let tag = format!("v{}", env::var("CARGO_PKG_VERSION").unwrap()); + let tags = git(&["tag", "--points-at", "HEAD"]).unwrap_or_default(); + if !tags.lines().any(|t| t == tag) { + println!("cargo:rustc-env=BELOW_BUILD_GIT_HASH={rev}"); + } +} + +fn git(args: &[&str]) -> Option { + let output = Command::new("git").args(args).output().ok()?; + let stdout = String::from_utf8(output.stdout).ok()?; + let stdout = stdout.trim(); + (output.status.success() && !stdout.is_empty()).then(|| stdout.to_string()) +} diff --git a/below/cgroupfs/Cargo.toml b/below/cgroupfs/Cargo.toml index 5b8a0642..a20a35c6 100644 --- a/below/cgroupfs/Cargo.toml +++ b/below/cgroupfs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "cgroupfs" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "A crate for reading cgroupv2 data" @@ -12,8 +12,8 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.104" -below-vmlinux = { version = "0.11.0", path = "../vmlinux" } -common = { package = "below-common", version = "0.11.0", path = "../common" } +below-vmlinux = { version = "0.12.0", path = "../vmlinux" } +common = { package = "below-common", version = "0.12.0", path = "../common" } libbpf-rs = { version = "0.27.2", default-features = false } libc = "0.2.186" nix = { version = "0.31.3", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] } @@ -27,7 +27,7 @@ paste = "1.0.14" tempfile = "3.27.0" [build-dependencies] -below-vmlinux = { version = "0.11.0", path = "../vmlinux" } +below-vmlinux = { version = "0.12.0", path = "../vmlinux" } bindgen = { version = "0.72.1", features = ["logging", "prettyplease", "runtime"], default-features = false } libbpf-cargo = { version = "0.27.2", default-features = false } diff --git a/below/common/Cargo.toml b/below/common/Cargo.toml index d86fcbce..070bdaa6 100644 --- a/below/common/Cargo.toml +++ b/below/common/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-common" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Common below code" diff --git a/below/config/Cargo.toml b/below/config/Cargo.toml index 9bb500c7..c6b822bf 100644 --- a/below/config/Cargo.toml +++ b/below/config/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-config" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Configurations for below" @@ -11,9 +11,9 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.104" -btrfs = { package = "below-btrfs", version = "0.11.0", path = "../btrfs" } -cgroupfs = { version = "0.11.0", path = "../cgroupfs" } -procfs = { package = "fb_procfs", version = "0.11.0", path = "../procfs" } +btrfs = { package = "below-btrfs", version = "0.12.0", path = "../btrfs" } +cgroupfs = { version = "0.12.0", path = "../cgroupfs" } +procfs = { package = "fb_procfs", version = "0.12.0", path = "../procfs" } serde = { version = "1.0.229", features = ["derive", "rc"] } toml = { version = "1.1.8", features = ["preserve_order"] } diff --git a/below/dump/Cargo.toml b/below/dump/Cargo.toml index 03eaa887..78777b47 100644 --- a/below/dump/Cargo.toml +++ b/below/dump/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-dump" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Dump crate for below" @@ -11,16 +11,16 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.104" -below_derive = { version = "0.11.0", path = "../below_derive" } +below_derive = { version = "0.12.0", path = "../below_derive" } clap = { version = "4.6.2", features = ["derive", "env", "string", "unicode", "wrap_help"] } -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } enum-iterator = "2.3.0" -model = { package = "below-model", version = "0.11.0", path = "../model" } +model = { package = "below-model", version = "0.12.0", path = "../model" } regex = "1.13.1" -render = { package = "below-render", version = "0.11.0", path = "../render" } +render = { package = "below-render", version = "0.12.0", path = "../render" } serde_json = { version = "1.0.154", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] } slog = { version = "2.8.2", features = ["max_level_trace", "nested-values"] } -store = { package = "below-store", version = "0.11.0", path = "../store" } +store = { package = "below-store", version = "0.12.0", path = "../store" } toml = { version = "1.1.8", features = ["preserve_order"] } [dev-dependencies] diff --git a/below/ethtool/Cargo.toml b/below/ethtool/Cargo.toml index f1e4a8f1..5ae644d2 100644 --- a/below/ethtool/Cargo.toml +++ b/below/ethtool/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-ethtool" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "ethtool crate for below" diff --git a/below/gpu_stats/Cargo.toml b/below/gpu_stats/Cargo.toml index 8ecf7061..7561c79f 100644 --- a/below/gpu_stats/Cargo.toml +++ b/below/gpu_stats/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-gpu-stats" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "GPU stats crate for below" @@ -10,5 +10,5 @@ repository = "https://github.com/facebookincubator/below" license = "Apache-2.0" [dependencies] -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } serde = { version = "1.0.229", features = ["derive", "rc"] } diff --git a/below/model/Cargo.toml b/below/model/Cargo.toml index 8a150878..821f9762 100644 --- a/below/model/Cargo.toml +++ b/below/model/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-model" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Model crate for below" @@ -12,22 +12,22 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.104" async-trait = "0.1.92" -below_derive = { version = "0.11.0", path = "../below_derive" } -btrfs = { package = "below-btrfs", version = "0.11.0", path = "../btrfs" } -cgroupfs = { version = "0.11.0", path = "../cgroupfs" } -common = { package = "below-common", version = "0.11.0", path = "../common" } +below_derive = { version = "0.12.0", path = "../below_derive" } +btrfs = { package = "below-btrfs", version = "0.12.0", path = "../btrfs" } +cgroupfs = { version = "0.12.0", path = "../cgroupfs" } +common = { package = "below-common", version = "0.12.0", path = "../common" } enum-iterator = "2.3.0" -ethtool = { package = "below-ethtool", version = "0.11.0", path = "../ethtool" } -gpu-stats = { package = "below-gpu-stats", version = "0.11.0", path = "../gpu_stats" } +ethtool = { package = "below-ethtool", version = "0.12.0", path = "../ethtool" } +gpu-stats = { package = "below-gpu-stats", version = "0.12.0", path = "../gpu_stats" } hostname = "0.4.2" os_info = "3.15.0" -procfs = { package = "fb_procfs", version = "0.11.0", path = "../procfs" } +procfs = { package = "fb_procfs", version = "0.12.0", path = "../procfs" } regex = "1.13.1" -resctrlfs = { version = "0.11.0", path = "../resctrlfs" } +resctrlfs = { version = "0.12.0", path = "../resctrlfs" } serde = { version = "1.0.229", features = ["derive", "rc"] } serde_json = { version = "1.0.154", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] } slog = { version = "2.8.2", features = ["max_level_trace", "nested-values"] } -tc = { package = "below-tc", version = "0.11.0", path = "../tc" } +tc = { package = "below-tc", version = "0.12.0", path = "../tc" } [dev-dependencies] futures = { version = "0.3.34", features = ["async-await", "compat"] } diff --git a/below/procfs/Cargo.toml b/below/procfs/Cargo.toml index 1f8eaf18..87db513a 100644 --- a/below/procfs/Cargo.toml +++ b/below/procfs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "fb_procfs" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "A crate for reading procfs" @@ -11,7 +11,7 @@ repository = "https://github.com/facebookincubator/below" license = "Apache-2.0" [dependencies] -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } libc = "0.2.186" nix = { version = "0.31.3", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] } openat = "0.1.21" diff --git a/below/render/Cargo.toml b/below/render/Cargo.toml index c21c61bd..95d7f24a 100644 --- a/below/render/Cargo.toml +++ b/below/render/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-render" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Render crate for below" @@ -10,5 +10,5 @@ repository = "https://github.com/facebookincubator/below" license = "Apache-2.0" [dependencies] -common = { package = "below-common", version = "0.11.0", path = "../common" } -model = { package = "below-model", version = "0.11.0", path = "../model" } +common = { package = "below-common", version = "0.12.0", path = "../common" } +model = { package = "below-model", version = "0.12.0", path = "../model" } diff --git a/below/resctrlfs/Cargo.toml b/below/resctrlfs/Cargo.toml index df6009dd..17b4c2ed 100644 --- a/below/resctrlfs/Cargo.toml +++ b/below/resctrlfs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "resctrlfs" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "A crate for reading resctrl fs data" @@ -11,7 +11,7 @@ repository = "https://github.com/facebookincubator/below" license = "Apache-2.0" [dependencies] -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } nix = { version = "0.31.3", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] } openat = "0.1.21" serde = { version = "1.0.229", features = ["derive", "rc"] } diff --git a/below/src/main.rs b/below/src/main.rs index d552035a..138affa0 100644 --- a/below/src/main.rs +++ b/below/src/main.rs @@ -89,7 +89,16 @@ open_source_shim!(); static LIVE_REMOTE_MAX_LATENCY_SEC: u64 = 10; +/// The crate version, with the commit for builds that aren't a release tag. +fn version() -> String { + match option_env!("BELOW_BUILD_GIT_HASH") { + None => env!("CARGO_PKG_VERSION").to_string(), + Some(hash) => format!("{} (rev {hash})", env!("CARGO_PKG_VERSION")), + } +} + #[derive(Debug, Parser)] +#[clap(version = version())] struct Opt { #[clap(long, value_parser, default_value = config::BELOW_DEFAULT_CONF)] config: PathBuf, diff --git a/below/store/Cargo.toml b/below/store/Cargo.toml index 375eb592..81518467 100644 --- a/below/store/Cargo.toml +++ b/below/store/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-store" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Store crate for below" @@ -13,11 +13,11 @@ license = "Apache-2.0" anyhow = "1.0.104" bitflags = { version = "2.13.2", features = ["serde", "std"], default-features = false } bytes = { version = "1.12.1", features = ["serde"] } -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } humantime = "2.4.0" maplit = "1.0" memmap2 = "0.9.11" -model = { package = "below-model", version = "0.11.0", path = "../model" } +model = { package = "below-model", version = "0.12.0", path = "../model" } nix = { version = "0.31.3", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] } serde = { version = "1.0.229", features = ["derive", "rc"] } serde_cbor = "0.11.2" diff --git a/below/tc/Cargo.toml b/below/tc/Cargo.toml index d31ec856..0ee0f0b8 100644 --- a/below/tc/Cargo.toml +++ b/below/tc/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-tc" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "TC crate for below" diff --git a/below/view/Cargo.toml b/below/view/Cargo.toml index 9731dfae..e2d75e62 100644 --- a/below/view/Cargo.toml +++ b/below/view/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-view" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "View crate for below" @@ -12,19 +12,19 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.104" chrono = { version = "0.4.45", features = ["clock", "serde", "std"], default-features = false } -common = { package = "below-common", version = "0.11.0", path = "../common" } +common = { package = "below-common", version = "0.12.0", path = "../common" } crossterm = { version = "0.29", features = ["event-stream", "serde"] } cursive = { version = "0.21.1", features = ["crossterm-backend"], default-features = false } enum-iterator = "2.3.0" humantime = "2.4.0" itertools = "0.15.0" libc = "0.2.186" -model = { package = "below-model", version = "0.11.0", path = "../model" } -procfs = { package = "fb_procfs", version = "0.11.0", path = "../procfs" } -render = { package = "below-render", version = "0.11.0", path = "../render" } +model = { package = "below-model", version = "0.12.0", path = "../model" } +procfs = { package = "fb_procfs", version = "0.12.0", path = "../procfs" } +render = { package = "below-render", version = "0.12.0", path = "../render" } serde = { version = "1.0.229", features = ["derive", "rc"] } slog = { version = "2.8.2", features = ["max_level_trace", "nested-values"] } -store = { package = "below-store", version = "0.11.0", path = "../store" } +store = { package = "below-store", version = "0.12.0", path = "../store" } toml = { version = "1.1.8", features = ["preserve_order"] } [dev-dependencies] diff --git a/below/vmlinux/Cargo.toml b/below/vmlinux/Cargo.toml index 50117eb6..0577f1a1 100644 --- a/below/vmlinux/Cargo.toml +++ b/below/vmlinux/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "below-vmlinux" -version = "0.11.0" +version = "0.12.0" authors = ["Meta Platforms, Inc. and affiliates"] edition = "2024" description = "Vendored kernel BTF (vmlinux.h) shared by below's BPF programs" diff --git a/docs/building.md b/docs/building.md index bba52232..c2a97e3c 100644 --- a/docs/building.md +++ b/docs/building.md @@ -45,13 +45,15 @@ cargo test # Debian packages `scripts/package_deb.sh ` packages a release build as -`target//debian/below__.deb`. The package installs +`target//debian/below_-1_.deb`. The package installs `/usr/bin/below` and enables and starts `below.service`, which records to `/var/log/below/store`. -Tagged releases publish amd64 and arm64 packages, built on Ubuntu 22.04, and -the matching binaries. Install one with: +To release, run `mise run version ` to set the version of every +workspace crate, merge that, then push a `v` tag. The tag must match +the version in `below/Cargo.toml`. The release has amd64 and arm64 packages, +built on Ubuntu 22.04, and the matching binaries. Install one with: ```shell -sudo apt install ./below__amd64.deb +sudo apt install ./below_-1_amd64.deb ``` diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..7db1241c --- /dev/null +++ b/mise.toml @@ -0,0 +1,31 @@ +# Task automation. `mise tasks` lists them. below only builds on Linux. + +[tools] +actionlint = "1.7.12" +shellcheck = "0.11.0" +"cargo:cargo-edit" = "0.13.14" +"cargo:cargo-deb" = "3.8.0" + +[tasks.version] +description = "Set the version of every workspace crate: mise run version 0.12.1" +usage = 'arg ""' +run = 'cargo set-version --workspace "${usage_version?}"' + +[tasks.deb] +description = "Build below and package it as a .deb for this machine's architecture" +run = [ + 'cargo build --release --locked --package below --target "$(uname -m)-unknown-linux-gnu"', + 'scripts/package_deb.sh "$(uname -m)-unknown-linux-gnu"', +] + +[tasks."test:deb"] +description = "Install the newest .deb in an Ubuntu systemd container and check it" +run = 'scripts/test_deb.sh "$(ls -t target/*/debian/below_*.deb | head -1)"' + +[tasks."lint:actions"] +description = "Lint the release workflows" +run = "actionlint .github/workflows/build.yml .github/workflows/release.yml" + +[tasks."lint:scripts"] +description = "Run ShellCheck on the packaging scripts" +run = "shellcheck scripts/package_deb.sh scripts/test_deb.sh" diff --git a/scripts/package_deb.sh b/scripts/package_deb.sh index 45bb92a2..be188d64 100755 --- a/scripts/package_deb.sh +++ b/scripts/package_deb.sh @@ -22,16 +22,4 @@ set -eu cd "$(dirname "$(realpath "$0")")"/.. -triple=$1 -crate_version=$(sed -n 's/^version = "\(.*\)"/\1/p' below/Cargo.toml | head -1) - -# Commits since the v tag sort after that release and before the next. -describe=$(git describe --tags --match "v$crate_version" --long --abbrev=12) -since=$(sed -E 's/^.*-([0-9]+)-g[0-9a-f]+$/\1/' <<<"$describe") -commit=$(sed -E 's/^.*-g([0-9a-f]+)$/\1/' <<<"$describe") -version=$crate_version -if [ "$since" != 0 ]; then - version="$crate_version+git$since.$commit" -fi - -cargo deb --package below --no-build --target "$triple" --deb-version "$version" +cargo deb --package below --no-build --target "$1" diff --git a/scripts/test_deb.sh b/scripts/test_deb.sh index 131b8c3e..b5c20e96 100755 --- a/scripts/test_deb.sh +++ b/scripts/test_deb.sh @@ -15,7 +15,7 @@ # limitations under the License. # Install a below .deb in an Ubuntu container running systemd and check the -# binary runs and the recording service is enabled. +# binary reports the package version and the recording service is enabled. # scripts/test_deb.sh [image] set -eu @@ -41,5 +41,11 @@ done # Not /tmp: systemd may mount a tmpfs over it after docker cp has written there. docker cp "$deb" "$container:/root/below.deb" docker exec "$container" apt-get install -y -qq /root/below.deb -docker exec "$container" below --version +version=$(dpkg-deb --field "$deb" Version) +reported=$(docker exec "$container" below --version) +echo "$reported" +case $reported in + "below ${version%-*}" | "below ${version%-*} (rev "*")") ;; + *) echo "below --version does not match the package version $version" >&2; exit 1 ;; +esac docker exec "$container" systemctl is-enabled below