Justfile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. new_version := "$(convco version --bump)"
  75. # If you're not cafkafk and she isn't dead, don't run this!
  76. #
  77. # usage: release major, release minor, release patch
  78. @release:
  79. cargo bump "{{new_version}}"
  80. git cliff -t "$(convco version)" > CHANGELOG.md
  81. cargo check
  82. nix build -L ./#clippy
  83. git checkout -b "cafk-release-v$(convco version)"
  84. git commit -asm "chore: release eza v$(convco version)"
  85. git push
  86. echo "waiting 10 seconds for github to catch up..."
  87. sleep 10
  88. gh pr create --draft --title "chore: release v$(convco version)" --body "This PR was auto-generated by our lovely just file" --reviewer cafkafk
  89. @echo "Now go review that and come back and run gh-release"
  90. @gh-release:
  91. git tag -a "v$(convco version --bump)" -m "auto generated by the justfile for eza v$(convco version)"
  92. mkdir -p ./target/"release-notes-$(convco version)"
  93. git cliff -t "v$(convco version)" -u > ./target/"release-notes-$(convco version)/RELEASE.md" ./target/"bin-$(convco version)"/*
  94. just checksum >> ./target/"release-notes-$(convco version)/RELEASE.md"
  95. gh release create "v$(convco version)" --title "eza v$(convco version)" -d -F ./target/"release-notes-$(convco version)/RELEASE.md"
  96. #----------------#
  97. # binaries #
  98. #----------------#
  99. tar BINARY TARGET:
  100. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  101. zip BINARY TARGET:
  102. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  103. tar_static BINARY TARGET:
  104. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  105. zip_static BINARY TARGET:
  106. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.zip ./target/{{TARGET}}/release/{{BINARY}}
  107. binary BINARY TARGET:
  108. rustup target add {{TARGET}}
  109. cross build --release --target {{TARGET}}
  110. just tar {{BINARY}} {{TARGET}}
  111. just zip {{BINARY}} {{TARGET}}
  112. binary_static BINARY TARGET:
  113. rustup target add {{TARGET}}
  114. RUSTFLAGS='-C target-feature=+crt-static' cross build --release --target {{TARGET}}
  115. just tar_static {{BINARY}} {{TARGET}}
  116. just zip_static {{BINARY}} {{TARGET}}
  117. checksum:
  118. @echo "# Checksums"
  119. @echo "## sha256sum"
  120. @echo '```'
  121. @sha256sum ./target/"bin-$(convco version)"/*
  122. @echo '```'
  123. @echo "## md5sum"
  124. @echo '```'
  125. @md5sum ./target/"bin-$(convco version)"/*
  126. @echo '```'
  127. alias c := cross
  128. # Generate release binaries for EZA
  129. #
  130. # usage: cross
  131. @cross:
  132. # Setup Output Directory
  133. mkdir -p ./target/"bin-$(convco version)"
  134. # Install Toolchains/Targets
  135. rustup toolchain install stable
  136. ## Linux
  137. ### x86
  138. just binary eza x86_64-unknown-linux-gnu
  139. # just binary_static eza x86_64-unknown-linux-gnu
  140. just binary eza x86_64-unknown-linux-musl
  141. # just binary_static eza x86_64-unknown-linux-musl
  142. ### aarch
  143. just binary eza aarch64-unknown-linux-gnu
  144. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  145. ### arm
  146. just binary eza arm-unknown-linux-gnueabihf
  147. # just binary_static eza arm-unknown-linux-gnueabihf
  148. ## MacOS
  149. # TODO: just binary eza x86_64-apple-darwin
  150. ## Windows
  151. ### x86
  152. just binary eza.exe x86_64-pc-windows-gnu
  153. # just binary_static eza.exe x86_64-pc-windows-gnu
  154. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  155. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  156. # Generate Checksums
  157. # TODO: moved to gh-release just checksum
  158. #---------------------#
  159. # Integration testing #
  160. #---------------------#
  161. alias gen := gen_test_dir
  162. test_dir := "tests/test_dir"
  163. gen_test_dir:
  164. #!/usr/bin/env bash
  165. rm {{test_dir}} -r;
  166. mkdir -p {{test_dir}}
  167. cd {{test_dir}};
  168. # BEGIN grid
  169. mkdir -p grid
  170. cd grid
  171. mkdir $(seq -w 001 1000);
  172. seq 0001 1000 | split -l 1 -a 3 -d - file_
  173. # Set time to unix epoch
  174. touch --date=@0 *;
  175. cd ..
  176. # END grid
  177. # BEGIN git
  178. mkdir -p git
  179. cd git
  180. mkdir $(seq -w 001 10);
  181. for f in ./*
  182. do
  183. cd $f
  184. git init
  185. seq 01 10 | split -l 1 -a 3 -d - file_
  186. cd ..
  187. done
  188. cd ..
  189. # END git
  190. # BEGIN test_root
  191. sudo mkdir root
  192. sudo chmod 777 root
  193. sudo mkdir root/empty
  194. # END test_root
  195. # BEGIN mknod
  196. mkdir -p specials
  197. sudo mknod specials/block-device b 3 60
  198. sudo mknod specials/char-device c 14 40
  199. sudo mknod specials/named-pipe p
  200. # END test_root
  201. eza -l --grid;
  202. # Runs integration tests in nix sandbox
  203. #
  204. # Required nix, likely won't work on windows.
  205. @itest:
  206. nix build -L ./#trycmd
  207. # Runs integration tests in nix sandbox, and dumps outputs.
  208. #
  209. # WARNING: this can cause loss of work
  210. @idump:
  211. rm ./tests/cmd/*nix.stderr -f || echo
  212. rm ./tests/cmd/*nix.stdout -f || echo
  213. nix build -L ./#trydump
  214. cp ./result/dump/*nix.* ./tests/cmd/