Justfile 7.0 KB

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