justfile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. # To override the version, pass it as an argument before the recipe:
  98. # e.g. just version=1.2.3 release
  99. # If version is not set, it will be determined by convco.
  100. version := ""
  101. new_version := if version == "" { "$(convco version --bump)" } else { version }
  102. # If you're not cafkafk and she isn't dead, don't run this!
  103. #
  104. # usage: release major, release minor, release patch
  105. [group('release')]
  106. release:
  107. cargo bump "{{new_version}}"
  108. git cliff -c .config/cliff.toml -t "{{new_version}}" > CHANGELOG.md
  109. cargo check
  110. nix build -L ./#clippy
  111. git checkout -b "cafk-release-v{{new_version}}"
  112. git commit -asm "chore: eza v{{new_version}} changelogs, version bump"
  113. git push
  114. @echo "waiting 10 seconds for github to catch up..."
  115. sleep 10
  116. gh pr create --draft --title "chore: release v{{new_version}}" --body "This PR was auto-generated by our lovely just file" --reviewer cafkafk
  117. @echo "Now go review that and come back and run gh-release"
  118. [group('release')]
  119. @gh-release:
  120. git tag -d "v{{new_version}}" || echo "tag not found, creating";
  121. git tag --sign -a "v{{new_version}}" -m "auto generated by the justfile for eza v$(convco version)"
  122. just cross
  123. just mangen
  124. just completions
  125. mkdir -p ./target/"release-notes-$(convco version)"
  126. git cliff -c .config/cliff.toml -t "v$(convco version)" --current > ./target/"release-notes-$(convco version)/RELEASE.md"
  127. just checksum >> ./target/"release-notes-$(convco version)/RELEASE.md"
  128. git push origin "v{{new_version}}"
  129. 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"
  130. #----------------#
  131. # binaries #
  132. #----------------#
  133. # TODO: make static/no_static DRY
  134. # TODO: add name prefix/suffix arguments
  135. [group('binaries')]
  136. tar BINARY TARGET:
  137. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  138. [group('binaries')]
  139. zip BINARY TARGET:
  140. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  141. [group('binaries')]
  142. tar_static BINARY TARGET:
  143. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  144. [group('binaries')]
  145. zip_static BINARY TARGET:
  146. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.zip ./target/{{TARGET}}/release/{{BINARY}}
  147. [group('binaries')]
  148. tar_no_libgit BINARY TARGET:
  149. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_no_libgit.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  150. [group('binaries')]
  151. zip_no_libgit BINARY TARGET:
  152. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_no_libgit.zip ./target/{{TARGET}}/release/{{BINARY}}
  153. [group('binaries')]
  154. tar_static_no_libgit BINARY TARGET:
  155. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static_no_libgit.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  156. [group('binaries')]
  157. zip_static_no_libgit BINARY TARGET:
  158. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static_no_libgit.zip ./target/{{TARGET}}/release/{{BINARY}}
  159. [group('binaries')]
  160. binary BINARY TARGET:
  161. rustup target add {{TARGET}}
  162. cross build --release --target {{TARGET}}
  163. just tar {{BINARY}} {{TARGET}}
  164. just zip {{BINARY}} {{TARGET}}
  165. [group('binaries')]
  166. binary_static BINARY TARGET:
  167. rustup target add {{TARGET}}
  168. RUSTFLAGS='-C target-feature=+crt-static' cross build --release --target {{TARGET}}
  169. just tar_static {{BINARY}} {{TARGET}}
  170. just zip_static {{BINARY}} {{TARGET}}
  171. [group('binaries')]
  172. binary_no_libgit BINARY TARGET:
  173. rustup target add {{TARGET}}
  174. cross build --no-default-features --release --target {{TARGET}}
  175. just tar_no_libgit {{BINARY}} {{TARGET}}
  176. just zip_no_libgit {{BINARY}} {{TARGET}}
  177. [group('binaries')]
  178. binary_static_no_libgit BINARY TARGET:
  179. rustup target add {{TARGET}}
  180. RUSTFLAGS='-C target-feature=+crt-static' cross build --no-default-features --release --target {{TARGET}}
  181. just tar_static_no_libgit {{BINARY}} {{TARGET}}
  182. just zip_static_no_libgit {{BINARY}} {{TARGET}}
  183. [group('binaries')]
  184. checksum:
  185. @echo "# Checksums"
  186. @echo "## sha256sum"
  187. @echo '```'
  188. @sha256sum ./target/"bin-$(convco version)"/*
  189. @echo '```'
  190. @echo "## md5sum"
  191. @echo '```'
  192. @md5sum ./target/"bin-$(convco version)"/*
  193. @echo '```'
  194. @echo "## blake3sum"
  195. @echo '```'
  196. @b3sum ./target/"bin-$(convco version)"/*
  197. @echo '```'
  198. alias c := cross
  199. # Generate release binaries for EZA
  200. #
  201. # usage: cross
  202. [group('binaries')]
  203. @cross:
  204. # Setup Output Directory
  205. mkdir -p ./target/"bin-$(convco version)"
  206. # Install Toolchains/Targets
  207. rustup toolchain install stable
  208. ## Linux
  209. ### x86
  210. just binary eza x86_64-unknown-linux-gnu
  211. # just binary_static eza x86_64-unknown-linux-gnu
  212. just binary eza x86_64-unknown-linux-musl
  213. # just binary_static eza x86_64-unknown-linux-musl
  214. ### aarch
  215. just binary eza aarch64-unknown-linux-gnu
  216. just binary_no_libgit eza aarch64-unknown-linux-gnu
  217. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  218. ### arm
  219. just binary eza arm-unknown-linux-gnueabihf
  220. just binary_no_libgit eza arm-unknown-linux-gnueabihf
  221. # just binary_static eza arm-unknown-linux-gnueabihf
  222. ## MacOS
  223. # TODO: just binary eza x86_64-apple-darwin
  224. ## Windows
  225. ### x86
  226. just binary eza.exe x86_64-pc-windows-gnu
  227. # just binary_static eza.exe x86_64-pc-windows-gnu
  228. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  229. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  230. # Generate Checksums
  231. # TODO: moved to gh-release just checksum
  232. [group('documentation')]
  233. @mangen:
  234. # Setup Output Directory
  235. mkdir -p ./target/"man-$(convco version)"
  236. pandoc --standalone -f markdown -t man man/eza.1.md > ./target/"man-$(convco version)"/eza.1
  237. pandoc --standalone -f markdown -t man man/eza_colors.5.md > ./target/"man-$(convco version)"/eza_colors.5
  238. pandoc --standalone -f markdown -t man man/eza_colors-explanation.5.md > ./target/"man-$(convco version)"/eza_colors-explanation.5
  239. tar czvf ./target/"man-$(convco version)".tar.gz ./target/"man-$(convco version)"
  240. [group('documentation')]
  241. [group('binaries')]
  242. @completions:
  243. # Setup Output Directory
  244. mkdir -p ./target/"completions-$(convco version)"
  245. cp completions/*/* ./target/"completions-$(convco version)"/
  246. tar czvf ./target/"completions-$(convco version)".tar.gz ./target/"completions-$(convco version)"
  247. #---------------------#
  248. # Integration testing #
  249. #---------------------#
  250. alias gen := gen_test_dir
  251. test_dir := "tests/test_dir"
  252. [group('testing')]
  253. gen_test_dir:
  254. bash devtools/dir-generator.sh {{ test_dir }}
  255. # Runs integration tests in nix sandbox
  256. #
  257. # Required nix, likely won't work on windows.
  258. [group('testing')]
  259. @itest:
  260. nix build -L ./#trycmd-local
  261. # Runs integration tests in nix sandbox, and dumps outputs.
  262. #
  263. # WARNING: this can cause loss of work
  264. [group('testing')]
  265. @idump:
  266. rm ./tests/gen/*_nix.stderr -f || echo
  267. rm ./tests/gen/*_nix.stdout -f || echo
  268. rm ./tests/gen/*_unix.stderr -f || echo
  269. rm ./tests/gen/*_unix.stdout -f || echo
  270. rm ./tests/ptests/ptest_*.stderr -f || echo
  271. rm ./tests/ptests/ptest_*.stdout -f || echo
  272. nix build -L ./#trydump
  273. 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' \;
  274. [group('testing')]
  275. @itest-gen:
  276. nix build -L ./#trycmd
  277. # Fully re-generates the integration tests using powertest
  278. [group('testing')]
  279. @regen:
  280. which powertest >&- 2>&- || (echo -e "Powertest not installed. Please Clone the repo and run:\n\tcargo install --path . --locked" && exit 1)
  281. echo "WARNING: this will delete all tests in tests/ptest"
  282. sleep 5
  283. echo "Deleting tests/ptests"
  284. rm -rf tests/ptests
  285. echo "Generating tests/ptests"
  286. powertest
  287. nix build -L ./#trydump
  288. 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' \;