fork/eza

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

Christina SørensenMerge pull request #570 from MartinFillon/improve-gen-test-dir9ba9c655

v0.15.2
9.1 KiB356 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}} -rf;
216    mkdir -p {{test_dir}}
217    cd {{test_dir}};
218
219    sudo groupadd -f eza_test
220
221    # BEGIN grid
222    mkdir -p grid
223    cd grid
224
225    mkdir $(seq -w 001 1000);
226    seq 0001 1000 | split -l 1 -a 3 -d - file_
227
228    # Set time to unix epoch
229    touch --date=@0 *;
230
231    cd ..
232
233    # END grid
234
235    # BEGIN git
236
237    mkdir -p git
238    cd git
239
240    mkdir $(seq -w 001 10);
241    for f in ./*
242    do
243        cd $f
244        git init
245        seq 01 10 | split -l 1 -a 3 -d - file_
246        cd ..
247    done
248
249    cd ..
250
251    # END git
252
253    # BEGIN test_root
254
255    sudo mkdir root
256    sudo chmod 777 root
257    sudo mkdir root/empty
258
259    # END test_root
260
261    # BEGIN mknod
262
263    mkdir -p specials
264
265    sudo mknod specials/block-device b  3 60
266    sudo mknod specials/char-device  c 14 40
267    sudo mknod specials/named-pipe   p
268
269    # END test_root
270
271    # BEGIN test_symlinks
272
273    mkdir -p symlinks
274    touch symlinks/file --date=@0
275    ln -s file symlinks/symlink
276    ln -s symlink symlinks/symlink2
277    mkdir -p symlinks/dir
278    ln -s dir symlinks/symlink3
279    ln -s pipitek symlinks/symlink4
280
281    # END test_symlinks
282
283    # BEGIN test_perms
284
285    mkdir -p perms
286    touch perms/file --date=@0
287    touch perms/file2 --date=@0
288    chmod 777 perms/file
289    chmod 001 perms/file2
290
291    # END test_perms
292
293    # BEGIN test_group
294    mkdir -p group
295    touch group/file --date=@0
296    sudo chgrp eza_test group/file
297    # END test_group
298
299    # BEGIN test_size
300    mkdir -p size
301    touch size/1M --date=@0
302    dd if=/dev/zero of=size/1M bs=1 count=0 seek=1M
303    touch size/1K --date=@0
304    dd if=/dev/zero of=size/1K bs=1 count=0 seek=1K
305    touch size/1B --date=@0
306    dd if=/dev/zero of=size/1B bs=1 count=0 seek=1
307    touch size/1337 --date=@0
308    dd if=/dev/zero of=size/1337 bs=1 count=0 seek=1337
309    # END test_size
310    
311    # BEGIN test_time
312    mkdir -p time
313    touch time/epoch --date=@0
314    touch time/1s --date=@1
315    touch time/1m --date=@60
316    touch time/1h --date=@3600
317    touch time/1d --date=@86400
318    touch time/1y --date=@31536000
319    # END test_time
320
321    # BEGIN test_icons
322    mkdir -p icons
323    touch icons/file --date=@0
324    touch icons/go.go --date=@0
325    touch icons/rust.rs --date=@0
326    touch icons/c.c --date=@0
327    touch icons/c++.cpp --date=@0
328    touch icons/python.py --date=@0
329    touch icons/java.java --date=@0
330    touch icons/javascript.js --date=@0
331    touch icons/html.html --date=@0
332    touch icons/css.css --date=@0
333    touch icons/php.php --date=@0
334    touch icons/ruby.rb --date=@0
335    touch icons/shell.sh --date=@0
336    touch icons/unknown.unknown --date=@0
337    touch icons/man.1 --date=@0
338    touch icons/marked.md --date=@0
339    # END test_icons
340
341    eza -l --grid;
342
343# Runs integration tests in nix sandbox
344#
345# Required nix, likely won't work on windows.
346@itest:
347    nix build -L ./#trycmd-local
348
349# Runs integration tests in nix sandbox, and dumps outputs.
350#
351# WARNING: this can cause loss of work
352@idump:
353    rm ./tests/cmd/*nix.stderr -f || echo
354    rm ./tests/cmd/*nix.stdout -f || echo
355    nix build -L ./#trydump
356    cp ./result/dump/*nix.* ./tests/cmd/