Skip to content

Commit

Permalink
internal tasks refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiegurari committed Jul 21, 2017
1 parent 5e29478 commit 2d6c2e3
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 84 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.3.34"
version = "0.3.35"
authors = ["Sagie Gur-Ari <sagiegurari@gmail.com>"]
description = "Rust task runner and build tool."
license = "Apache-2.0"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ See [contributing guide](.github/CONTRIBUTING.md)

| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2017-07-21 | v0.3.35 | Maintenance |
| 2017-07-21 | v0.3.34 | Added coverage-tarpaulin task |
| 2017-07-21 | v0.3.33 | Added more environment variables for workspace support |
| 2017-07-20 | v0.3.32 | Added --list-all-steps cli option |
Expand Down
1 change: 1 addition & 0 deletions docs/_includes/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ See [contributing guide](https://github.com/sagiegurari/cargo-make/blob/master/.

| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2017-07-21 | v0.3.35 | Maintenance |
| 2017-07-21 | v0.3.34 | Added coverage-tarpaulin task |
| 2017-07-21 | v0.3.33 | Added more environment variables for workspace support |
| 2017-07-20 | v0.3.32 | Added --list-all-steps cli option |
Expand Down
49 changes: 28 additions & 21 deletions docs/api/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,21 +1233,24 @@
onEach(e.getElementsByClassName('associatedconstant'), func);
});

var span = document.createElement('span');
span.className = 'toggle-label';
span.style.display = 'none';
span.innerHTML = '&nbsp;Expand&nbsp;description';

var mainToggle = toggle.cloneNode(true);
mainToggle.appendChild(span);

var wrapper = document.createElement('div');
wrapper.className = 'toggle-wrapper';
wrapper.appendChild(mainToggle);
function createToggle() {
var span = document.createElement('span');
span.className = 'toggle-label';
span.style.display = 'none';
span.innerHTML = '&nbsp;Expand&nbsp;description';

var mainToggle = toggle.cloneNode(true);
mainToggle.appendChild(span);

var wrapper = document.createElement('div');
wrapper.className = 'toggle-wrapper';
wrapper.appendChild(mainToggle);
return wrapper;
}

onEach(document.getElementById('main').getElementsByClassName('docblock'), function(e) {
if (e.parentNode.id === "main") {
e.parentNode.insertBefore(wrapper, e);
e.parentNode.insertBefore(createToggle(), e);
}
});

Expand All @@ -1273,18 +1276,22 @@
}
})

var span = document.createElement('span');
span.className = 'toggle-label';
span.style.display = 'none';
span.innerHTML = '&nbsp;Expand&nbsp;attributes';
toggle.appendChild(span);
function createToggleWrapper() {
var span = document.createElement('span');
span.className = 'toggle-label';
span.style.display = 'none';
span.innerHTML = '&nbsp;Expand&nbsp;attributes';
toggle.appendChild(span);

var wrapper = document.createElement('div');
wrapper.className = 'toggle-wrapper toggle-attributes';
wrapper.appendChild(toggle);
return wrapper;
}

var wrapper = document.createElement('div');
wrapper.className = 'toggle-wrapper toggle-attributes';
wrapper.appendChild(toggle);
onEach(document.getElementById('main').getElementsByTagName('pre'), function(e) {
onEach(e.getElementsByClassName('attributes'), function(i_e) {
i_e.parentNode.insertBefore(wrapper, i_e);
i_e.parentNode.insertBefore(createToggleWrapper(), i_e);
collapseDocs(i_e.previousSibling.childNodes[0]);
});
});
Expand Down
5 changes: 5 additions & 0 deletions docs/api/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,11 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
padding-left: 10px;
}

.item-spacer {
width: 100%;
height: 12px;
}

span.since {
position: initial;
font-size: 20px;
Expand Down
2 changes: 1 addition & 1 deletion docs/api/src/cargo_make/command.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
};

