Justfile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. all: build test xtests
  2. all-release: build-release test-release xtests-release
  3. all-quick: build-quick test-quick xtests-quick
  4. export DOG_DEBUG := ""
  5. #----------#
  6. # building #
  7. #----------#
  8. # compile the dog binary
  9. @build:
  10. cargo build
  11. # compile the dog binary (in release mode)
  12. @build-release:
  13. cargo build --release --verbose
  14. strip "${CARGO_TARGET_DIR:-target}/release/dog"
  15. # compile the dog binary (without some features)
  16. @build-quick:
  17. cargo build --no-default-features
  18. #---------------#
  19. # running tests #
  20. #---------------#
  21. # run unit tests
  22. @test:
  23. cargo test --workspace -- --quiet
  24. # run unit tests (in release mode)
  25. @test-release:
  26. cargo test --release --workspace --verbose
  27. # run unit tests (without some features)
  28. @test-quick:
  29. cargo test --workspace --no-default-features -- --quiet
  30. # run mutation tests
  31. @test-mutation:
  32. cargo +nightly test --package dns --features=dns/with_mutagen -- --quiet
  33. cargo +nightly mutagen --package dns --features=dns/with_mutagen
  34. #------------------------#
  35. # running extended tests #
  36. #------------------------#
  37. # run extended tests
  38. @xtests:
  39. specsheet xtests/*.toml -O cmd.target.dog="${CARGO_TARGET_DIR:-../target}/debug/dog"
  40. # run extended tests (in release mode)
  41. @xtests-release:
  42. specsheet xtests/*.toml -O cmd.target.dog="${CARGO_TARGET_DIR:-../target}/release/dog"
  43. # run extended tests (omitting certain feature tests)
  44. @xtests-quick:
  45. specsheet xtests/*.toml -O cmd.target.dog="${CARGO_TARGET_DIR:-../target}/debug/dog" --skip-tags=udp,tls,https,json
  46. #---------#
  47. # fuzzing #
  48. #---------#
  49. # run fuzzing on the dns crate
  50. @fuzz:
  51. cargo +nightly fuzz --version
  52. cd dns; cargo +nightly fuzz run fuzz_parsing -- -jobs=`nproc` -workers=`nproc` -runs=69105
  53. # print out the data that caused crashes during fuzzing as hexadecimal
  54. @fuzz-hex:
  55. for crash in dns/fuzz/artifacts/fuzz_parsing/crash-*; do echo; echo $crash; hexyl $crash; done
  56. # remove fuzz log files
  57. @fuzz-clean:
  58. rm dns/fuzz/fuzz-*.log
  59. #-----------------------#
  60. # code quality and misc #
  61. #-----------------------#
  62. # lint the code
  63. @clippy:
  64. touch dns/src/lib.rs
  65. cargo clippy
  66. # generate a code coverage report using tarpaulin via docker
  67. @coverage-docker:
  68. docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin cargo tarpaulin --all --out Html
  69. # update dependency versions, and check for outdated ones
  70. @update-deps:
  71. cargo update
  72. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  73. cargo outdated
  74. # list unused dependencies
  75. @unused-deps:
  76. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  77. cargo +nightly udeps
  78. # print versions of the necessary build tools
  79. @versions:
  80. rustc --version
  81. cargo --version
  82. #---------------#
  83. # documentation #
  84. #---------------#
  85. # render the documentation
  86. @doc:
  87. cargo doc --no-deps --workspace
  88. # build the man pages
  89. @man:
  90. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  91. pandoc --standalone -f markdown -t man man/dog.1.md > "${CARGO_TARGET_DIR:-target}/man/dog.1"
  92. # build and preview the man page
  93. @man-preview: man
  94. man "${CARGO_TARGET_DIR:-target}/man/dog.1"
  95. #-----------#
  96. # packaging #
  97. #-----------#
  98. # create a distributable package
  99. zip desc exe="dog":
  100. #!/usr/bin/env perl
  101. use Archive::Zip;
  102. -e 'target/release/{{ exe }}' || die 'Binary not built!';
  103. -e 'target/man/dog.1' || die 'Man page not built!';
  104. my $zip = Archive::Zip->new();
  105. $zip->addFile('completions/dog.bash');
  106. $zip->addFile('completions/dog.zsh');
  107. $zip->addFile('completions/dog.fish');
  108. $zip->addFile('target/man/dog.1', 'man/dog.1');
  109. $zip->addFile('target/release/{{ exe }}', 'bin/{{ exe }}');
  110. $zip->writeToFileNamed('dog-{{ desc }}.zip') == AZ_OK || die 'Zip write error!';
  111. system 'unzip -l "dog-{{ desc }}".zip'