From 0d6c71e5a7f46d3553955442098ac5504de72110 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:34:59 -0600 Subject: [PATCH] feat(id): enforce justfile formatting in treefmt + CI (#1797) --- .github/scripts/id-pr-checks.txt | 1 + pkgs/id/flake.nix | 14 +++++++++++++- pkgs/id/justfile | 32 ++++++++++++++++---------------- pkgs/id/treefmt.toml | 6 ++++++ 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/scripts/id-pr-checks.txt b/.github/scripts/id-pr-checks.txt index 856883def8..971d49b25b 100644 --- a/.github/scripts/id-pr-checks.txt +++ b/.github/scripts/id-pr-checks.txt @@ -26,6 +26,7 @@ shellcheck-check shfmt-check statix-check taplo-check +justfmt-check clippy-lint web-lint cargo-check diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index c8c1c6a43a..92d7fa317a 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -308,7 +308,7 @@ # ======================================================================= # Formatter: nix fmt - # Uses treefmt to orchestrate rustfmt + biome + prettier + nixfmt + statix + shfmt + taplo + # Uses treefmt to orchestrate rustfmt + biome + prettier + nixfmt + statix + shfmt + taplo + just # ======================================================================= formatter = pkgs.writeShellScriptBin "formatter" '' export PATH="${pkgs.lib.makeBinPath fmtBins}:$PATH" @@ -599,6 +599,18 @@ echo "taplo-check passed at $(date)" > $out/result.txt ''; }; + justfmt-check = pkgs.stdenv.mkDerivation { + name = "id-justfmt-check"; + src = ./.; + nativeBuildInputs = [ pkgs.just ]; + buildPhase = '' + just --fmt --check --justfile ./justfile + ''; + installPhase = '' + mkdir -p $out + echo "justfmt-check passed at $(date)" > $out/result.txt + ''; + }; prettier-check = pkgs.stdenv.mkDerivation { name = "id-prettier-check"; src = ./.; diff --git a/pkgs/id/justfile b/pkgs/id/justfile index b8c4bc3577..ef91fa9cca 100644 --- a/pkgs/id/justfile +++ b/pkgs/id/justfile @@ -22,7 +22,7 @@ default: kill-serve # Show available recipes list: - @just --list + @just --list # ============================================================================= # Quality Checks @@ -59,7 +59,7 @@ treefmt *args: unset TREEFMT_TREE_ROOT TREEFMT_TREE_ROOT_CMD TREEFMT_TREE_ROOT_FILE # Translate --check to --fail-on-change (treefmt v2 renamed the flag) translated_args=() - for arg in {{args}}; do + for arg in {{ args }}; do case "$arg" in --check) translated_args+=(--fail-on-change) ;; *) translated_args+=("$arg") ;; @@ -78,7 +78,7 @@ treefmt-no-cache *args: unset TREEFMT_TREE_ROOT TREEFMT_TREE_ROOT_CMD TREEFMT_TREE_ROOT_FILE # Translate --check to --fail-on-change (treefmt v2 renamed the flag) translated_args=() - for arg in {{args}}; do + for arg in {{ args }}; do case "$arg" in --check) translated_args+=(--fail-on-change) ;; *) translated_args+=("$arg") ;; @@ -279,7 +279,7 @@ alias test-lib := test-unit # Run the F11.8 benchmark harness (issue #539): journal append+fsync, checkpoint compaction, guest replay, session fan-out bench *args: - cargo bench --bench world_bench -- {{args}} + cargo bench --bench world_bench -- {{ args }} # Run integration tests only [group('test')] @@ -299,7 +299,7 @@ test-int-sandbox: # pair (#869; 3 → 4 shards in #551 to rebalance the ~12.5 min shards). [group('test')] test-shard-sandbox SHARD COUNT: - bash scripts/test-shard-sandbox.sh {{SHARD}} {{COUNT}} + bash scripts/test-shard-sandbox.sh {{ SHARD }} {{ COUNT }} # Run tests with output shown [group('test')] @@ -309,7 +309,7 @@ test-verbose: # Run a specific test by name [group('test')] test-one NAME: - cargo test --all-features {{NAME}} + cargo test --all-features {{ NAME }} # [bun] Run web tests (Rust + TypeScript unit tests + type checking) [group('test')] @@ -527,7 +527,7 @@ alias web-dev := web-assets-dev # Run CLI with arguments (lib variant) [group('run')] run *ARGS: - cargo run -- {{ARGS}} + cargo run -- {{ ARGS }} # Serve with web UI (default) [bun] [group('run')] @@ -536,12 +536,12 @@ serve *ARGS: web (serve-web ARGS) # Serve with web UI (skip asset build, requires pre-built assets) [group('run')] serve-web *ARGS: - cargo run --features web -- serve --web {{ARGS}} + cargo run --features web -- serve --web {{ ARGS }} # Serve without web UI [group('run')] serve-lib *ARGS: - cargo run -- serve {{ARGS}} + cargo run -- serve {{ ARGS }} # Serve a new instance with web UI and auto-assigned port (creates .iroh//) [bun] [group('run')] @@ -550,12 +550,12 @@ serve-new NAME="" *ARGS: web (serve-new-web NAME ARGS) # Serve a new instance with web UI (skip asset build, requires pre-built assets) [group('run')] serve-new-web NAME="" *ARGS: - cargo run --features web -- {{ if NAME != "" { "--new=" + NAME } else { "--new=" } }} serve --web --port 0 {{ARGS}} + cargo run --features web -- {{ if NAME != "" { "--new=" + NAME } else { "--new=" } }} serve --web --port 0 {{ ARGS }} # Serve a new instance without web UI and auto-assigned port [group('run')] serve-new-lib NAME="" *ARGS: - cargo run -- {{ if NAME != "" { "--new=" + NAME } else { "--new=" } }} serve --port 0 {{ARGS}} + cargo run -- {{ if NAME != "" { "--new=" + NAME } else { "--new=" } }} serve --port 0 {{ ARGS }} # Build then serve with web UI [bun] [group('run')] @@ -569,7 +569,7 @@ kill: # Sleep for specified seconds (default 0.6) [group('run')] sleep SECONDS="0.6": - sleep {{SECONDS}} + sleep {{ SECONDS }} # Kill and restart serve with web UI [bun] [alias: default] [group('run')] @@ -658,7 +658,7 @@ chown: update-input +inputs: #!/usr/bin/env bash set -euo pipefail - for input in {{inputs}}; do + for input in {{ inputs }}; do echo "--- Updating $input ---" nix flake update "$input" done @@ -674,10 +674,10 @@ alias update-all-inputs := update-inputs-all [private] _nixpkgs-inputs ref="": #!/usr/bin/env bash - if [ -z "{{ref}}" ]; then + if [ -z "{{ ref }}" ]; then nix eval --raw --impure --expr 'import ./nix/nixpkgs-inputs.nix {}' else - nix eval --raw --impure --expr "import ./nix/nixpkgs-inputs.nix { ref = \"{{ref}}\"; }" + nix eval --raw --impure --expr "import ./nix/nixpkgs-inputs.nix { ref = \"{{ ref }}\"; }" fi # Update all direct NixOS/nixpkgs inputs (any branch) @@ -743,7 +743,7 @@ update-nixpkgs-unstable-only: # Run a single nix flake check by name (e.g. just check-one test-unit) [group('nix')] check-one NAME: - nix build -L .#checks.x86_64-linux.{{NAME}} + nix build -L .#checks.x86_64-linux.{{ NAME }} # Build nix package — web variant (nix build) [group('nix')] diff --git a/pkgs/id/treefmt.toml b/pkgs/id/treefmt.toml index ce4effb171..7d7124b3f5 100644 --- a/pkgs/id/treefmt.toml +++ b/pkgs/id/treefmt.toml @@ -9,6 +9,7 @@ # statix - Nix linter/fixer # shfmt - Shell scripts # taplo - TOML files +# just - justfile [global] excludes = [ @@ -59,3 +60,8 @@ options = ["-i", "2", "-s", "-w"] command = "taplo" options = ["fmt"] includes = ["*.toml"] + +[formatter.just] +command = "bash" +options = ["-c", "for f in \"$@\"; do just --fmt --justfile \"$f\"; done", "_"] +includes = ["justfile"]