<span class="kw">if</span> <span class="op">!</span><span class="macro">cfg</span><span class="macro">!</span>(<span class="ident">windows</span>) {
<span class="ident">mut_script_lines</span>.<span class="ident">insert</span>(<span class="ident">insert_index</span>, <span class="string">&quot;set -e&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">mut_script_lines</span>.<span class="ident">insert</span>(<span class="ident">insert_index</span>, <span class="string">&quot;set -xe&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">insert_index</span> <span class="op">=</span> <span class="ident">insert_index</span> <span class="op">+</span> <span class="number">1</span>;
}
<span class="ident">mut_script_lines</span>.<span class="ident">insert</span>(<span class="ident">insert_index</span>, <span class="ident">cd_command</span>);
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn create_script(
};

if !cfg!(windows) {
mut_script_lines.insert(insert_index, "set -e".to_string());
mut_script_lines.insert(insert_index, "set -xe".to_string());
insert_index = insert_index + 1;
}
mut_script_lines.insert(insert_index, cd_command);
Expand Down
4 changes: 2 additions & 2 deletions src/command_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn create_script_no_shebang() {
let cwd = current_dir().unwrap();
let mut expected_script = "".to_string();
if !cfg!(windows) {
expected_script.push_str("set -e\n");
expected_script.push_str("set -xe\n");
}
expected_script.push_str("cd ");
expected_script.push_str(cwd.to_str().unwrap());
Expand All @@ -31,7 +31,7 @@ fn create_script_with_shebang() {
let cwd = current_dir().unwrap();
let mut expected_script = "#!/bin/bash\n".to_string();
if !cfg!(windows) {
expected_script.push_str("set -e\n");
expected_script.push_str("set -xe\n");
}
expected_script.push_str("cd ");
expected_script.push_str(cwd.to_str().unwrap());
Expand Down
156 changes: 98 additions & 58 deletions src/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,21 @@ args = ["push"]

[tasks.workspace-members-ci]
script = [
"export CARGO_MAKE_SKIP_CODECOV=\"true\"", #prevent codecov publish in member builds
"export CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY=\"${CARGO_MAKE_WORKING_DIRECTORY}/target\"",
"export CARGO_MAKE_COVERAGE_REPORT_DIRECTORY=\"${CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY}/coverage\"", #output coverage data goes into workspace level
"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"
'''
#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]
Expand All @@ -308,54 +316,84 @@ alias = "coverage-kcov"
description = "Installs (if missing) and runs coverage using kcov (not supported on windows)"
windows_alias = "empty"
install_script = [
"command -v kcov >/dev/null 2>&1 || {",
"if [ -n \"$KCOV_VERSION\" ]; then",
"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",
"fi",
"}"
'''
command -v kcov >/dev/null 2>&1 || {
if [ -n "$KCOV_VERSION" ]; then
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
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"
'''
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-lcov]
description = "WARNING, ONLY INSTALLS LCOV. ACTUAL COVERAGE IS CURRENTLY NOT IMPLEMENTED!!!"
windows_alias = "empty"
install_script = [
'''
command -v lcov >/dev/null 2>&1 || {
git clone https://github.com/linux-test-project/lcov.git
cd lcov
sudo make install
cd ..
rm -Rf ./lcov
}
'''
]
script = [
'''
echo "Not Implemented."
exit 1
'''
]

[tasks.coverage-tarpaulin]
Expand Down Expand Up @@ -397,9 +435,11 @@ dependencies = [
[tasks.ci-coverage-flow]
windows_alias = "empty"
script = [
"if [ \"$TRAVIS\" = \"true\" ]; then",
"if [ \"$CARGO_MAKE_RUN_CODECOV\" = \"true\" ]; then",
"cargo make --loglevel=${CARGO_MAKE_LOG_LEVEL} codecov-flow",
"fi",
"fi"
'''
if [ "$TRAVIS" = "true" ]; then
if [ "$CARGO_MAKE_RUN_CODECOV" = "true" ]; then
cargo make --loglevel=${CARGO_MAKE_LOG_LEVEL} codecov-flow
fi
fi
'''
]

0 comments on commit 2d6c2e3

Please sign in to comment.