Skip to content

Commit

Permalink
renamed dependencies attribute and added coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiegurari committed Jun 24, 2017
1 parent 331cfbf commit f66518e
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 55 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-make"
version = "0.1.2"
version = "0.2.0"
authors = ["Sagie Gur-Ari <[email protected]>"]
description = "Rust task runner and build tool."
license = "Apache-2.0"
Expand Down
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* [Installation](#installation)
* [Usage](#usage)
* [Simple Example](#usage-simple)
* [Tasks, Depedencies and Aliases](#usage-task-depedencies-alias)
* [Tasks, Dependencies and Aliases](#usage-task-dependencies-alias)
* [Default Tasks and Extending](#usage-default-tasks)
* [Continues Integration](#usage-ci)
* [Environment Variables](#usage-env)
Expand All @@ -25,7 +25,7 @@
## Overview
The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.<br>
A task is a command or a script to execute.<br>
Tasks can have depedencies which are also tasks that will be executed before the task itself.<br>
Tasks can have dependencies which are also tasks that will be executed before the task itself.<br>
With a simple toml based configuration file, you can define a multi platform build script that can run build, test, documentation generation, bench tests execution, security validations and more by running a single command.

<a name="installation"></a>
Expand Down Expand Up @@ -68,15 +68,15 @@ args = ["clean"]
[tasks.build]
command = "cargo"
args = ["build"]
depedencies = ["clean"]
dependencies = ["clean"]

[tasks.test]
command = "cargo"
args = ["test"]
depedencies = ["clean"]
dependencies = ["clean"]

[tasks.my-flow]
depedencies = [
dependencies = [
"format",
"build",
"test"
Expand Down Expand Up @@ -149,8 +149,8 @@ test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

We now created a build script that can run on any platform.

<a name="usage-task-depedencies-alias"></a>
### Tasks, Depedencies and Aliases
<a name="usage-task-dependencies-alias"></a>
### Tasks, Dependencies and Aliases
In many cases, certain tasks depend on other tasks.<br>
For example you would like to format the code before running build and run the build before running tests.<br>
Such flow can be defined as follows:
Expand All @@ -164,12 +164,12 @@ args = ["fmt", "--", "--write-mode=overwrite"]
[tasks.build]
command = "cargo"
args = ["build"]
depedencies = ["format"]
dependencies = ["format"]

[tasks.test]
command = "cargo"
args = ["test"]
depedencies = ["build"]
dependencies = ["build"]
````

When you run:
Expand All @@ -178,29 +178,29 @@ When you run:
cargo make -b ./my_build.toml -t test
````

It will try to run test, see that it has depedencies and those have other depedencies.<br>
Therefore it will create an execution plan for the tasks based on the tasks and their depedencies.<br>
It will try to run test, see that it has dependencies and those have other dependencies.<br>
Therefore it will create an execution plan for the tasks based on the tasks and their dependencies.<br>
In our case it will invoke format -> build -> test.<br>

The same task will never be executed twice so if we have for example:

````toml
[tasks.A]
depedencies = ["B", "C"]
dependencies = ["B", "C"]

[tasks.B]
depedencies = ["D"]
dependencies = ["D"]

[tasks.C]
depedencies = ["D"]
dependencies = ["D"]

[tasks.D]
script = [
"echo hello"
]
````

In this example, A depdends on B and C, and both B and C are depedended on D.<br>
In this example, A depends on B and C, and both B and C are dependended on D.<br>
Task D however will not be invoked twice.<br>
The output of the execution will look something like this:

Expand All @@ -225,13 +225,13 @@ So now, if we want to have D execute twice we can do the following:

````toml
[tasks.A]
depedencies = ["B", "C"]
dependencies = ["B", "C"]

[tasks.B]
depedencies = ["D"]
dependencies = ["D"]

[tasks.C]
depedencies = ["D2"]
dependencies = ["D2"]

[tasks.D]
script = [
Expand Down Expand Up @@ -339,7 +339,7 @@ OPTIONS:

<a name="roadmap"></a>
## Roadmap
The cargo-make task runner is still in initial development and there are many things planned for the comming release.<br>
The cargo-make task runner is still in initial development and there are many things planned for the coming release.<br>
Here are a few of the top priorities:

* Support platform specific task overrides
Expand All @@ -358,6 +358,7 @@ See [contributing guide](.github/CONTRIBUTING.md)

| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2017-06-24 | v0.2.0 | Internal fixes (renamed dependencies attribute) |
| 2017-06-24 | v0.1.2 | Print build time, added internal docs, unit tests and coverage |
| 2017-06-24 | v0.1.1 | Added support for env vars, task alias and crate installation |
| 2017-06-23 | v0.1.0 | Initial release. |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/cargo_make/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h1 id='cargo-make' class='section-header'><a href='#cargo-make'>cargo-make</a><
<p>Rust task runner and build tool.<br>
The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.<br>
A task is a command or a script to execute.<br>
Tasks can have depedencies which are also tasks that will be executed before the task itself.<br>
Tasks can have dependencies which are also tasks that will be executed before the task itself.<br>
With a simple toml based configuration file, you can define a multi platform build script that can run build, test,
documentation generation, bench tests execution, security validations and more by running a single command.</p>

Expand Down
4 changes: 2 additions & 2 deletions docs/api/src/cargo_make/installer.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
</pre><pre class="rust ">
<span class="doccomment">//! # installer</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! Installs external depedencies for tasks.&lt;br&gt;</span>
<span class="doccomment">//! There are 2 types of depedencies: install_crate, install_script.&lt;br&gt;</span>
<span class="doccomment">//! Installs external dependencies for tasks.&lt;br&gt;</span>
<span class="doccomment">//! There are 2 types of dependencies: install_crate, install_script.&lt;br&gt;</span>
<span class="doccomment">//! install_crate ensures the crate command is available and if not installs the crate based on the provided name.&lt;br&gt;</span>
<span class="doccomment">//! install_script always gets executed before the task command.</span>
<span class="doccomment">//!</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/src/cargo_make/main.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
<span class="doccomment">//! Rust task runner and build tool.&lt;br&gt;</span>
<span class="doccomment">//! The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.&lt;br&gt;</span>
<span class="doccomment">//! A task is a command or a script to execute.&lt;br&gt;</span>
<span class="doccomment">//! Tasks can have depedencies which are also tasks that will be executed before the task itself.&lt;br&gt;</span>
<span class="doccomment">//! Tasks can have dependencies which are also tasks that will be executed before the task itself.&lt;br&gt;</span>
<span class="doccomment">//! With a simple toml based configuration file, you can define a multi platform build script that can run build, test,</span>
<span class="doccomment">//! documentation generation, bench tests execution, security validations and more by running a single command.</span>
<span class="doccomment">//!</span>
Expand Down
8 changes: 4 additions & 4 deletions docs/api/src/cargo_make/runner.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@

<span class="kw">match</span> <span class="ident">config</span>.<span class="ident">tasks</span>.<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="ident">actual_task</span>) {
<span class="prelude-val">Some</span>(<span class="ident">task_config</span>) <span class="op">=&gt;</span> {
<span class="kw">match</span> <span class="ident">task_config</span>.<span class="ident">depedencies</span> {
<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">depedencies</span>) <span class="op">=&gt;</span> {
<span class="kw">for</span> <span class="ident">depedency</span> <span class="kw">in</span> <span class="ident">depedencies</span> {
<span class="kw">match</span> <span class="ident">task_config</span>.<span class="ident">dependencies</span> {
<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">dependencies</span>) <span class="op">=&gt;</span> {
<span class="kw">for</span> <span class="ident">depedency</span> <span class="kw">in</span> <span class="ident">dependencies</span> {
<span class="ident">create_execution_plan_for_step</span>(<span class="kw-2">&amp;</span><span class="ident">logger</span>, <span class="kw-2">&amp;</span><span class="ident">config</span>, <span class="kw-2">&amp;</span><span class="ident">depedency</span>, <span class="ident">steps</span>, <span class="ident">task_names</span>, <span class="bool-val">false</span>);
}
}
_ <span class="op">=&gt;</span> <span class="ident">logger</span>.<span class="ident">verbose</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span>(<span class="string">&quot;No depedencies found for task: &quot;</span>, <span class="kw-2">&amp;</span>[<span class="kw-2">&amp;</span><span class="ident">task</span>], <span class="prelude-val">None</span>),
_ <span class="op">=&gt;</span> <span class="ident">logger</span>.<span class="ident">verbose</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span>(<span class="string">&quot;No dependencies found for task: &quot;</span>, <span class="kw-2">&amp;</span>[<span class="kw-2">&amp;</span><span class="ident">task</span>], <span class="prelude-val">None</span>),
};

<span class="kw">if</span> <span class="op">!</span><span class="ident">task_names</span>.<span class="ident">contains</span>(<span class="ident">task</span>) {
Expand Down
4 changes: 2 additions & 2 deletions docs/api/src/cargo_make/types.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">HashMap</span>;

<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Serialize</span>, <span class="ident">Deserialize</span>, <span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
<span class="doccomment">/// Holds a single task configuration such as command and depedencies list</span>
<span class="doccomment">/// Holds a single task configuration such as command and dependencies list</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Task</span> {
<span class="doccomment">/// if defined, task points to another task and all other properties are ignored</span>
<span class="kw">pub</span> <span class="ident">alias</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
Expand All @@ -126,7 +126,7 @@
<span class="doccomment">/// If command is not defined, and script is defined, the provided script will be executed</span>
<span class="kw">pub</span> <span class="ident">script</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;&gt;</span>,
<span class="doccomment">/// A list of tasks to execute before this task</span>
<span class="kw">pub</span> <span class="ident">depedencies</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;&gt;</span>
<span class="kw">pub</span> <span class="ident">dependencies</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;&gt;</span>
}

<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Serialize</span>, <span class="ident">Deserialize</span>, <span class="ident">Debug</span>)]</span>
Expand Down
6 changes: 3 additions & 3 deletions examples/alias.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

[tasks.A]
depedencies = ["B", "C"]
dependencies = ["B", "C"]

[tasks.B]
depedencies = ["D"]
dependencies = ["D"]

[tasks.C]
depedencies = ["D2"]
dependencies = ["D2"]

[tasks.D]
script = [
Expand Down
6 changes: 3 additions & 3 deletions examples/depedencies.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

[tasks.A]
depedencies = ["B", "C"]
dependencies = ["B", "C"]

[tasks.B]
depedencies = ["D"]
dependencies = ["D"]

[tasks.C]
depedencies = ["D"]
dependencies = ["D"]

[tasks.D]
script = [
Expand Down
2 changes: 1 addition & 1 deletion examples/script.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ script = [
]

[tasks.default]
depedencies = ["hello-world"]
dependencies = ["hello-world"]
6 changes: 3 additions & 3 deletions examples/simple-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ args = ["clean"]
[tasks.build]
command = "cargo"
args = ["build"]
depedencies = ["clean"]
dependencies = ["clean"]

[tasks.test]
command = "cargo"
args = ["test"]
depedencies = ["clean"]
dependencies = ["clean"]

[tasks.my-flow]
depedencies = [
dependencies = [
"format",
"build",
"test"
Expand Down
12 changes: 6 additions & 6 deletions src/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
RUST_BACKTRACE="1"

[tasks.default]
depedencies = [
dependencies = [
"dev-test-flow"
]

[tasks.ci-flow]
depedencies = [
dependencies = [
"pre-build",
"build-verbose",
"post-build",
Expand All @@ -18,7 +18,7 @@ depedencies = [
]

[tasks.dev-test-flow]
depedencies = [
dependencies = [
"format-flow",
"pre-build",
"build",
Expand All @@ -29,7 +29,7 @@ depedencies = [
]

[tasks.build-flow]
depedencies = [
dependencies = [
"init",
"pre-clean",
"clean-apidocs",
Expand Down Expand Up @@ -82,7 +82,7 @@ args = ["fmt", "--", "--write-mode=overwrite"]
[tasks.post-format]

[tasks.format-flow]
depedencies = [
dependencies = [
"pre-format",
"format",
"post-format"
Expand Down Expand Up @@ -129,7 +129,7 @@ args = ["bench"]
[tasks.post-bench]

[tasks.bench-flow]
depedencies = [
dependencies = [
"pre-bench",
"bench",
"post-bench"
Expand Down
4 changes: 2 additions & 2 deletions src/installer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! # installer
//!
//! Installs external depedencies for tasks.<br>
//! There are 2 types of depedencies: install_crate, install_script.<br>
//! Installs external dependencies for tasks.<br>
//! There are 2 types of dependencies: install_crate, install_script.<br>
//! install_crate ensures the crate command is available and if not installs the crate based on the provided name.<br>
//! install_script always gets executed before the task command.
//!
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
//! Rust task runner and build tool.<br>
//! The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.<br>
//! A task is a command or a script to execute.<br>
//! Tasks can have depedencies which are also tasks that will be executed before the task itself.<br>
//! Tasks can have dependencies which are also tasks that will be executed before the task itself.<br>
//! With a simple toml based configuration file, you can define a multi platform build script that can run build, test,
//! documentation generation, bench tests execution, security validations and more by running a single command.
//!
Expand Down
8 changes: 4 additions & 4 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ fn create_execution_plan_for_step(

match config.tasks.get(&actual_task) {
Some(task_config) => {
match task_config.depedencies {
Some(ref depedencies) => {
for depedency in depedencies {
match task_config.dependencies {
Some(ref dependencies) => {
for depedency in dependencies {
create_execution_plan_for_step(&logger, &config, &depedency, steps, task_names, false);
}
}
_ => logger.verbose::<()>("No depedencies found for task: ", &[&task], None),
_ => logger.verbose::<()>("No dependencies found for task: ", &[&task], None),
};

if !task_names.contains(task) {
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::collections::HashMap;

#[derive(Serialize, Deserialize, Debug, Clone)]
/// Holds a single task configuration such as command and depedencies list
/// Holds a single task configuration such as command and dependencies list
pub struct Task {
/// if defined, task points to another task and all other properties are ignored
pub alias: Option<String>,
Expand All @@ -21,7 +21,7 @@ pub struct Task {
/// If command is not defined, and script is defined, the provided script will be executed
pub script: Option<Vec<String>>,
/// A list of tasks to execute before this task
pub depedencies: Option<Vec<String>>
pub dependencies: Option<Vec<String>>
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down

0 comments on commit f66518e

Please sign in to comment.