justfile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
  2. alias b := build
  3. alias c := check
  4. alias t := test
  5. [private]
  6. default:
  7. @just --list
  8. # Execute a partial check (MSRV is not checked)
  9. precommit:
  10. @bash misc/scripts/precommit.sh
  11. # Format the entire Rust code
  12. fmt:
  13. @bash misc/scripts/check-fmt.sh
  14. # Check if the Rust code is formatted
  15. check-fmt:
  16. @bash misc/scripts/check-fmt.sh check
  17. # run `cargo build` on everything
  18. build *ARGS="--workspace --all-targets":
  19. #!/usr/bin/env bash
  20. set -euo pipefail
  21. if [ ! -f Cargo.toml ]; then
  22. cd {{invocation_directory()}}
  23. fi
  24. cargo build {{ARGS}}
  25. # run `cargo check` on everything
  26. check *ARGS="--workspace --all-targets":
  27. #!/usr/bin/env bash
  28. set -euo pipefail
  29. if [ ! -f Cargo.toml ]; then
  30. cd {{invocation_directory()}}
  31. fi
  32. cargo check {{ARGS}}
  33. # run all checks recommended before opening a PR
  34. final-check: lint clippy
  35. #!/usr/bin/env bash
  36. set -euo pipefail
  37. if [ ! -f Cargo.toml ]; then
  38. cd {{invocation_directory()}}
  39. fi
  40. cargo test --doc
  41. just test
  42. # run code formatters
  43. format:
  44. #!/usr/bin/env bash
  45. set -euo pipefail
  46. if [ ! -f Cargo.toml ]; then
  47. cd {{invocation_directory()}}
  48. fi
  49. cargo fmt --all
  50. nixpkgs-fmt $(echo **.nix)
  51. # run lints (git pre-commit hook)
  52. lint:
  53. #!/usr/bin/env bash
  54. set -euo pipefail
  55. env NO_STASH=true $(git rev-parse --git-common-dir)/hooks/pre-commit
  56. # run tests
  57. test: build
  58. #!/usr/bin/env bash
  59. set -euo pipefail
  60. if [ ! -f Cargo.toml ]; then
  61. cd {{invocation_directory()}}
  62. fi
  63. cargo test
  64. # run and restart on changes
  65. watch *ARGS="-x run":
  66. #!/usr/bin/env bash
  67. set -euo pipefail
  68. if [ ! -f Cargo.toml ]; then
  69. cd {{invocation_directory()}}
  70. fi
  71. env RUST_LOG=${RUST_LOG:-debug} cargo watch {{ARGS}}
  72. # run `cargo clippy` on everything
  73. clippy *ARGS="--locked --offline --workspace --all-targets":
  74. cargo clippy {{ARGS}} -- --deny warnings --allow deprecated
  75. # run `cargo clippy --fix` on everything
  76. clippy-fix *ARGS="--locked --offline --workspace --all-targets":
  77. cargo clippy {{ARGS}} --fix
  78. # run `semgrep`
  79. semgrep:
  80. env SEMGREP_ENABLE_VERSION_CHECK=0 \
  81. semgrep --error --no-rewrite-rule-ids --config .config/semgrep.yaml
  82. # check typos
  83. [no-exit-message]
  84. typos *PARAMS:
  85. #!/usr/bin/env bash
  86. set -eo pipefail
  87. export FLAKEBOX_GIT_LS
  88. FLAKEBOX_GIT_LS="$(git ls-files)"
  89. export FLAKEBOX_GIT_LS_TEXT
  90. FLAKEBOX_GIT_LS_TEXT="$(echo "$FLAKEBOX_GIT_LS" | grep -v -E "^db/|\.(png|ods|jpg|jpeg|woff2|keystore|wasm|ttf|jar|ico)\$")"
  91. if ! echo "$FLAKEBOX_GIT_LS_TEXT" | typos {{PARAMS}} --file-list - --force-exclude ; then
  92. >&2 echo "Typos found: Valid new words can be added to '.typos.toml'"
  93. return 1
  94. fi
  95. # fix all typos
  96. [no-exit-message]
  97. typos-fix-all:
  98. just typos -w
  99. # THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION