-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnurfile
More file actions
152 lines (142 loc) · 3.49 KB
/
nurfile
File metadata and controls
152 lines (142 loc) · 3.49 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
use .github/common.nu run-cmd
# Build rust API docs
def "nur docs rs" [
--open (-o), # open the built docs in the default browser
] {
mut cmd = [
"cargo",
"doc",
"--no-deps",
"--lib",
"--package",
"cpp-linter",
"--package",
"clang-installer",
]
if $open {
$cmd = $cmd | append "--open"
}
run-cmd ...$cmd
}
# Build mkdocs output.
#
# This uses `uv` to drive `mkdocs`.
# This also ensures the cli-gen binding is built because
# the CLI is part of the documentation.
export def "nur docs" [
--build (-b), # Build the docs without serving them.
--dirty (-d), # Skip re-building bindings and use the previously built version.
--open (-o), # Open the built docs in your browser.
] {
mut sync_args = [--package cli-gen --all-groups]
let has_cli_gen_installed = (^uv pip show cli-gen) | complete | ($in.exit_code == 0)
if not $dirty or not $has_cli_gen_installed {
$sync_args = $sync_args | append [--reinstall-package cli-gen]
}
run-cmd uv sync ...$sync_args
let mkdocs_cmd = if $build { "build" } else { "serve" }
mut cmd = [
uv run mkdocs $mkdocs_cmd --config-file docs/mkdocs.yml
]
if $open and not $build {
$cmd = $cmd | append '--open'
}
run-cmd ...$cmd
if $open and $build {
start docs/site/index.html
}
}
# Run unit tests
#
# To select a profile defined in .config/nextest.toml:
# nur test --profile ci
#
# Otherwise, the default profile is used.
export def "nur test" [
--profile (-p): string = "default", # The nextest profile to use.
--clean (-c), # Clean before testing
] {
# run-cmd uv sync --group test
if $clean {
run-cmd cargo llvm-cov clean
}
let cmd = [
cargo,
llvm-cov,
--no-report,
nextest,
--package,
cpp-linter,
--package,
clang-installer,
--features,
bin,
--lib,
--tests,
--color,
always,
--profile,
$profile,
]
run-cmd uv run --group test ...$cmd
}
# Generate HTML coverage report
export def "nur test llvm-cov" [
--open (-o), # Open the built report in your browser.
] {
mut cmd = [
cargo
llvm-cov
report
--html
--ignore-filename-regex
main
]
if $open {
$cmd = $cmd | append "--open"
}
run-cmd ...$cmd
}
# Generate lcov.info
#
# Useful for codecov uploads and VSCode extensions
# like "Coverage Gutters".
export def "nur test lcov" [] {
run-cmd ...[
cargo
llvm-cov
report
--lcov
--output-path
lcov.info
--ignore-filename-regex
main
]
}
# Run clippy and rustfmt
export def "nur lint" [
--check (-c), # Only check, do not fix
] {
mut clippy = [cargo clippy --all-features --all-targets]
if $check {
$clippy = $clippy | append [-- -D warnings]
} else {
$clippy = $clippy | append [--fix --allow-dirty --allow-staged]
}
run-cmd ...$clippy
mut fmt = [cargo fmt]
if $check {
$fmt = $fmt | append "--check"
}
run-cmd ...$fmt
}
export def "nur pre-commit" [
--all (-a), # Run pre-commit hooks on all files, not just staged files.
--upgrade (-U), # Upgrade pre-commit hooks to the latest version.
] {
if $upgrade {
run-cmd uv run pre-commit autoupdate
}
let args = if $all { ["--all-files"] } else { [] }
run-cmd uv run pre-commit run ...$args
}