This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / knot2 / justfile
5.9 kB 137 lines
1set shell := ["bash", "-eu", "-o", "pipefail", "-c"] 2 3default: 4 @just --list 5 6gen-config: 7 cargo run -p knot-server -- config-template > example.toml 8 9fmt: 10 cargo fmt --all 11 12fmt-check: 13 cargo fmt --all --check 14 15clippy: 16 cargo clippy -p 'knot-*' --all-targets -- -D warnings 17 18test: 19 cargo test -p 'knot-*' 20 21fuzz crate='knot-pack' target='pack' time='60': 22 cd crates/{{crate}}/fuzz && RUSTUP_TOOLCHAIN=nightly cargo fuzz run {{target}} -- -max_total_time={{time}} 23 24fuzz-ci: (fuzz "knot-pack" "pkt" "30") (fuzz "knot-pack" "pack" "30") (fuzz "knot-pack" "receive_commands" "30") (fuzz "knot-pack" "upload_args" "30") (fuzz "knot-git" "patch" "30") (fuzz "knot-cobs" "cob_change" "30") (fuzz "knot-cobs" "cob_ref" "30") (fuzz "knot-atproto" "pubkey" "30") (fuzz "knot-atproto" "did_document" "30") (fuzz "knot-edge" "spki" "30") (fuzz "knot-edge" "spki_pin" "30") (fuzz "knot-lfs" "transfer" "30") (fuzz "knot-lfs" "batch" "30") (fuzz "knot-lfs" "pointer" "30") 25 26bench filter='': 27 cargo bench -p knot-bench --bench pack -- {{filter}} 28 cargo bench -p knot-bench --bench cob -- {{filter}} 29 cargo bench -p knot-bench --bench projection -- {{filter}} 30 31bench-scaling: 32 cargo bench -p knot-bench --bench coldstart 33 34bench-gate: 35 cargo test -p knot-bench --features instrument --test gate 36 37bench-gate-registry: 38 cargo test -p knot-bench --features instrument --test registry_gate 39 40differential: 41 cargo test -p knot-pack --test differential 42 43t55xx *tests: 44 internal_docs/t55xx/run.sh {{tests}} 45 46ci: fmt-check clippy test gates bench-gate fuzz-ci 47 48gates: gate-no-subprocess (gate-no-banned-deps "no-sql" "an embedded database" "rusqlite|libsqlite3-sys|sqlx|sqlx-core|sled|fjall|redb") (gate-no-banned-deps "no-native-git" "a native git or TLS shim" "git2|libgit2-sys|openssl-sys|zlib-ng|zlib-ng-sys") gate-no-string-ids gate-no-unguarded-receive gate-fuzz-targets-enumerated 49 50gate-no-subprocess: 51 #!/usr/bin/env bash 52 set -euo pipefail 53 hits=$(grep -rn "process::Command" crates/*/src --include="*.rs" | grep -v "/_lex/" || true) 54 if [ -n "$hits" ]; then 55 echo "no-subprocess gate failed: server source spawns processes" >&2 56 echo "$hits" >&2 57 exit 1 58 fi 59 echo "ok: no process spawning in server source" 60 61gate-no-banned-deps name subject pattern: 62 #!/usr/bin/env bash 63 set -euo pipefail 64 hits=$(cargo tree -p knot-server --edges normal,build --prefix none | sort -u | grep -iE '^({{pattern}}) v' || true) 65 if [ -n "$hits" ]; then 66 echo "{{name}} gate failed: {{subject}} is in the knot-server dependency tree" >&2 67 echo "$hits" >&2 68 exit 1 69 fi 70 echo "ok: {{subject}} isn't in the knot-server dependency tree" 71 72gate-no-string-ids: 73 #!/usr/bin/env bash 74 set -euo pipefail 75 hits=$(grep -nE 'pub fn .*(-> *String|: *String\b)' crates/knot-types/src/ids.rs | grep -v 'fn to_hex' || true) 76 if [ -n "$hits" ]; then 77 echo "no-string-ids gate failed: a String-typed id crosses the knot-types boundary" >&2 78 echo "$hits" >&2 79 exit 1 80 fi 81 echo "ok: no String-typed id crosses the knot-types boundary" 82 83gate-no-unguarded-receive: 84 #!/usr/bin/env bash 85 set -euo pipefail 86 hits=$(grep -rn 'receive_pack(\|receive_pack_with_limits(' crates/*/src --include="*.rs" | grep -v 'pub fn ' || true) 87 if [ -n "$hits" ]; then 88 echo "no-unguarded-receive gate failed: server source calls the unguarded receive path, use receive_pack_guarded" >&2 89 echo "$hits" >&2 90 exit 1 91 fi 92 echo "ok: the unguarded receive path is reached only from tests" 93 94gate-fuzz-targets-enumerated: 95 #!/usr/bin/env bash 96 set -euo pipefail 97 disk=$(mktemp) 98 recipe=$(mktemp) 99 triplet=$(mktemp) 100 trap 'rm -f "$disk" "$recipe" "$triplet"' EXIT 101 find crates -path '*/fuzz/fuzz_targets/*.rs' -not -path '*/target/*' | sed -E 's#crates/([^/]+)/fuzz/fuzz_targets/(.+)\.rs#\1 \2#' | sort -u > "$disk" 102 just --show fuzz-ci | grep -oE '\(fuzz "[^"]+" "[^"]+" "[^"]+"' | sed -E 's#\(fuzz "([^"]+)" "([^"]+)" "([^"]+)"#\1 \2 \3#' | sort -u > "$triplet" 103 cut -d' ' -f1,2 "$triplet" > "$recipe" 104 while read -r crate target secs; do 105 if ! [[ "$secs" =~ ^[1-9][0-9]*$ ]]; then 106 echo "fuzz-targets-enumerated gate failed: target '$crate $target' runs for '$secs', not a positive number of seconds" >&2 107 exit 1 108 fi 109 done < "$triplet" 110 missing=$(comm -23 "$disk" "$recipe" || true) 111 extra=$(comm -13 "$disk" "$recipe" || true) 112 if [ -n "$missing" ] || [ -n "$extra" ]; then 113 echo "fuzz-targets-enumerated gate failed: the fuzz-ci recipe and the targets on disk disagree" >&2 114 if [ -n "$missing" ]; then 115 echo "on disk but absent from fuzz-ci:" >&2 116 echo "$missing" >&2 117 fi 118 if [ -n "$extra" ]; then 119 echo "in fuzz-ci but no matching target on disk:" >&2 120 echo "$extra" >&2 121 fi 122 exit 1 123 fi 124 while read -r crate target; do 125 manifest="crates/$crate/fuzz/Cargo.toml" 126 if ! grep -qF "name = \"$target\"" "$manifest" || ! grep -qF "path = \"fuzz_targets/$target.rs\"" "$manifest"; then 127 echo "fuzz-targets-enumerated gate failed: $manifest has no [[bin]] declaring target '$target'" >&2 128 exit 1 129 fi 130 entry=$(grep -oE 'knot_[a-z0-9_]+::fuzz::[a-z0-9_]+' "crates/$crate/fuzz/fuzz_targets/$target.rs" | head -1 | sed -E 's#.*::fuzz::##' || true) 131 smoke="crates/$crate/tests/fuzz_smoke.rs" 132 if [ -z "$entry" ] || ! grep -qE "fuzz::${entry}\(" "$smoke"; then 133 echo "fuzz-targets-enumerated gate failed: target '$target' entry point $(echo "$crate" | tr - _)::fuzz::$entry has no smoke-test coverage in $smoke" >&2 134 exit 1 135 fi 136 done < "$disk" 137 echo "ok: every fuzz target is enumerated in fuzz-ci, declared in its fuzz manifest, and smoke-tested"