justfile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. # SPDX-FileCopyrightText: 2024 Christina Sørensen
  2. # SPDX-License-Identifier: EUPL-1.2
  3. _default:
  4. @just -l
  5. all: build test
  6. all-release: build-release test-release
  7. [group('house-keeping')]
  8. genDemo:
  9. fish_prompt="> " fish_history="eza_history" vhs < docs/tapes/demo.tape
  10. nsxiv -a docs/images/demo.gif
  11. #----------#
  12. # building #
  13. #----------#
  14. # compile the exa binary
  15. [group('building')]
  16. @build:
  17. cargo build
  18. # compile the exa binary (in release mode)
  19. [group('building')]
  20. @build-release:
  21. cargo build --release --verbose
  22. # produce an HTML chart of compilation timings
  23. [group('building')]
  24. @build-time:
  25. cargo +nightly clean
  26. cargo +nightly build -Z timings
  27. # check that the exa binary can compile
  28. [group('building')]
  29. @check:
  30. cargo check
  31. #---------------#
  32. # running tests #
  33. #---------------#
  34. # run unit tests
  35. [group('testing')]
  36. @test:
  37. cargo test --workspace -- --quiet
  38. # run unit tests (in release mode)
  39. [group('testing')]
  40. @test-release:
  41. cargo test --workspace --release --verbose
  42. #-----------------------#
  43. # code quality and misc #
  44. #-----------------------#
  45. # lint the code
  46. [group('house-keeping')]
  47. @clippy:
  48. touch src/main.rs
  49. cargo clippy
  50. # update dependency versions, and checks for outdated ones
  51. [group('house-keeping')]
  52. @update-deps:
  53. cargo update
  54. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  55. cargo outdated
  56. # list unused dependencies
  57. [group('house-keeping')]
  58. @unused-deps:
  59. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  60. cargo +nightly udeps
  61. # check that every combination of feature flags is successful
  62. [group('house-keeping')]
  63. @check-features:
  64. command -v cargo-hack >/dev/null || (echo "cargo-hack not installed" && exit 1)
  65. cargo hack check --feature-powerset
  66. # print versions of the necessary build tools
  67. [group('house-keeping')]
  68. @versions:
  69. rustc --version
  70. cargo --version
  71. #---------------#
  72. # documentation #
  73. #---------------#
  74. # build the man pages
  75. [group('documentation')]
  76. @man:
  77. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  78. version=$(awk 'BEGIN { FS = "\"" } ; /^version/ { print $2 ; exit }' Cargo.toml); \
  79. for page in eza.1 eza_colors.5 eza_colors-explanation.5; do \
  80. sed "s/\$version/v${version}/g" "man/${page}.md" | pandoc --standalone -f markdown -t man > "${CARGO_TARGET_DIR:-target}/man/${page}"; \
  81. done;
  82. # build and preview the main man page (eza.1)
  83. [group('documentation')]
  84. @man-1-preview: man
  85. man "${CARGO_TARGET_DIR:-target}/man/eza.1"
  86. # build and preview the colour configuration man page (eza_colors.5)
  87. [group('documentation')]
  88. @man-5-preview: man
  89. man "${CARGO_TARGET_DIR:-target}/man/eza_colors.5"
  90. # build and preview the colour configuration man page (eza_colors.5)
  91. [group('documentation')]
  92. @man-5-explanations-preview: man
  93. man "${CARGO_TARGET_DIR:-target}/man/eza_colors-explanation.5"
  94. #---------------#
  95. # release #
  96. #---------------#
  97. new_version := "$(convco version --bump)"
  98. # If you're not cafkafk and she isn't dead, don't run this!
  99. #
  100. # usage: release major, release minor, release patch
  101. [group('release')]
  102. release:
  103. cargo bump "{{new_version}}"
  104. git cliff -c .config/cliff.toml -t "{{new_version}}" > CHANGELOG.md
  105. cargo check
  106. nix build -L ./#clippy
  107. git checkout -b "cafk-release-v{{new_version}}"
  108. git commit -asm "chore: eza v{{new_version}} changelogs, version bump"
  109. git push
  110. @echo "waiting 10 seconds for github to catch up..."
  111. sleep 10
  112. gh pr create --draft --title "chore: release v{{new_version}}" --body "This PR was auto-generated by our lovely just file" --reviewer cafkafk
  113. @echo "Now go review that and come back and run gh-release"
  114. [group('release')]
  115. @gh-release:
  116. git tag -d "v{{new_version}}" || echo "tag not found, creating";
  117. git tag --sign -a "v{{new_version}}" -m "auto generated by the justfile for eza v$(convco version)"
  118. just cross
  119. just mangen
  120. just completions
  121. mkdir -p ./target/"release-notes-$(convco version)"
  122. git cliff -c .config/cliff.toml -t "v$(convco version)" --current > ./target/"release-notes-$(convco version)/RELEASE.md"
  123. just checksum >> ./target/"release-notes-$(convco version)/RELEASE.md"
  124. git push origin "v{{new_version}}"
  125. 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)"/* ./target/"man-$(convco version).tar.gz" ./target/"completions-$(convco version).tar.gz"
  126. #----------------#
  127. # binaries #
  128. #----------------#
  129. # TODO: make static/no_static DRY
  130. # TODO: add name prefix/suffix arguments
  131. [group('binaries')]
  132. tar BINARY TARGET:
  133. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  134. [group('binaries')]
  135. zip BINARY TARGET:
  136. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  137. [group('binaries')]
  138. tar_static BINARY TARGET:
  139. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  140. [group('binaries')]
  141. zip_static BINARY TARGET:
  142. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.zip ./target/{{TARGET}}/release/{{BINARY}}
  143. [group('binaries')]
  144. tar_no_libgit BINARY TARGET:
  145. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_no_libgit.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  146. [group('binaries')]
  147. zip_no_libgit BINARY TARGET:
  148. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_no_libgit.zip ./target/{{TARGET}}/release/{{BINARY}}
  149. [group('binaries')]
  150. tar_static_no_libgit BINARY TARGET:
  151. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static_no_libgit.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  152. [group('binaries')]
  153. zip_static_no_libgit BINARY TARGET:
  154. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static_no_libgit.zip ./target/{{TARGET}}/release/{{BINARY}}
  155. [group('binaries')]
  156. binary BINARY TARGET:
  157. rustup target add {{TARGET}}
  158. cross build --release --target {{TARGET}}
  159. just tar {{BINARY}} {{TARGET}}
  160. just zip {{BINARY}} {{TARGET}}
  161. [group('binaries')]
  162. binary_static BINARY TARGET:
  163. rustup target add {{TARGET}}
  164. RUSTFLAGS='-C target-feature=+crt-static' cross build --release --target {{TARGET}}
  165. just tar_static {{BINARY}} {{TARGET}}
  166. just zip_static {{BINARY}} {{TARGET}}
  167. [group('binaries')]
  168. binary_no_libgit BINARY TARGET:
  169. rustup target add {{TARGET}}
  170. cross build --no-default-features --release --target {{TARGET}}
  171. just tar_no_libgit {{BINARY}} {{TARGET}}
  172. just zip_no_libgit {{BINARY}} {{TARGET}}
  173. [group('binaries')]
  174. binary_static_no_libgit BINARY TARGET:
  175. rustup target add {{TARGET}}
  176. RUSTFLAGS='-C target-feature=+crt-static' cross build --no-default-features --release --target {{TARGET}}
  177. just tar_static_no_libgit {{BINARY}} {{TARGET}}
  178. just zip_static_no_libgit {{BINARY}} {{TARGET}}
  179. [group('binaries')]
  180. checksum:
  181. @echo "# Checksums"
  182. @echo "## sha256sum"
  183. @echo '```'
  184. @sha256sum ./target/"bin-$(convco version)"/*
  185. @echo '```'
  186. @echo "## md5sum"
  187. @echo '```'
  188. @md5sum ./target/"bin-$(convco version)"/*
  189. @echo '```'
  190. @echo "## blake3sum"
  191. @echo '```'
  192. @b3sum ./target/"bin-$(convco version)"/*
  193. @echo '```'
  194. alias c := cross
  195. # Generate release binaries for EZA
  196. #
  197. # usage: cross
  198. [group('binaries')]
  199. @cross:
  200. # Setup Output Directory
  201. mkdir -p ./target/"bin-$(convco version)"
  202. # Install Toolchains/Targets
  203. rustup toolchain install stable
  204. ## Linux
  205. ### x86
  206. just binary eza x86_64-unknown-linux-gnu
  207. # just binary_static eza x86_64-unknown-linux-gnu
  208. just binary eza x86_64-unknown-linux-musl
  209. # just binary_static eza x86_64-unknown-linux-musl
  210. ### aarch
  211. just binary eza aarch64-unknown-linux-gnu
  212. just binary_no_libgit eza aarch64-unknown-linux-gnu
  213. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  214. ### arm
  215. just binary eza arm-unknown-linux-gnueabihf
  216. just binary_no_libgit eza arm-unknown-linux-gnueabihf
  217. # just binary_static eza arm-unknown-linux-gnueabihf
  218. ## MacOS
  219. # TODO: just binary eza x86_64-apple-darwin
  220. ## Windows
  221. ### x86
  222. just binary eza.exe x86_64-pc-windows-gnu
  223. # just binary_static eza.exe x86_64-pc-windows-gnu
  224. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  225. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  226. # Generate Checksums
  227. # TODO: moved to gh-release just checksum
  228. [group('documentation')]
  229. @mangen:
  230. # Setup Output Directory
  231. mkdir -p ./target/"man-$(convco version)"
  232. pandoc --standalone -f markdown -t man man/eza.1.md > ./target/"man-$(convco version)"/eza.1
  233. pandoc --standalone -f markdown -t man man/eza_colors.5.md > ./target/"man-$(convco version)"/eza_colors.5
  234. pandoc --standalone -f markdown -t man man/eza_colors-explanation.5.md > ./target/"man-$(convco version)"/eza_colors-explanation.5
  235. tar czvf ./target/"man-$(convco version)".tar.gz ./target/"man-$(convco version)"
  236. [group('documentation')]
  237. [group('binaries')]
  238. @completions:
  239. # Setup Output Directory
  240. mkdir -p ./target/"completions-$(convco version)"
  241. cp completions/*/* ./target/"completions-$(convco version)"/
  242. tar czvf ./target/"completions-$(convco version)".tar.gz ./target/"completions-$(convco version)"
  243. #---------------------#
  244. # Integration testing #
  245. #---------------------#
  246. alias gen := gen_test_dir
  247. test_dir := "tests/test_dir"
  248. [group('testing')]
  249. gen_test_dir:
  250. bash devtools/dir-generator.sh {{ test_dir }}
  251. # Runs integration tests in nix sandbox
  252. #
  253. # Required nix, likely won't work on windows.
  254. [group('testing')]
  255. @itest:
  256. nix build -L ./#trycmd-local
  257. # Runs integration tests in nix sandbox, and dumps outputs.
  258. #
  259. # WARNING: this can cause loss of work
  260. [group('testing')]
  261. @idump:
  262. rm ./tests/gen/*_nix.stderr -f || echo
  263. rm ./tests/gen/*_nix.stdout -f || echo
  264. rm ./tests/gen/*_unix.stderr -f || echo
  265. rm ./tests/gen/*_unix.stdout -f || echo
  266. rm ./tests/ptests/ptest_*.stderr -f || echo
  267. rm ./tests/ptests/ptest_*.stdout -f || echo
  268. nix build -L ./#trydump
  269. find result/dump -type f \( -name "*.stdout" -o -name "*.stderr" \) -exec sh -c 'base=$(basename {}); if [ -e "tests/gen/${base%.*}.toml" ]; then cp {} tests/gen/; elif [ -e "tests/cmd/${base%.*}.toml" ]; then cp {} tests/cmd/; elif [ -e "tests/ptests/${base%.*}.toml" ]; then cp {} tests/ptests/; fi' \;
  270. [group('testing')]
  271. @itest-gen:
  272. nix build -L ./#trycmd
  273. # Fully re-generates the integration tests using powertest
  274. [group('testing')]
  275. @regen:
  276. which powertest >&- 2>&- || (echo -e "Powertest not installed. Please Clone the repo and run:\n\tcargo install --path . --locked" && exit 1)
  277. echo "WARNING: this will delete all tests in tests/ptest"
  278. sleep 5
  279. echo "Deleting tests/ptests"
  280. rm -rf tests/ptests
  281. echo "Generating tests/ptests"
  282. powertest
  283. nix build -L ./#trydump
  284. find result/dump -type f \( -name "*.stdout" -o -name "*.stderr" \) -exec sh -c 'base=$(basename {}); if [ -e "tests/ptests/${base%.*}.toml" ]; then cp {} tests/ptests/; fi' \;