Justfile 7.3 KB

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