Justfile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. all: build test
  2. all-release: build-release test-release
  3. #----------#
  4. # building #
  5. #----------#
  6. # compile the exa binary
  7. @build:
  8. cargo build
  9. # compile the exa binary (in release mode)
  10. @build-release:
  11. cargo build --release --verbose
  12. # produce an HTML chart of compilation timings
  13. @build-time:
  14. cargo +nightly clean
  15. cargo +nightly build -Z timings
  16. # check that the exa binary can compile
  17. @check:
  18. cargo check
  19. #---------------#
  20. # running tests #
  21. #---------------#
  22. # run unit tests
  23. @test:
  24. cargo test --workspace -- --quiet
  25. # run unit tests (in release mode)
  26. @test-release:
  27. cargo test --workspace --release --verbose
  28. #-----------------------#
  29. # code quality and misc #
  30. #-----------------------#
  31. # lint the code
  32. @clippy:
  33. touch src/main.rs
  34. cargo clippy
  35. # update dependency versions, and checks for outdated ones
  36. @update-deps:
  37. cargo update
  38. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  39. cargo outdated
  40. # list unused dependencies
  41. @unused-deps:
  42. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  43. cargo +nightly udeps
  44. # check that every combination of feature flags is successful
  45. @check-features:
  46. command -v cargo-hack >/dev/null || (echo "cargo-hack not installed" && exit 1)
  47. cargo hack check --feature-powerset
  48. # print versions of the necessary build tools
  49. @versions:
  50. rustc --version
  51. cargo --version
  52. #---------------#
  53. # documentation #
  54. #---------------#
  55. # build the man pages
  56. @man:
  57. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  58. version=$(cat Cargo.toml | grep ^version | head -n 1 | awk '{print $NF}' | tr -d '"'); \
  59. for page in eza.1 eza_colors.5 eza_colors-explanation.5; do \
  60. pandoc --standalone -f markdown -t man <(cat "man/${page}.md" | sed "s/\$version/v${version}/g") > "${CARGO_TARGET_DIR:-target}/man/${page}"; \
  61. done;
  62. # build and preview the main man page (eza.1)
  63. @man-1-preview: man
  64. man "${CARGO_TARGET_DIR:-target}/man/eza.1"
  65. # build and preview the colour configuration man page (eza_colors.5)
  66. @man-5-preview: man
  67. man "${CARGO_TARGET_DIR:-target}/man/eza_colors.5"
  68. # build and preview the colour configuration man page (eza_colors.5)
  69. @man-5-explanations-preview: man
  70. man "${CARGO_TARGET_DIR:-target}/man/eza_colors-explanation.5"
  71. #---------------#
  72. # release #
  73. #---------------#
  74. # If you're not cafkafk and she isn't dead, don't run this!
  75. #
  76. # usage: release major, release minor, release patch
  77. @release version:
  78. cargo bump '{{version}}'
  79. git cliff -t $(grep '^version' Cargo.toml | head -n 1 | grep -E '([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?' -o) > CHANGELOG.md
  80. cargo check
  81. nix build -L ./#clippy
  82. git checkout -b cafk-release-$(grep '^version' Cargo.toml | head -n 1 | grep -E '([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?' -o)
  83. git commit -asm "chore: release $(grep '^version' Cargo.toml | head -n 1 | grep -E '([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?' -o)"
  84. git push
  85. echo "waiting 10 seconds for github to catch up..."
  86. sleep 10
  87. gh pr create --draft --title "chore: release $(grep '^version' Cargo.toml | head -n 1 | grep -E '([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?' -o)" --body "This PR was auto-generated by our lovely just file" --reviewer cafkafk
  88. #----------------#
  89. # binaries #
  90. #----------------#
  91. tar BINARY TARGET:
  92. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  93. zip BINARY TARGET:
  94. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  95. binary BINARY TARGET:
  96. rustup target add {{TARGET}}
  97. cross build --release --target {{TARGET}}
  98. just tar {{BINARY}} {{TARGET}}
  99. just zip {{BINARY}} {{TARGET}}
  100. checksum:
  101. echo "# Checksums"
  102. echo "## sha256sum"
  103. echo '```'
  104. sha256sum ./target/"bin-$(convco version)"/*
  105. echo '```'
  106. echo "## md5sum"
  107. echo '```'
  108. md5sum ./target/"bin-$(convco version)"/*
  109. echo '```'
  110. alias c := cross
  111. # Generate release binaries for EZA
  112. #
  113. # usage: cross
  114. @cross:
  115. # Setup Output Directory
  116. mkdir -p ./target/"bin-$(convco version)"
  117. # Install Toolchains/Targets
  118. rustup toolchain install stable
  119. ## Linux
  120. ### x86
  121. just binary eza x86_64-unknown-linux-gnu
  122. just binary eza x86_64-unknown-linux-musl
  123. ### aarch
  124. just binary eza aarch64-unknown-linux-gnu
  125. ### arm
  126. just binary eza arm-unknown-linux-gnueabihf
  127. ## MacOS
  128. # TODO: just binary eza x86_64-apple-darwin
  129. ## Windows
  130. ### x86
  131. just binary eza.exe x86_64-pc-windows-gnu
  132. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  133. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  134. # Generate Checksums
  135. just checksum
  136. #---------------------#
  137. # Integration testing #
  138. #---------------------#
  139. alias gen := gen_test_dir
  140. test_dir := "tests/test_dir"
  141. gen_test_dir:
  142. #!/usr/bin/env bash
  143. rm {{test_dir}} -r;
  144. mkdir -p {{test_dir}}
  145. cd {{test_dir}};
  146. # BEGIN grid
  147. mkdir -p grid
  148. cd grid
  149. mkdir $(seq -w 001 1000);
  150. seq 0001 1000 | split -l 1 -a 3 -d - file_
  151. # Set time to unix epoch
  152. touch --date=@0 *;
  153. cd ..
  154. # END grid
  155. # BEGIN git
  156. mkdir -p git
  157. cd git
  158. mkdir $(seq -w 001 10);
  159. for f in ./*
  160. do
  161. cd $f
  162. git init
  163. seq 01 10 | split -l 1 -a 3 -d - file_
  164. cd ..
  165. done
  166. cd ..
  167. # END git
  168. # BEGIN test_root
  169. sudo mkdir root
  170. sudo chmod 777 root
  171. sudo mkdir root/empty
  172. # END test_root
  173. # BEGIN mknod
  174. mkdir -p specials
  175. sudo mknod specials/block-device b 3 60
  176. sudo mknod specials/char-device c 14 40
  177. sudo mknod specials/named-pipe p
  178. # END test_root
  179. eza -l --grid;
  180. # Runs integration tests in nix sandbox
  181. #
  182. # Required nix, likely won't work on windows.
  183. @itest:
  184. nix build -L ./#trycmd
  185. # Runs integration tests in nix sandbox, and dumps outputs.
  186. #
  187. # WARNING: this can cause loss of work
  188. @idump:
  189. rm ./tests/cmd/*nix.stderr -f || echo
  190. rm ./tests/cmd/*nix.stdout -f || echo
  191. nix build -L ./#trydump
  192. cp ./result/dump/*nix.* ./tests/cmd/