From b5cd4fd53db686d39b45669189d06e0684d57b94 Mon Sep 17 00:00:00 2001 From: sagie gur ari Date: Sat, 31 Jul 2021 13:00:19 +0000 Subject: [PATCH] format toml files --- examples/condition.toml | 20 +++- examples/env.toml | 30 ++++-- examples/install.toml | 5 +- examples/run_task.toml | 6 +- examples/watch.toml | 4 +- src/lib/descriptor/makefiles/github.toml | 20 +++- .../descriptor/makefiles/rust-coverage.toml | 29 ++++- src/lib/descriptor/makefiles/rust.toml | 102 ++++++++++++++---- src/lib/descriptor/makefiles/toml.toml | 4 +- src/lib/test/makefiles/env.toml | 4 +- src/lib/test/test_files/.crates.toml | 8 +- 11 files changed, 181 insertions(+), 51 deletions(-) diff --git a/examples/condition.toml b/examples/condition.toml index 535f183b..95f1aa95 100755 --- a/examples/condition.toml +++ b/examples/condition.toml @@ -33,9 +33,19 @@ args = ["running test-default"] [tasks.test-routing] run_task = [ - { name = "test1", condition = { platforms = ["windows", "linux"], channels = ["beta", "stable"] } }, - { name = "test2", condition = { platforms = ["mac"], rust_version = { min = "1.20.0", max = "1.30.0" } } }, - { name = "test3", condition_script = ["somecommand"] }, + { name = "test1", condition = { platforms = [ + "windows", + "linux", + ], channels = [ + "beta", + "stable", + ] } }, + { name = "test2", condition = { platforms = [ + "mac", + ], rust_version = { min = "1.20.0", max = "1.30.0" } } }, + { name = "test3", condition_script = [ + "somecommand", + ] }, { name = "test-default" }, ] @@ -58,7 +68,9 @@ echo "condition was met" ''' [tasks.test-file-not-exists-condition] -condition = { files_not_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml2"] } +condition = { files_not_exist = [ + "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml2", +] } script = ''' echo "condition was met" ''' diff --git a/examples/env.toml b/examples/env.toml index 13bb5336..cd48c9c5 100755 --- a/examples/env.toml +++ b/examples/env.toml @@ -1,8 +1,10 @@ -env_files = [{ path = "./profile.env", profile = "development" }, { path = "./test.env" }] +env_files = [ + { path = "./profile.env", profile = "development" }, + { path = "./test.env" }, +] -env_scripts = [ - ''' +env_scripts = [''' #!@duckscript echo first env script... @@ -10,15 +12,13 @@ composite_env_value = get_env COMPOSITE echo COMPOSITE = ${composite_env_value} set_env COMPOSITE_2 ${composite_env_value} -''', - ''' +''', ''' #!@duckscript echo second env script... composite_env_value = get_env COMPOSITE_2 echo COMPOSITE_2 = ${composite_env_value} -''', -] +'''] [config] skip_core_tasks = true @@ -39,14 +39,22 @@ ENV_FROM_LIST = [ "${SIMPLE}", "simple value: ${SIMPLE} script value: ${SCRIPT}", ] -CONDITIONED_VALUE = { value = "${SIMPLE}", condition = { env_set = ["SIMPLE"] } } -IF_UNDEFINED = { value = "defined_in_makefile", condition = { env_not_set = ["IF_UNDEFINED"] } } +CONDITIONED_VALUE = { value = "${SIMPLE}", condition = { env_set = [ + "SIMPLE", +] } } +IF_UNDEFINED = { value = "defined_in_makefile", condition = { env_not_set = [ + "IF_UNDEFINED", +] } } COMPOSITE_OF_MAPPED = "VALUE: ${IF_UNDEFINED}" PATH_GLOB = { glob = "./src/**/mod.rs", include_files = true, include_dirs = false, ignore_type = "git" } [env.override-test] -PREFER_EXISTING = { value = "new", condition = { env_not_set = ["PREFER_EXISTING"] } } -OVERWRITE_EXISTING = { value = "new", condition = { env_set = ["OVERWRITE_EXISTING"] } } +PREFER_EXISTING = { value = "new", condition = { env_not_set = [ + "PREFER_EXISTING", +] } } +OVERWRITE_EXISTING = { value = "new", condition = { env_set = [ + "OVERWRITE_EXISTING", +] } } [tasks.init] script_runner = "@duckscript" diff --git a/examples/install.toml b/examples/install.toml index 00d6f94c..a41901d8 100644 --- a/examples/install.toml +++ b/examples/install.toml @@ -8,6 +8,9 @@ command = "cargo" args = ["make", "--version"] [tasks.complex-example] -install_crate = { crate_name = "cargo-make", binary = "cargo", test_arg = ["make", "--version"], min_version = "0.0.1" } +install_crate = { crate_name = "cargo-make", binary = "cargo", test_arg = [ + "make", + "--version", +], min_version = "0.0.1" } command = "cargo" args = ["make", "--version"] diff --git a/examples/run_task.toml b/examples/run_task.toml index 31270d4f..cc656be0 100755 --- a/examples/run_task.toml +++ b/examples/run_task.toml @@ -34,4 +34,8 @@ args = ["cleanup"] run_task = { name = ["echo1", "echo2"], fork = true, cleanup_task = "cleanup" } [tasks.cleanup-example-with-error] -run_task = { name = ["echo1", "echo2", "fail"], fork = true, cleanup_task = "cleanup" } +run_task = { name = [ + "echo1", + "echo2", + "fail", +], fork = true, cleanup_task = "cleanup" } diff --git a/examples/watch.toml b/examples/watch.toml index c2b027ee..ed76867b 100644 --- a/examples/watch.toml +++ b/examples/watch.toml @@ -16,4 +16,6 @@ watch = true [tasks.watch-args-example] command = "echo" args = ["Triggered by watch"] -watch = { postpone = true, no_git_ignore = true, ignore_pattern = "examples/files/*", watch = ["./docs/"] } +watch = { postpone = true, no_git_ignore = true, ignore_pattern = "examples/files/*", watch = [ + "./docs/", +] } diff --git a/src/lib/descriptor/makefiles/github.toml b/src/lib/descriptor/makefiles/github.toml index 30ff999a..4bad016d 100644 --- a/src/lib/descriptor/makefiles/github.toml +++ b/src/lib/descriptor/makefiles/github.toml @@ -15,12 +15,21 @@ category = "Publish" dependencies = ["github-hub-find"] condition = { env = { "CARGO_MAKE_GIT_BRANCH" = "master" } } run_task = [ - { name = "github-publish-hub", condition = { env_set = ["GITHUB_API_TOKEN"], env_true = ["CARGO_MAKE_GITHUB_HUB_CLI_FOUND"] } }, - { name = "github-publish-curl", condition = { platforms = ["linux", "mac"], env_set = [ + { name = "github-publish-hub", condition = { env_set = [ + "GITHUB_API_TOKEN", + ], env_true = [ + "CARGO_MAKE_GITHUB_HUB_CLI_FOUND", + ] } }, + { name = "github-publish-curl", condition = { platforms = [ + "linux", + "mac", + ], env_set = [ "GITHUB_API_TOKEN", "GITHUB_REPO_NAME", ] } }, - { name = "github-publish-hublish", condition = { env_set = ["GITHUB_REPO_NAME"] } }, + { name = "github-publish-hublish", condition = { env_set = [ + "GITHUB_REPO_NAME", + ] } }, ] [tasks.github-hub-find] @@ -76,7 +85,10 @@ cargo hublish --url "https://api.github.com/repos/${GITHUB_REPO_NAME}/releases" # Creates a new github release. description = "Creates a new github release using curl." category = "Publish" -condition = { platforms = ["linux", "mac"], env_set = [ +condition = { platforms = [ + "linux", + "mac", +], env_set = [ "GITHUB_API_TOKEN", "GITHUB_REPO_NAME", "CARGO_MAKE_PROJECT_NAME", diff --git a/src/lib/descriptor/makefiles/rust-coverage.toml b/src/lib/descriptor/makefiles/rust-coverage.toml index f7eb5d38..41d19603 100644 --- a/src/lib/descriptor/makefiles/rust-coverage.toml +++ b/src/lib/descriptor/makefiles/rust-coverage.toml @@ -24,15 +24,24 @@ description = "Runs coverage (by default using kcov)." category = "Test" env = { "RUSTFLAGS" = "-C link-dead-code" } run_task = [ - { name = "coverage-tarpaulin", condition = { platforms = ["linux"], env = { "CARGO_MAKE_COVERAGE_PROVIDER" = "tarpaulin" } } }, - { name = "coverage-kcov", condition = { platforms = ["linux"] } }, + { name = "coverage-tarpaulin", condition = { platforms = [ + "linux", + ], env = { "CARGO_MAKE_COVERAGE_PROVIDER" = "tarpaulin" } } }, + { name = "coverage-kcov", condition = { platforms = [ + "linux", + ] } }, ] [tasks.coverage-kcov] description = "Installs (if missing) and runs coverage using kcov (not supported on windows)" category = "Test" dependencies = ["setup-sudo-env"] -condition = { env_set = ["CARGO_MAKE_KCOV_VERSION"], platforms = ["linux", "mac"] } +condition = { env_set = [ + "CARGO_MAKE_KCOV_VERSION", +], platforms = [ + "linux", + "mac", +] } script_runner = "bash" env = { "CARGO_MAKE_KCOV_INCLUDE_PATTERN" = "${CARGO_MAKE_WORKING_DIRECTORY}/src/" } install_script = ''' @@ -198,7 +207,12 @@ dependencies = ["pre-coverage", "coverage", "post-coverage"] [tasks.codecov] description = "Runs codecov script to upload coverage results to codecov." category = "Test" -condition = { env_not_set = ["CARGO_MAKE_SKIP_CODECOV"], platforms = ["linux", "mac"] } +condition = { env_not_set = [ + "CARGO_MAKE_SKIP_CODECOV", +], platforms = [ + "linux", + "mac", +] } script_runner = "bash" script = ''' #!/usr/bin/env bash @@ -214,5 +228,10 @@ dependencies = ["coverage-flow", "codecov"] [tasks.ci-coverage-flow] description = "Runs the coverage flow and uploads the results to codecov." category = "CI" -condition = { platforms = ["linux"], env_true = ["CARGO_MAKE_CI", "CARGO_MAKE_RUN_CODECOV"] } +condition = { platforms = [ + "linux", +], env_true = [ + "CARGO_MAKE_CI", + "CARGO_MAKE_RUN_CODECOV", +] } run_task = "codecov-flow" diff --git a/src/lib/descriptor/makefiles/rust.toml b/src/lib/descriptor/makefiles/rust.toml index ae5e1a14..725e51a7 100644 --- a/src/lib/descriptor/makefiles/rust.toml +++ b/src/lib/descriptor/makefiles/rust.toml @@ -118,7 +118,9 @@ description = "Delete API docs." category = "Documentation" workspace = false run_task = [ - { name = "workspace-clean-apidocs", condition = { env_set = ["CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER"] } }, + { name = "workspace-clean-apidocs", condition = { env_set = [ + "CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER", + ] } }, { name = "crate-clean-apidocs" }, ] @@ -160,7 +162,9 @@ category = "Cleanup" description = "Deletes the Cargo.lock file." category = "Cleanup" run_task = [ - { name = "workspace-delete-lock", condition = { env_set = ["CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER"] } }, + { name = "workspace-delete-lock", condition = { env_set = [ + "CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER", + ] } }, { name = "crate-delete-lock" }, ] @@ -191,8 +195,12 @@ dependencies = ["delete-lock", "dev-test-flow"] [tasks.install-rustfmt] description = "Installs cargo rustfmt plugin." category = "Development" -env.CFG_RELEASE = { value = "${CARGO_MAKE_RUST_VERSION}", condition = { env_not_set = ["CFG_RELEASE"] } } -env.CFG_RELEASE_CHANNEL = { value = "${CARGO_MAKE_RUST_CHANNEL}", condition = { env_not_set = ["CFG_RELEASE_CHANNEL"] } } +env.CFG_RELEASE = { value = "${CARGO_MAKE_RUST_VERSION}", condition = { env_not_set = [ + "CFG_RELEASE", +] } } +env.CFG_RELEASE_CHANNEL = { value = "${CARGO_MAKE_RUST_CHANNEL}", condition = { env_not_set = [ + "CFG_RELEASE_CHANNEL", +] } } install_crate = { crate_name = "rustfmt-nightly", rustup_component_name = "rustfmt", binary = "rustfmt", test_arg = "--help" } [tasks.pre-format] @@ -229,7 +237,13 @@ dependencies = ["pre-check-format", "check-format", "post-check-format"] [tasks.check-format-ci-flow] description = "Runs cargo fmt --check if conditions are met." category = "Test" -condition = { env_set = ["CARGO_MAKE_RUN_CHECK_FORMAT"], channels = ["nightly"], platforms = ["linux"] } +condition = { env_set = [ + "CARGO_MAKE_RUN_CHECK_FORMAT", +], channels = [ + "nightly", +], platforms = [ + "linux", +] } run_task = "check-format-flow" [tasks.format-flow] @@ -349,7 +363,11 @@ run_task = "readme-include-files-conditioned" description = "Modifies the current README.md by including external files." category = "Documentation" private = true -condition = { env_true = ["CARGO_MAKE_DOCS_README_INCLUDE_FILES"], files_exist = ["${CARGO_MAKE_DOCS_README_FILE}"] } +condition = { env_true = [ + "CARGO_MAKE_DOCS_README_INCLUDE_FILES", +], files_exist = [ + "${CARGO_MAKE_DOCS_README_FILE}", +] } dependencies = ["readme-file-set-env"] install_crate = { crate_name = "md-inc", binary = "md-inc", test_arg = "--help" } env = { CARGO_MAKE_DOCS_INCLUDE_FILES_MARKDOWN_FILE = "${CARGO_MAKE_DOCS_README_FILE}" } @@ -440,7 +458,9 @@ run_task = [ "test-single-threaded", "test-custom", "test-multi-phases-cleanup", - ], condition = { env_true = ["CARGO_MAKE_TEST_USE_MULTI_TEST_PHASES"] } }, + ], condition = { env_true = [ + "CARGO_MAKE_TEST_USE_MULTI_TEST_PHASES", + ] } }, { name = "test" }, ] @@ -600,7 +620,13 @@ dependencies = ["pre-outdated", "outdated", "post-outdated"] [tasks.outdated-ci-flow] description = "Runs outdated cargo conditioned CI flow." category = "CI" -condition = { env_set = ["CARGO_MAKE_CHECK_OUTDATED"], env_true = ["CARGO_MAKE_CRATE_HAS_DEPENDENCIES"], env_false = ["CARGO_MAKE_PR"], env = { "CARGO_MAKE_CI_BRANCH_NAME" = "master" }, channels = [ +condition = { env_set = [ + "CARGO_MAKE_CHECK_OUTDATED", +], env_true = [ + "CARGO_MAKE_CRATE_HAS_DEPENDENCIES", +], env_false = [ + "CARGO_MAKE_PR", +], env = { "CARGO_MAKE_CI_BRANCH_NAME" = "master" }, channels = [ "nightly", ], platforms = [ "linux", @@ -623,7 +649,11 @@ category = "CI" [tasks.unused-dependencies] description = "Checks for unused dependencies." category = "CI" -condition = { channels = ["nightly"], env_true = ["CARGO_MAKE_CRATE_HAS_DEPENDENCIES"] } +condition = { channels = [ + "nightly", +], env_true = [ + "CARGO_MAKE_CRATE_HAS_DEPENDENCIES", +] } command = "cargo" args = ["udeps"] @@ -675,7 +705,9 @@ ignore_errors = true description = "Selects clippy task based on current environment." category = "Test" run_task = [ - { name = "clippy-allow-fail", condition = { env_true = ["CARGO_MAKE_CLIPPY_ALLOW_FAIL"] } }, + { name = "clippy-allow-fail", condition = { env_true = [ + "CARGO_MAKE_CLIPPY_ALLOW_FAIL", + ] } }, { name = "clippy" }, ] @@ -687,7 +719,13 @@ dependencies = ["pre-clippy", "clippy-router", "post-clippy"] [tasks.clippy-ci-flow] description = "Runs clippy code linter if conditions are met." category = "CI" -condition = { env_set = ["CARGO_MAKE_RUN_CLIPPY"], channels = ["nightly"], platforms = ["linux"] } +condition = { env_set = [ + "CARGO_MAKE_RUN_CLIPPY", +], channels = [ + "nightly", +], platforms = [ + "linux", +] } run_task = "clippy-flow" [tasks.copy-apidocs] @@ -695,7 +733,9 @@ description = "Copies the generated documentation to the docs/api directory." category = "Documentation" workspace = false run_task = [ - { name = "workspace-copy-apidocs", condition = { env_set = ["CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER"] } }, + { name = "workspace-copy-apidocs", condition = { env_set = [ + "CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER", + ] } }, { name = "crate-copy-apidocs" }, ] @@ -830,10 +870,16 @@ category = "Publish" description = "Runs full sanity, generates github release and publishes the crate." category = "Publish" workspace = false -condition = { env_set = ["COMMIT_MSG", "GITHUB_API_TOKEN", "GITHUB_REPO_NAME"], env = { "CARGO_MAKE_GIT_BRANCH" = "master" } } +condition = { env_set = [ + "COMMIT_MSG", + "GITHUB_API_TOKEN", + "GITHUB_REPO_NAME", +], env = { "CARGO_MAKE_GIT_BRANCH" = "master" } } env = { "CARGO_MAKE_SKIP_PREPUBLISH_CLEAN" = true, "CARGO_MAKE_GIT_PUSH_ARGS" = "--no-verify" } run_task = [ - { name = "workspace-build-publish-flow", condition = { env_true = ["CARGO_MAKE_CRATE_IS_WORKSPACE"] } }, + { name = "workspace-build-publish-flow", condition = { env_true = [ + "CARGO_MAKE_CRATE_IS_WORKSPACE", + ] } }, { name = "crate-build-publish-flow" }, ] @@ -902,7 +948,11 @@ install_crate = { rustup_component_name = "rls-preview", binary = "rls", test_ar [tasks.zip-release-ci-flow] description = "Compiles the binary in release mode and zips it up" category = "CI" -condition = { env_set = ["CARGO_MAKE_RELEASE_FLOW_TARGET"], env_true = ["CARGO_MAKE_CI"] } +condition = { env_set = [ + "CARGO_MAKE_RELEASE_FLOW_TARGET", +], env_true = [ + "CARGO_MAKE_CI", +] } dependencies = [ "print-env-flow", "clean", @@ -964,7 +1014,9 @@ condition = { env_set = [ ], env_true = [ "CARGO_MAKE_CI", "CARGO_MAKE_BINARY_RELEASE_ENV_INSTALL_MUSL", -], platforms = ["linux"] } +], platforms = [ + "linux", +] } env.OPENSSL_DIR = "${HOME}/openssl-musl" env.OPENSSL_PLATFORM = { source = "${CARGO_MAKE_BINARY_RELEASE_ENV_ARM_LINUX}", default_value = "x86_64", mapping = { "true" = "armv4" } } script = ''' @@ -978,7 +1030,9 @@ make install [tasks.build-release-for-binary-upload] run_task = [ - { name = "cross-build-release-for-target", condition = { env_true = ["CARGO_MAKE_BINARY_RELEASE_ENV_USE_CROSS"] } }, + { name = "cross-build-release-for-target", condition = { env_true = [ + "CARGO_MAKE_BINARY_RELEASE_ENV_USE_CROSS", + ] } }, { name = "build-release-for-target" }, ] @@ -986,7 +1040,11 @@ run_task = [ description = "Makes a release build for a given target" category = "Build" private = true -condition = { env_set = ["CARGO_MAKE_RELEASE_FLOW_TARGET"], env_true = ["CARGO_MAKE_CI"] } +condition = { env_set = [ + "CARGO_MAKE_RELEASE_FLOW_TARGET", +], env_true = [ + "CARGO_MAKE_CI", +] } args = [ "build", "--release", @@ -997,7 +1055,9 @@ args = [ [tasks.cross-build-release-for-target] extend = "build-release-for-target-base" -install_crate = { crate_name = "cross", binary = "cross", test_arg = ["--help"] } +install_crate = { crate_name = "cross", binary = "cross", test_arg = [ + "--help", +] } command = "cross" [tasks.build-release-for-target] @@ -1013,7 +1073,9 @@ condition = { env_set = [ "CARGO_MAKE_PROJECT_NAME", "CARGO_MAKE_PROJECT_VERSION", "CARGO_MAKE_BINARY_EXECUTABLE_NAME", -], env_true = ["CARGO_MAKE_CI"] } +], env_true = [ + "CARGO_MAKE_CI", +] } env.OUTPUT_NAME = "${CARGO_MAKE_PROJECT_NAME}-v${CARGO_MAKE_PROJECT_VERSION}-${CARGO_MAKE_RELEASE_FLOW_TARGET}" env.TARGET_RELEASE_DIRECTORY = "target/${CARGO_MAKE_RELEASE_FLOW_TARGET}/release" script_runner = "@shell" diff --git a/src/lib/descriptor/makefiles/toml.toml b/src/lib/descriptor/makefiles/toml.toml index c3d1f4b6..b61f47e7 100644 --- a/src/lib/descriptor/makefiles/toml.toml +++ b/src/lib/descriptor/makefiles/toml.toml @@ -6,7 +6,9 @@ category = "Development" description = "Formats all toml files defined in the CARGO_MAKE_FORMAT_TOML_FILES environment variable." category = "Development" condition = { env_set = ["CARGO_MAKE_FORMAT_TOML_FILES"] } -install_crate = { crate_name = "taplo-cli", binary = "taplo", test_arg = ["--help"] } +install_crate = { crate_name = "taplo-cli", binary = "taplo", test_arg = [ + "--help", +] } command = "taplo" args = ["format", "${CARGO_MAKE_FORMAT_TOML_FILES}"] diff --git a/src/lib/test/makefiles/env.toml b/src/lib/test/makefiles/env.toml index 65ecb277..d55eb820 100755 --- a/src/lib/test/makefiles/env.toml +++ b/src/lib/test/makefiles/env.toml @@ -1,6 +1,8 @@ [env] -IF_UNDEFINED = { value = "defined_in_makefile", condition = { env_not_set = ["IF_UNDEFINED"] } } +IF_UNDEFINED = { value = "defined_in_makefile", condition = { env_not_set = [ + "IF_UNDEFINED", +] } } COMPOSITE_OF_MAPPED = "VALUE: ${IF_UNDEFINED}" [tasks.if-undefined-print] diff --git a/src/lib/test/test_files/.crates.toml b/src/lib/test/test_files/.crates.toml index dfcc71d8..8ced1d25 100644 --- a/src/lib/test/test_files/.crates.toml +++ b/src/lib/test/test_files/.crates.toml @@ -1,7 +1,11 @@ [v1] -"test1 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = ["test1"] +"test1 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = [ + "test1", +] "cargo-make 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = [ "cargo-make", "makers", ] -"test2 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = ["test2"] +"test2 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = [ + "test2", +]