Justfile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. pandoc --standalone -f markdown -t man man/eza.1.md > "${CARGO_TARGET_DIR:-target}/man/eza.1"
  59. pandoc --standalone -f markdown -t man man/eza_colors.5.md > "${CARGO_TARGET_DIR:-target}/man/eza_colors.5"
  60. pandoc --standalone -f markdown -t man man/eza_colors-explanation.5.md > "${CARGO_TARGET_DIR:-target}/man/eza_colors-explanation.5"
  61. # build and preview the main man page (eza.1)
  62. @man-1-preview: man
  63. man "${CARGO_TARGET_DIR:-target}/man/eza.1"
  64. # build and preview the colour configuration man page (eza_colors.5)
  65. @man-5-preview: man
  66. man "${CARGO_TARGET_DIR:-target}/man/eza_colors.5"
  67. # build and preview the colour configuration man page (eza_colors.5)
  68. @man-5-explanations-preview: man
  69. man "${CARGO_TARGET_DIR:-target}/man/eza_colors-explanation.5"
  70. #---------------#
  71. # release #
  72. #---------------#
  73. # If you're not cafkafk and she isn't dead, don't run this!
  74. #
  75. # usage: release major, release minor, release patch
  76. @release version:
  77. cargo bump '{{version}}'
  78. 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
  79. cargo check
  80. nix build -L ./#clippy
  81. 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)
  82. 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)"
  83. git push
  84. echo "waiting 10 seconds for github to catch up..."
  85. sleep 10
  86. 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
  87. # If you're not cafkafk and she isn't dead, you probably don't need to run
  88. # this!
  89. #
  90. # usage: cross
  91. @cross:
  92. # Install Toolchains/Targets
  93. rustup toolchain install stable
  94. ## Linux
  95. ### x86
  96. rustup target add x86_64-unknown-linux-gnu
  97. rustup target add x86_64-unknown-linux-musl
  98. ### aarch
  99. rustup target add aarch64-unknown-linux-gnu
  100. ### arm
  101. rustup target add arm-unknown-linux-gnueabihf
  102. ## Windows
  103. ### x86
  104. rustup target add x86_64-pc-windows-gnu
  105. rustup target add x86_64-pc-windows-msvc
  106. # Setup Output Directory
  107. mkdir -p ./target/"bin-$(convco version)"
  108. # Build
  109. ## Linux
  110. ### x86
  111. cross build --target x86_64-unknown-linux-gnu --release
  112. tar czvf ./target/"bin-$(convco version)"/eza_x86_64-unknown-linux-gnu.tar.gz -C ./target/x86_64-unknown-linux-gnu/release/ ./eza
  113. cross build --release --target=x86_64-unknown-linux-musl
  114. tar czvf ./target/"bin-$(convco version)"/eza_x86_64-unknown-linux-musl.tar.gz -C ./target/x86_64-unknown-linux-musl/release/ ./eza
  115. cross build --target aarch64-unknown-linux-gnu --release
  116. tar czvf ./target/"bin-$(convco version)"/eza_aarch64-unknown-linux-gnu.tar.gz -C ./target/aarch64-unknown-linux-gnu/release/ ./eza
  117. cross build --target arm-unknown-linux-gnueabihf --release
  118. tar czvf ./target/"bin-$(convco version)"/arm-unknown-linux-gnueabihf.tar.gz -C ./target/arm-unknown-linux-gnueabihf/release/ ./eza
  119. ## Windows
  120. cross build --target x86_64-pc-windows-gnu --release
  121. zip -j ./target/"bin-$(convco version)"/x86_64-pc-windows-gnu.zip ./target/x86_64-pc-windows-gnu/release/eza.exe
  122. cross build --target x86_64-pc-windows-msvc --release
  123. zip -j ./target/"bin-$(convco version)"/x86_64-pc-windows-msvc.zip ./target/x86_64-pc-windows-gnu/release/eza.exe
  124. # Generate Checksums
  125. echo "# Checksums"
  126. echo "## sha256sum"
  127. echo '```'
  128. sha256sum ./target/"bin-$(convco version)"/*
  129. echo '```'
  130. echo "## md5sum"
  131. echo '```'
  132. md5sum ./target/"bin-$(convco version)"/*
  133. echo '```'
  134. #---------------------#
  135. # Integration testing #
  136. #---------------------#
  137. # Runs integration tests in nix sandbox
  138. #
  139. # Required nix, likely won't work on windows.
  140. @itest:
  141. nix build -L ./#trycmd
  142. # Runs integration tests in nix sandbox, and dumps outputs.
  143. #
  144. # WARNING: this can cause loss of work
  145. @idump:
  146. rm ./tests/cmd/*nix.stderr -f || echo
  147. rm ./tests/cmd/*nix.stdout -f || echo
  148. nix build -L ./#trydump
  149. cp ./result/dump/*nix.* ./tests/cmd/