cargo-make 0.3.77

Rust task runner and build tool.
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516

[config]
init_task = "init"
end_task = "end"

[env]
RUST_BACKTRACE = "full"
KCOV_VERSION = "33"

[tasks.default]
description = "Default task points to the development testing flow"
dependencies = [
    "dev-test-flow"
]

[tasks.ci-flow]
description = "CI task will run cargo build and cargo test with verbose output"
dependencies = [
    "pre-ci-flow",
    "pre-build",
    "build-verbose",
    "post-build",
    "pre-test",
    "test-verbose",
    "post-test",
    "ci-coverage-flow",
    "post-ci-flow"
]

[tasks.workspace-ci-flow]
description = "CI task will run CI flow for each member and merge coverage reports"
dependencies = [
    "pre-workspace-ci-flow",
    "workspace-members-ci",
    "workspace-coverage",
    "post-workspace-ci-flow"
]

[tasks.dev-test-flow]
description = "Development testing flow will first format the code, and than run cargo build and test"
dependencies = [
    "format-flow",
    "pre-build",
    "build",
    "post-build",
    "pre-test",
    "test",
    "post-test"
]

[tasks.pre-publish-clean-flow]
description = "Clears old artifactes before publishing"
dependencies = [
    "pre-clean",
    "clean",
    "post-clean"
]

[tasks.pre-publish-conditioned-clean-flow]
description = "Clears old artifactes before publishing"
condition = { env_not_set = [ "CARGO_MAKE_SKIP_PREPUBLISH_CLEAN" ] }
run_task = "pre-publish-clean-flow"

[tasks.publish-flow]
description = "Publish flow - First clean the target directory of any old leftovers, package and publish"
dependencies = [
    "pre-publish-conditioned-clean-flow",
    "pre-publish",
    "publish",
    "post-publish"
]

[tasks.build-flow]
# This is the full sanity testing flow which includes:
# cleanup of old build
# generating docs and moving them to the docs folder
# running cargo build and test
# running cargo plugins such as security and dependency validations
description = "Full sanity testing flow."
dependencies = [
    "init-build-flow",
    "pre-clean",
    "clean-apidocs",
    "clean",
    "post-clean",
    "format-flow",
    "pre-build",
    "build",
    "post-build",
    "pre-test",
    "test",
    "post-test",
    "pre-verify-project",
    "verify-project",
    "post-verify-project",
    "pre-audit",
    "audit",
    "post-audit",
    "pre-outdated",
    "outdated",
    "post-outdated",
    "pre-docs",
    "docs",
    "post-docs",
    "copy-apidocs",
    "end-build-flow"
]

[tasks.empty]
description = "Empty Task"

[tasks.init]
description = "By default this task is invoked at the start of every cargo-make run."

[tasks.end]
description = "By default this task is invoked at the end of every cargo-make run."

[tasks.init-build-flow]

[tasks.pre-clean]

[tasks.clean-apidocs]
description = "Delete API docs."
command = "rm"
args = ["-Rf", "./docs/api"]

[tasks.clean]
description = "Runs the cargo clean command."
command = "cargo"
args = ["clean"]

[tasks.post-clean]

[tasks.delete-lock]
description = "Deletes the Cargo.lock file."
script = [
    "rm -f ./Cargo.lock"
]

[tasks.pre-format]

[tasks.format]
description = "Runs the cargo rustfmt plugin."
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--write-mode=overwrite"]

[tasks.post-format]

[tasks.format-flow]
description = "Runs the cargo rustfmt plugin as part of a flow."
dependencies = [
    "pre-format",
    "format",
    "post-format"
]

[tasks.pre-docs]

[tasks.docs]
description = "Generate rust documentation."
command = "cargo"
args = ["doc", "--no-deps"]

[tasks.post-docs]

[tasks.pre-build]

[tasks.build]
description = "Runs the rust compiler."
command = "cargo"
args = ["build", "--all-features"]

[tasks.build-verbose]
description = "Runs the rust compiler with verbose output."
command = "cargo"
args = ["build", "--verbose", "--all-features"]

[tasks.post-build]

[tasks.pre-test]

[tasks.test]
description = "Runs all available tests."
command = "cargo"
args = ["test", "--all-features"]

[tasks.test-verbose]
description = "Runs all available tests with verbose output."
command = "cargo"
args = ["test", "--verbose", "--all-features"]

[tasks.post-test]

[tasks.pre-bench]

[tasks.bench]
description = "Runs all available bench files."
command = "cargo"
args = ["bench"]

[tasks.post-bench]

[tasks.bench-flow]
description = "Runs a bench flow."
dependencies = [
    "pre-bench",
    "bench",
    "post-bench"
]

[tasks.pre-verify-project]

[tasks.verify-project]
description = "Runs verify-project cargo plugin."
command = "cargo"
args = ["verify-project"]

[tasks.post-verify-project]

[tasks.pre-audit]

[tasks.audit]
description = "Runs verify-audit cargo plugin."
install_crate = "cargo-audit"
command = "cargo"
args = ["audit"]

[tasks.post-audit]

[tasks.pre-outdated]

[tasks.outdated]
description = "Runs verify-outdated cargo plugin."
install_crate = "cargo-outdated"
command = "cargo"
args = ["outdated", "--root-deps-only", "--exit-code", "1"]

[tasks.post-outdated]

[tasks.clippy]
description = "Runs clippy code linter."
install_crate = "clippy"
command = "cargo"
args = ["clippy"]

[tasks.copy-apidocs]
description = "Copies the generated documentation to the docs/api directory."
script = [
    "mkdir -p ./docs/api",
    "mv ./target/doc/* ./docs/api"
]

[tasks.end-build-flow]

[tasks.pre-package]

[tasks.package]
description = "Runs the cargo package command."
command = "cargo"
args = ["package"]

[tasks.post-package]

[tasks.pre-publish]

[tasks.publish]
description = "Runs the cargo publish command."
command = "cargo"
args = ["publish"]

[tasks.post-publish]

[tasks.pre-git-add]

[tasks.git-add]
description = "Runs the cargo add command."
command = "git"
args = ["add", "."]

[tasks.post-git-add]

[tasks.pre-git-status]

[tasks.git-status]
description = "Runs git status command."
command = "git"
args = ["status"]

[tasks.post-git-status]

[tasks.pre-git-commit]

[tasks.git-commit]
description = "Runs git commit command."
command = "git"
args = ["commit"]

[tasks.git-commit-message]
description = "Runs git commit command with the message defined in the COMMIT_MSG environment variable."
script = [
    "git commit -m \"$COMMIT_MSG\""
]

[tasks.post-git-commit]

[tasks.pre-git-push]

[tasks.git-push]
description = "Runs git push command."
command = "git"
args = ["push"]

[tasks.post-git-push]

[tasks.git-pull]
description = "Runs git pull command."
command = "git"
args = ["pull"]

[tasks.pre-ci-flow]

[tasks.post-ci-flow]

[tasks.pre-workspace-ci-flow]

[tasks.post-workspace-ci-flow]

[tasks.workspace-members-ci]
description = "Runs the ci-flow for every workspace member."
script = [
'''
#prevent codecov publish in member builds
export CARGO_MAKE_SKIP_CODECOV="true"

export CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY="${CARGO_MAKE_WORKING_DIRECTORY}/target"

#output coverage data goes into workspace level
export CARGO_MAKE_COVERAGE_REPORT_DIRECTORY="${CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY}/coverage"

cargo make --loglevel=${CARGO_MAKE_LOG_LEVEL} ci-flow

unset CARGO_MAKE_COVERAGE_REPORT_DIRECTORY
unset CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY
unset CARGO_MAKE_SKIP_CODECOV
'''
]

[tasks.workspace-members-ci.windows]
run_task = "ci-flow"

[tasks.workspace-coverage]
description = "Runs coverage task (by default the codecov flow)."
linux_alias = "codecov"

[tasks.pre-coverage]

[tasks.coverage]
description = "Runs coverage (by default using kcov)."
alias = "coverage-kcov"

[tasks.coverage-kcov]
description = "Installs (if missing) and runs coverage using kcov (not supported on windows)"
windows_alias = "empty"
condition = { env_set = [ "KCOV_VERSION" ] }
install_script = [
'''
command -v kcov >/dev/null 2>&1 || {
    if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
        sudo apt-get update || true
        sudo apt-get install -y libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev

        wget https://github.com/SimonKagstrom/kcov/archive/v$KCOV_VERSION.zip
        unzip v$KCOV_VERSION.zip
        cd kcov-$KCOV_VERSION
        mkdir build
        cd ./build
        cmake ..
        make
        sudo make install
        cd ../..
        rm -rf kcov-$KCOV_VERSION
    fi
}
'''
]
script = [
'''
echo "Working Directory: ${CARGO_MAKE_WORKING_DIRECTORY}"

TARGET_DIRECTORY="target/coverage"
if [ -n "$CARGO_MAKE_COVERAGE_REPORT_DIRECTORY" ]; then
    TARGET_DIRECTORY="$CARGO_MAKE_COVERAGE_REPORT_DIRECTORY"
    mkdir -p ${TARGET_DIRECTORY}
else
    mkdir -p ./target/coverage
fi

BINARY_DIRECTORY=target/debug/deps
if [ -n "$CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY" ]; then
    BINARY_DIRECTORY="${CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY}/debug/deps"
fi

echo "Running unit tests from directory: ${BINARY_DIRECTORY}"
for file in ${BINARY_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}*
do
    if "$file" ; then
        echo "Running file: $file"
        kcov --include-pattern=${CARGO_MAKE_WORKING_DIRECTORY}/src/ "$TARGET_DIRECTORY" "$file" || true
    fi
done

echo "Running integration tests from directory: ${BINARY_DIRECTORY}"
for file in ${BINARY_DIRECTORY}/test_*
do
    if "$file" ; then
        echo "Running file: $file"
        kcov --include-pattern=${CARGO_MAKE_WORKING_DIRECTORY}/src/ "$TARGET_DIRECTORY" "$file" || true
    fi
done
'''
]

