fork/eza

git clone https://git.julia.blue/fork/eza

Christina SørensenMerge pull request #460 from gardouille/fix-just-pandoc-command89e6ab15

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