-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
116 lines (97 loc) · 3.46 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env just --justfile
set dotenv-load := true
# Build and run.
run *FLAGS:
cargo run {{FLAGS}}
just css
just index
watch *FLAGS:
cargo watch -x run -i output -s 'just css' -s 'just index' {{FLAGS}}
index *FLAGS:
pagefind {{FLAGS}}
serve *FLAGS:
miniserve --index=index.html output {{FLAGS}}
css *FLAGS:
npx tailwindcss -i css/main.css -o output/main.css {{FLAGS}}
# Apply strict formatting.
fmt *FLAGS:
cargo +nightly fmt --all {{FLAGS}}
# Run clippy on codebase, tests, examples, while testing all features.
check *FLAGS:
cargo clippy --tests --examples --all-targets --all-features --workspace -- -D warnings {{FLAGS}}
# Run tests.
test *FLAGS:
cargo nextest run --all-features --workspace {{FLAGS}}
# Generate documentation. Add '-- open' to open the docs in a web page.
doc *FLAGS:
cargo doc --all-features --document-private-items --workspace
# Calculate coverage and open page with the results.
coverage *FLAGS:
cargo llvm-cov {{FLAGS}}
# Benchmark codebase with criterion.
benchmark *FLAGS:
cargo criterion {{FLAGS}}
# Check for unused dependencies, audit for vulnerabilities,
# and check if newer version of depenedencies is available.
thorough-check:
cargo +nightly udeps --all-targets
cargo audit
cargo upgrades
# Check for unusead features. Opens results in a browser.
unused-features:
unused-features analyze
unused-features build-report --input report.json
rm report.json
mv report.html /tmp
xdg-open /tmp/report.html
# Check build timings.
build-timings:
cargo clean
cargo build --release --quiet --timings
xdg-open /target/cargo-timings/cargo-timing.html
# Runs all checks necessary before commit.
# Checks formating, code quality, tests, documentation and more.
pre-commit:
@just fmt
@just check
@just test
@just doc
@just thorough-check
@just unused-features
# Similar to `pre-commit` command, but is not interactive and doesn't modify the codebase.
# Suitable for automated CI pipelines.
ci:
@just fmt --check
@just check
# @just test
@just doc
@just thorough-check
# Initializes the project, installing all tools necessary. Should be run once before begining of development.
init:
npm install
echo # installing nightly used by `just fmt` and `cargo udeps`
rustup install nightly
echo # things required by `just test`
cargo install cargo-nextest
echo # things required by `just watch`
cargo install cargo-watch
echo # things required by `just coverage`
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov
echo # things required by `just benchmark`
cargo install cargo-criterion
echo # things required by `just thorough-check`
cargo install cargo-udeps
cargo install cargo-audit
cargo install cargo-upgrades
cargo install cargo-unused-features
cargo install pagefind
# Deploy redirects to new site to netlify
deploy-netlify site="ask-historians-archive" input_name="ah" limit="2022-01-01":
rm -rf output
mkdir output
echo '* https://archive.observer/:splat' > output/_redirects
netlify deploy --site="{{site}}" --dir output --prod
deploy-ssh host path site="ask-historians-archive" input_name="ah" limit="2014-01-01":
just run --release -- --limit-posts={{limit}} --submissions=input/{{input_name}}_posts.json --comments=input/{{input_name}}_comments.json
tar -c --zstd ./output | ssh {{host}} 'mkdir {{path}} && cd {{path}} && tar -x --zstd'