justfile 2.5 KB

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