This repository was archived by the owner on Jun 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJustfile
More file actions
183 lines (156 loc) · 5.55 KB
/
Copy pathJustfile
File metadata and controls
183 lines (156 loc) · 5.55 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Main Justfile for Xenith
#
# Provides a simple interface to run various tasks as well as
# useful variables.
#
# Provides:
# - `ROOT_DIR`: The root directory of the project.
# - `PACKER_DIR`: The directory where Packer templates are stored.
# - `ANSIBLE_DIR`: The directory where Ansible roles and playbooks are stored.
# - `WEBSITE_DIR`: The directory where the website files are stored.
#
# Check Just documentation for more information:
# https://just.systems/man/en/introduction.html
# ------------------------------
# Settings
# ------------------------------
set shell := ["/usr/bin/env", "bash", "-c"]
set allow-duplicate-recipes := true
# ------------------------------
# Requirements
# ------------------------------
cargo := require("cargo")
hugo := require("hugo")
xdg-open := require("xdg-open")
# ------------------------------
# Variables
# ------------------------------
ROOT_DIR := source_directory()
PACKER_DIR := ROOT_DIR / "packer"
ANSIBLE_DIR := ROOT_DIR / "ansible"
WEBSITE_DIR := ROOT_DIR / "xenith-website"
build_profile := "dev"
build_package := ""
# ------------------------------
# Aliases
# ------------------------------
alias cov := coverage
alias fmt := format
alias check := lint
# ------------------------------
# Tasks
# ------------------------------
[doc("Default task - will be run when no task is specified.")]
default:
@just --list
@echo
@echo "Note: you can run recipes from subdirectories with: just <subdir>/<recipe>."
@echo "For example: just packer/build-image."
[confirm("Are you sure you want to clean the build directory? (y/n)")]
[doc("Clean the Cargo build directory.")]
clean package=build_package:
{{ cargo }} clean {{ if package == "" { "" } else { "-p " + package } }}
[doc("Format the code using rustfmt.")]
[group("fmt")]
format package=build_package:
{{ cargo }} fmt {{ if package == "" { "--all" } else { "-p " + package } }} -- --emit=files
[doc("Run strict static analysis using Clippy.")]
[group("lint")]
lint package=build_package:
{{ cargo }} clippy \
--all-targets \
--all-features \
{{ if package == "" { "--all" } else { "-p " + package } }}
[doc("Check for unused dependencies.")]
[group("lint")]
udeps:
RUSTC_BOOTSTRAP=1 {{ cargo }} udeps --all-targets --backend depinfo
[doc("Check for security vulnerabilities, license compliance and others in dependencies.")]
[group("lint")]
deny:
{{ cargo }} deny --all-features check
[doc("Run all tests.")]
[group("test")]
test package=build_package:
{{ cargo }} nextest run \
{{ if package == "" { "--workspace" } else { "-p " + package } }} \
--all-features \
--all-targets
[doc("Run crate documentation tests.")]
[group("docs")]
[group("test")]
test-docs package=build_package:
{{ cargo }} test {{ if package == "" { "--all" } else { "-p " + package } }} --doc
[doc("Run coverage analysis.")]
[group("test")]
coverage package=build_package:
{{ cargo }} tarpaulin \
--all-targets \
--all-features \
--exclude-files **/examples/*.rs \
{{ if package == "" { "--workspace " } else { "-p " + package } }}
[doc("Build Rust crates documentation")]
[group("docs")]
build-rustdocs package=build_package:
RUSTDOCFLAGS="$RUSTDOCFLAGS --enable-index-page -Zunstable-options --default-theme=ayu" {{ cargo }} +nightly doc \
{{ if package == "" { "--all" } else { "-p " + package } }} \
--workspace \
--no-deps \
--document-private-items
[doc("Serve rustdocs.")]
[group("docs")]
[working-directory(".")]
@serve-rustdocs package=build_package:
echo "Serving rustdocs... "
{{ xdg-open }} {{ ROOT_DIR }}/target/doc/{{ package }}/index.html
[doc("Build project's documentation.")]
[group("docs")]
[working-directory("./xenith-website")]
@build-docs:
echo "Building the documentation... "
{{ hugo }} \
--gc --minify
[doc("Serve the documentation.")]
[group("docs")]
[working-directory("./xenith-website")]
@serve-docs:
echo "Serving the documentation... "
{{ hugo }} server \
--logLevel debug \
--buildDrafts \
--disableFastRender
[doc("Build project. Use release parameter for release builds. Use package parameter to build a specific package.")]
[group("build")]
build profile=build_profile package=build_package:
{{ cargo }} build {{ if profile == "release" { "--release" } else { "" } }} --all-targets {{ if package == "" { "--workspace" } else { "-p " + package } }}
[doc("Run the project with configuration file. Use release parameter for release builds. Use package parameter to run a specific package.")]
[group("run")]
run profile=build_profile package=build_package: lint format
{{ cargo }} run {{ if profile == "release" { "--release" } else { "" } }} {{ if package == "" { "" } else { "-p " + package } }}
[doc("Run a specific example with configuration file. Use release parameter for release builds.")]
[group("run")]
run-example example profile=build_profile:
RUST_LOG=info {{ cargo }} run {{ if profile == "release" { "--release" } else { "" } }} --example {{ example }}
[group("quality")]
coupling package type="summary":
#!/usr/bin/env bash
set -euo pipefail
case "{{ type }}" in
summary)
FLAG="--summary"
;;
hotspots)
FLAG="--hotspots"
;;
web)
FLAG="--web"
;;
ai)
FLAG="--ai"
;;
*)
echo "Error: You must use one of those: summary/hotspots/web/ai"
exit 1
;;
esac
{{ cargo }} coupling "$FLAG" --exclude-tests {{ package }}