Justfile 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. all: build test
  2. all-release: build-release test-release
  3. genDemo:
  4. fish_prompt="> " fish_history="eza_history" vhs < docs/tapes/demo.tape
  5. nsxiv -a docs/images/demo.gif
  6. #----------#
  7. # building #
  8. #----------#
  9. # compile the exa binary
  10. @build:
  11. cargo build
  12. # compile the exa binary (in release mode)
  13. @build-release:
  14. cargo build --release --verbose
  15. # produce an HTML chart of compilation timings
  16. @build-time:
  17. cargo +nightly clean
  18. cargo +nightly build -Z timings
  19. # check that the exa binary can compile
  20. @check:
  21. cargo check
  22. #---------------#
  23. # running tests #
  24. #---------------#
  25. # run unit tests
  26. @test:
  27. cargo test --workspace -- --quiet
  28. # run unit tests (in release mode)
  29. @test-release:
  30. cargo test --workspace --release --verbose
  31. #-----------------------#
  32. # code quality and misc #
  33. #-----------------------#
  34. # lint the code
  35. @clippy:
  36. touch src/main.rs
  37. cargo clippy
  38. # update dependency versions, and checks for outdated ones
  39. @update-deps:
  40. cargo update
  41. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  42. cargo outdated
  43. # list unused dependencies
  44. @unused-deps:
  45. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  46. cargo +nightly udeps
  47. # check that every combination of feature flags is successful
  48. @check-features:
  49. command -v cargo-hack >/dev/null || (echo "cargo-hack not installed" && exit 1)
  50. cargo hack check --feature-powerset
  51. # print versions of the necessary build tools
  52. @versions:
  53. rustc --version
  54. cargo --version
  55. #---------------#
  56. # documentation #
  57. #---------------#
  58. # build the man pages
  59. @man:
  60. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  61. version=$(awk 'BEGIN { FS = "\"" } ; /^version/ { print $2 ; exit }' Cargo.toml); \
  62. for page in eza.1 eza_colors.5 eza_colors-explanation.5; do \
  63. sed "s/\$version/v${version}/g" "man/${page}.md" | pandoc --standalone -f markdown -t man > "${CARGO_TARGET_DIR:-target}/man/${page}"; \
  64. done;
  65. # build and preview the main man page (eza.1)
  66. @man-1-preview: man
  67. man "${CARGO_TARGET_DIR:-target}/man/eza.1"
  68. # build and preview the colour configuration man page (eza_colors.5)
  69. @man-5-preview: man
  70. man "${CARGO_TARGET_DIR:-target}/man/eza_colors.5"
  71. # build and preview the colour configuration man page (eza_colors.5)
  72. @man-5-explanations-preview: man
  73. man "${CARGO_TARGET_DIR:-target}/man/eza_colors-explanation.5"
  74. #---------------#
  75. # release #
  76. #---------------#
  77. new_version := "$(convco version --bump)"
  78. # If you're not cafkafk and she isn't dead, don't run this!
  79. #
  80. # usage: release major, release minor, release patch
  81. release:
  82. cargo bump "{{new_version}}"
  83. git cliff -t "{{new_version}}" > CHANGELOG.md
  84. cargo check
  85. nix build -L ./#clippy
  86. git checkout -b "cafk-release-v{{new_version}}"
  87. git commit -asm "chore: release eza v{{new_version}}"
  88. git push
  89. @echo "waiting 10 seconds for github to catch up..."
  90. sleep 10
  91. gh pr create --draft --title "chore: release v{{new_version}}" --body "This PR was auto-generated by our lovely just file" --reviewer cafkafk
  92. @echo "Now go review that and come back and run gh-release"
  93. @gh-release:
  94. git tag -d "v{{new_version}}" || echo "tag not found, creating";
  95. git tag -a "v{{new_version}}" -m "auto generated by the justfile for eza v$(convco version)"
  96. just cross
  97. mkdir -p ./target/"release-notes-$(convco version)"
  98. git cliff -t "v$(convco version)" --current > ./target/"release-notes-$(convco version)/RELEASE.md"
  99. just checksum >> ./target/"release-notes-$(convco version)/RELEASE.md"
  100. 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)"/*
  101. #----------------#
  102. # binaries #
  103. #----------------#
  104. tar BINARY TARGET:
  105. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  106. zip BINARY TARGET:
  107. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  108. tar_static BINARY TARGET:
  109. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  110. zip_static BINARY TARGET:
  111. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.zip ./target/{{TARGET}}/release/{{BINARY}}
  112. binary BINARY TARGET:
  113. rustup target add {{TARGET}}
  114. cross build --release --target {{TARGET}}
  115. just tar {{BINARY}} {{TARGET}}
  116. just zip {{BINARY}} {{TARGET}}
  117. binary_static BINARY TARGET:
  118. rustup target add {{TARGET}}
  119. RUSTFLAGS='-C target-feature=+crt-static' cross build --release --target {{TARGET}}
  120. just tar_static {{BINARY}} {{TARGET}}
  121. just zip_static {{BINARY}} {{TARGET}}
  122. checksum:
  123. @echo "# Checksums"
  124. @echo "## sha256sum"
  125. @echo '```'
  126. @sha256sum ./target/"bin-$(convco version)"/*
  127. @echo '```'
  128. @echo "## md5sum"
  129. @echo '```'
  130. @md5sum ./target/"bin-$(convco version)"/*
  131. @echo '```'
  132. alias c := cross
  133. # Generate release binaries for EZA
  134. #
  135. # usage: cross
  136. @cross:
  137. # Setup Output Directory
  138. mkdir -p ./target/"bin-$(convco version)"
  139. # Install Toolchains/Targets
  140. rustup toolchain install stable
  141. ## Linux
  142. ### x86
  143. just binary eza x86_64-unknown-linux-gnu
  144. # just binary_static eza x86_64-unknown-linux-gnu
  145. just binary eza x86_64-unknown-linux-musl
  146. # just binary_static eza x86_64-unknown-linux-musl
  147. ### aarch
  148. just binary eza aarch64-unknown-linux-gnu
  149. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  150. ### arm
  151. just binary eza arm-unknown-linux-gnueabihf
  152. # just binary_static eza arm-unknown-linux-gnueabihf
  153. ## MacOS
  154. # TODO: just binary eza x86_64-apple-darwin
  155. ## Windows
  156. ### x86
  157. just binary eza.exe x86_64-pc-windows-gnu
  158. # just binary_static eza.exe x86_64-pc-windows-gnu
  159. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  160. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  161. # Generate Checksums
  162. # TODO: moved to gh-release just checksum
  163. #---------------------#
  164. # Integration testing #
  165. #---------------------#
  166. alias gen := gen_test_dir
  167. test_dir := "tests/test_dir"
  168. gen_test_dir:
  169. #!/usr/bin/env bash
  170. rm {{test_dir}} -rf;
  171. mkdir -p {{test_dir}}
  172. cd {{test_dir}};
  173. sudo groupadd -f eza_test
  174. # BEGIN grid
  175. mkdir -p grid
  176. cd grid
  177. mkdir $(seq -w 001 1000);
  178. seq 0001 1000 | split -l 1 -a 3 -d - file_
  179. # Set time to unix epoch
  180. touch --date=@0 *;
  181. cd ..
  182. # END grid
  183. # BEGIN git
  184. mkdir -p git
  185. cd git
  186. mkdir $(seq -w 001 10);
  187. for f in ./*
  188. do
  189. cd $f
  190. git init
  191. seq 01 10 | split -l 1 -a 3 -d - file_
  192. cd ..
  193. done
  194. cd ..
  195. # END git
  196. # BEGIN test_root
  197. sudo mkdir root
  198. sudo chmod 777 root
  199. sudo mkdir root/empty
  200. # END test_root
  201. # BEGIN mknod
  202. mkdir -p specials
  203. sudo mknod specials/block-device b 3 60
  204. sudo mknod specials/char-device c 14 40
  205. sudo mknod specials/named-pipe p
  206. # END test_root
  207. # BEGIN test_symlinks
  208. mkdir -p symlinks
  209. touch symlinks/file --date=@0
  210. ln -s file symlinks/symlink
  211. ln -s symlink symlinks/symlink2
  212. mkdir -p symlinks/dir
  213. ln -s dir symlinks/symlink3
  214. ln -s pipitek symlinks/symlink4
  215. # END test_symlinks
  216. # BEGIN test_perms
  217. mkdir -p perms
  218. touch perms/file --date=@0
  219. touch perms/file2 --date=@0
  220. chmod 777 perms/file
  221. chmod 001 perms/file2
  222. # END test_perms
  223. # BEGIN test_group
  224. mkdir -p group
  225. touch group/file --date=@0
  226. sudo chgrp eza_test group/file
  227. # END test_group
  228. # BEGIN test_size
  229. mkdir -p size
  230. touch size/1M --date=@0
  231. dd if=/dev/zero of=size/1M bs=1 count=0 seek=1M
  232. touch size/1K --date=@0
  233. dd if=/dev/zero of=size/1K bs=1 count=0 seek=1K
  234. touch size/1B --date=@0
  235. dd if=/dev/zero of=size/1B bs=1 count=0 seek=1
  236. touch size/1337 --date=@0
  237. dd if=/dev/zero of=size/1337 bs=1 count=0 seek=1337
  238. # END test_size
  239. # BEGIN test_time
  240. mkdir -p time
  241. touch time/epoch --date=@0
  242. touch time/1s --date=@1
  243. touch time/1m --date=@60
  244. touch time/1h --date=@3600
  245. touch time/1d --date=@86400
  246. touch time/1y --date=@31536000
  247. # END test_time
  248. # BEGIN test_icons
  249. mkdir -p icons
  250. touch icons/file --date=@0
  251. touch icons/go.go --date=@0
  252. touch icons/rust.rs --date=@0
  253. touch icons/c.c --date=@0
  254. touch icons/c++.cpp --date=@0
  255. touch icons/python.py --date=@0
  256. touch icons/java.java --date=@0
  257. touch icons/javascript.js --date=@0
  258. touch icons/html.html --date=@0
  259. touch icons/css.css --date=@0
  260. touch icons/php.php --date=@0
  261. touch icons/ruby.rb --date=@0
  262. touch icons/shell.sh --date=@0
  263. touch icons/unknown.unknown --date=@0
  264. touch icons/man.1 --date=@0
  265. touch icons/marked.md --date=@0
  266. # END test_icons
  267. eza -l --grid;
  268. # Runs integration tests in nix sandbox
  269. #
  270. # Required nix, likely won't work on windows.
  271. @itest:
  272. nix build -L ./#trycmd-local
  273. # Runs integration tests in nix sandbox, and dumps outputs.
  274. #
  275. # WARNING: this can cause loss of work
  276. @idump:
  277. rm ./tests/cmd/*nix.stderr -f || echo
  278. rm ./tests/cmd/*nix.stdout -f || echo
  279. nix build -L ./#trydump
  280. cp ./result/dump/*nix.* ./tests/cmd/