[tasks.coverage-tarpaulin]
description = "Runs coverage using tarpaulin rust crate (linux only)"

[tasks.coverage-tarpaulin.linux]
install_crate = "cargo-tarpaulin"
command = "cargo"
args = ["tarpaulin"]

[tasks.post-coverage]

[tasks.coverage-flow]
description = "Runs the full coverage flow."
dependencies = [
    "pre-coverage",
    "coverage",
    "post-coverage"
]

[tasks.codecov]
description = "Runs codecov script to upload coverage results to codecov."
windows_alias = "empty"
script_runner = "bash"
condition = { env_not_set = [ "CARGO_MAKE_SKIP_CODECOV" ] }
script = [
    "#!/usr/bin/env bash",
    "bash <(curl -s https://codecov.io/bash)"
]

[tasks.codecov-flow]
description = "Runs the full coverage flow and uploads the results to codecov."
windows_alias = "empty"
dependencies = [
    "coverage-flow",
    "codecov"
]

[tasks.ci-coverage-flow]
description = "Runs the coverage flow and uploads the results to codecov."
windows_alias = "empty"
condition = { env = { "TRAVIS" = "true", "CARGO_MAKE_RUN_CODECOV" = "true" } }
run_task = "codecov-flow"

[tasks.upload-artifacts]
description = "Uploads the binary artifact from the cargo package/publish output."
alias = "bintray-upload"

[tasks.bintray-upload]
description = "Uploads the binary artifact from the cargo package/publish output to bintray."

[tasks.bintray-upload.linux]
condition = { env_set = [ "BINTRAY_API_KEY", "BINTRAY_OWNER_NAME", "BINTRAY_PACKAGE_NAME" ] }
script = [
    "curl -T \"./target/package/${CARGO_MAKE_CRATE_NAME}-${CARGO_MAKE_CRATE_VERSION}/target/debug/${CARGO_MAKE_CRATE_NAME}\" -u${BINTRAY_OWNER_NAME}:${BINTRAY_API_KEY} -H \"X-Bintray-Package:${BINTRAY_PACKAGE_NAME}\" -H \"X-Bintray-Version:v${CARGO_MAKE_CRATE_VERSION}\" https://api.bintray.com/content/${BINTRAY_OWNER_NAME}/${CARGO_MAKE_CRATE_NAME}/${CARGO_MAKE_CRATE_NAME}_v${CARGO_MAKE_CRATE_VERSION}?override=1",
    "curl -X POST -u${BINTRAY_OWNER_NAME}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER_NAME}/${CARGO_MAKE_CRATE_NAME}/${BINTRAY_PACKAGE_NAME}/v${CARGO_MAKE_CRATE_VERSION}/publish"
]

[tasks.github-publish]
# Creates a new github release.
# Set the GITHUB_API_TOKEN environment variables to automatically authenticate.
description = "Creates a new github release."
install_crate = "cargo-hublish"
command = "cargo"
args = ["hublish"]

[tasks.github-publish-custom-name]
# Creates a new github release.
# Set the GITHUB_API_TOKEN environment variables to automatically authenticate.
description = "Creates a new github release."
install_crate = "cargo-hublish"
args = ["hublish"]
script = [
    "cargo hublish --url \"https://api.github.com/repos/$GITHUB_REPO_NAME/releases\""
]

[tasks.build-publish-flow]
description = "Runs full sanity, generates github release and publishes the crate."
condition = { env_set = [ "COMMIT_MSG", "GITHUB_API_TOKEN", "GITHUB_REPO_NAME" ] }
env = { "CARGO_MAKE_SKIP_PREPUBLISH_CLEAN" = "true" }
run_task = "build-publish-flow-no-validation"

[tasks.build-publish-flow-no-validation]
dependencies = [
    "delete-lock",
    "build-flow",
    "git-add",
    "git-status",
    "git-commit-message",
    "git-push",
    "github-publish-custom-name",
    "publish-flow",
    "upload-artifacts",
    "git-pull"
]