-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.toml
215 lines (179 loc) · 6.4 KB
/
Makefile.toml
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# This directory contains the scripts that run our CI activity and checks.
# The idea is that these scripts let you easily replicate CI steps locally.
#
# The most common tasks are
# - `fix-all` tries to fix all the formatting and code style issues. This is
# most likely the command you want to run.
# - `check-all` runs all the formatting and code-style checks we also run in CI
# This performs all teh same operations as `fix-ll` but complains instead of
# solving them.
# - `pdg-tests` which runs our current complete test suite
#
# The CI actually runs some of these checks in separate steps to provide easier
# insight into which part failed.
[env]
TEST_DIR = "crates/paralegal-flow/tests"
CARGO_TERM_VERBOSE = { condition = { env_true = ["CI"] }, value = "true" }
[config]
default_to_workspace = false
[tasks.install]
command = "cargo"
args = ["install", "--locked", "--path", "crates/paralegal-flow"]
[tasks.ci-tests]
description = "The suite of tests we run in CI"
dependencies = ["cargo-tests", "guide-project"]
[tasks.check-all]
description = "Perform all formatting-like checks. This is the same set that runs in the CI."
dependencies = ["format-check-all", "clippy-check-all", "doc-check"]
[tasks.fix-all]
description = """\
Attempt to perform any formatting and code structure related fixes.
Note: This uses the clippy-fix command under the hood. This can introduce
breaking changes and so this tscript only passes `--allow-staged` to the
fix command. What this means for you is that you need to stage (or commit)
your changes in git for the fix command to work. This is a precaution that
allows you to inspect, test and potentially reject clippy's changes before
accepting them.
Because we invoke the fix command multiple separate time it may fail again
because of unstaged changes after applying the first fix. Inspect the changes,
stage them and rerun the script until no more errors occur.
"""
dependencies = ["format-all", "clippy-all"]
[tasks.cargo-tests]
command = "cargo"
args = ["test", "--no-fail-fast"]
[tasks.flowistry-tests]
command = "cargo"
args = ["test", "-pflowistry_pdg", "-pflowistry_pdg_construction"]
[tasks.paralegal-flow-tests]
command = "cargo"
args = ["test", "-pparalegal-flow", "-pparalegal-spdg"]
[tasks.policy-tests]
command = "cargo"
args = ["test", "-pparalegal-policy"]
[tasks.guide-project]
description = "Build and run the policy from the guide."
cwd = "guide/deletion-policy"
command = "cargo"
args = ["run"]
dependencies = ["install"]
[tasks.doc-check]
dependencies = [
"rustdoc-paralegal-spdg",
"rustdoc-paralegal-policy",
"rustdoc-paralegal",
]
[tasks.rustdoc-one]
private = true
command = "cargo"
args = ["rustdoc", "-p", "${RUSTDOC_TARGET}", "--", "-Drustdoc::all"]
[tasks.rustdoc-paralegal-spdg]
extend = "rustdoc-one"
env = { "RUSTDOC_TARGET" = "paralegal-spdg" }
[tasks.rustdoc-paralegal-policy]
extend = "rustdoc-one"
env = { "RUSTDOC_TARGET" = "paralegal-policy" }
[tasks.rustdoc-paralegal]
extend = "rustdoc-one"
env = { "RUSTDOC_TARGET" = "paralegal" }
[tasks.format-all]
env = { "FORMAT_ARGS" = "fmt", "INCLUDE_TESTS" = "true" }
run_task = "format-run"
[tasks.format-check-all]
env = { "FORMAT_ARGS" = "fmt --check", "INCLUDE_TESTS" = "true" }
run_task = "format-run"
[tasks.clippy-all]
description = """\
Note: You are using the clippy-fix command. Because this can introduce breaking
changes this script only passes `--allow-staged` to the fix command. What this
means for you is that you need to stage (or commit) your changes in git for the
fix command to work. This is a precaution that allows you to inspect, test and
potentially reject clippy's changes before accepting them.
Because we invoke the fix command multiple separate time it may fail again
because of unstaged changes after applying the first fix. Inspect the changes,
stage them and rerun the script until no more errors occur.
"""
run_task = "format-run"
[tasks.clippy-all.env]
FORMAT_ARGS = "clippy --fix --allow-staged --all -- -Dwarnings"
INCLUDE_TESTS = { unset = true }
[tasks.clippy-check-all]
run_task = "format-run"
[tasks.clippy-check-all.env]
FORMAT_ARGS = "clippy --all -- -Dwarnings"
INCLUDE_TESTS = { unset = true }
[tasks.format-base]
description = """\
This is bit ugly, because we want to reuse this tasks
- In different directories (controlled by the `FORMAT_WD` env variable)
- With different base comamnds (`cargo clippy` vs `cargo fmt`)
- With different goals (check vs fix)
The last two are both done via the `FORMAT_ARGS` command.
Basically this task doesn't do anything, the only reason it exists is so that we can
combine multiple partially configured runs of this in the `format-run` task. That run
configures the various places where this task is called on, then the top-level tasks
(`format-check-all`, `format-all`, `clippy-check-all`, `clippy-all`) select the actual
command to run but is able to reuse the targets to run the commands on.
"""
private = true
cwd = "${FORMAT_WD}"
command = "cargo"
args = ["@@split(FORMAT_ARGS, )"]
[tasks.format-run]
private = true
dependencies = [
"format-props",
"format-guide-example",
"format-guide-policy",
"format-tests",
]
[tasks.format-props]
private = true
env = { "FORMAT_WD" = "." }
run_task = "format-base"
[tasks.format-guide-example]
private = true
env = { "FORMAT_WD" = "guide/file-db-example" }
run_task = "format-base"
[tasks.format-guide-policy]
private = true
env = { "FORMAT_WD" = "guide/deletion-policy" }
run_task = "format-base"
[tasks.format-tests]
private = true
condition = { env_set = ["INCLUDE_TESTS"] }
script_runner = "@duckscript"
script = '''
wd = pwd
test_glob = concat ${TEST_DIR} /*
test_dirs = glob_array ${test_glob}
for dir in ${test_dirs}
cargo_toml_path = concat ${dir} /Cargo.toml
if is_path_exists ${cargo_toml_path}
cd ${dir}
exec --fail-on-error cargo %{FORMAT_ARGS}
cd ${wd}
end
end
cd crates/paralegal-policy/tests/test-crate
exec cargo %{FORMAT_ARGS}
'''
[tasks.populate-doc-dir]
dependencies = ["get-rustc-docs"]
script_runner = "@duckscript"
script = '''
source_path = concat ${RUSTUP_HOME} /toolchains/ ${RUSTUP_TOOLCHAIN} /share/doc/rust/html/rustc
mkdir docs
mv doc-src/index.html docs
mv ${source_path} docs/compiler
'''
[tasks.get-rustc-docs]
command = "rustup"
args = ["component", "add", "rustc-docs"]
dependencies = ["clean-rustc-docs-location"]
[tasks.clean-rustc-docs-location]
command = "rm"
args = [
"-rf",
"${RUSTUP_HOME}/toolchains/${RUSTUP_TOOLCHAIN}/share/doc/rust/html/rustc",
]