This commit is contained in:
2019-09-15 19:51:50 -04:00
parent 861856a090
commit 1ecf5bda2e
13 changed files with 177 additions and 40 deletions
+1
View File
@@ -1,3 +1,4 @@
.vscode/settings.json
bake.egg-info/*
**/__pycache__/**
.DS_Store
+9 -23
View File
@@ -1,27 +1,13 @@
echo:
cat Bakefile
format:
black .
full-install: system-deps install
install: node-deps python-deps
env:
env
argv-example:
set -eux
echo "HELLO, $WHO"
echo $@
dangerous-example: @confirm:secure
rm -fr *
full-install: system-install python-deps
python-deps:
# Example of comments
pipenv install
node-deps:
yarn install
system-deps:
brew install pipenv
python-dev-deps:
pipenv install --dev
system-install: @confirm
brew install python pipenv
pypi-upload: python-dev-deps
pipenv run setup.py upload
+1
View File
@@ -5,6 +5,7 @@ verify_ssl = true
[dev-packages]
black = "*"
pytest = "*"
[packages]
bashf = {editable = true,path = "."}
Generated
+84 -5
View File
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "586d266e0093a64d666ab313fd620746db0d04d1dc6da5a184ffc6e3bf2ee04c"
"sha256": "8a1f7d6811e7584a6353ef345102bb126bc56e315a14b5bb0ce6d52ad7d8281b"
},
"pipfile-spec": 6,
"requires": {
@@ -16,12 +16,12 @@
]
},
"default": {
"bash.py": {
"appdirs": {
"hashes": [
"sha256:108279834ec18c6597806393c3779076b07013c1cdbc3ffd9197dc04985ac8ba",
"sha256:be5a86449866642adea843c08b0075990f36294ad42681eb41e9924307e3b4af"
"sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92",
"sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e"
],
"version": "==0.4.2"
"version": "==1.4.3"
},
"bashf": {
"editable": true,
@@ -78,6 +78,13 @@
],
"version": "==1.4.3"
},
"atomicwrites": {
"hashes": [
"sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4",
"sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6"
],
"version": "==1.3.0"
},
"attrs": {
"hashes": [
"sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79",
@@ -100,12 +107,84 @@
],
"version": "==7.0"
},
"importlib-metadata": {
"hashes": [
"sha256:652234b6ab8f2506ae58e528b6fbcc668831d3cc758e1bc01ef438d328b68cdb",
"sha256:6f264986fb88042bc1f0535fa9a557e6a376cfe5679dc77caac7fe8b5d43d05f"
],
"markers": "python_version < '3.8'",
"version": "==0.22"
},
"more-itertools": {
"hashes": [
"sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832",
"sha256:92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"
],
"version": "==7.2.0"
},
"packaging": {
"hashes": [
"sha256:a7ac867b97fdc07ee80a8058fe4435ccd274ecc3b0ed61d852d7d53055528cf9",
"sha256:c491ca87294da7cc01902edbe30a5bc6c4c28172b5138ab4e4aa1b9d7bfaeafe"
],
"version": "==19.1"
},
"pluggy": {
"hashes": [
"sha256:0db4b7601aae1d35b4a033282da476845aa19185c1e6964b25cf324b5e4ec3e6",
"sha256:fa5fa1622fa6dd5c030e9cad086fa19ef6a0cf6d7a2d12318e10cb49d6d68f34"
],
"version": "==0.13.0"
},
"py": {
"hashes": [
"sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa",
"sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"
],
"version": "==1.8.0"
},
"pyparsing": {
"hashes": [
"sha256:6f98a7b9397e206d78cc01df10131398f1c8b8510a2f4d97d9abd82e1aacdd80",
"sha256:d9338df12903bbf5d65a0e4e87c2161968b10d2e489652bb47001d82a9b028b4"
],
"version": "==2.4.2"
},
"pytest": {
"hashes": [
"sha256:95d13143cc14174ca1a01ec68e84d76ba5d9d493ac02716fd9706c949a505210",
"sha256:b78fe2881323bd44fd9bd76e5317173d4316577e7b1cddebae9136a4495ec865"
],
"index": "pypi",
"version": "==5.1.2"
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.12.0"
},
"toml": {
"hashes": [
"sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c",
"sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"
],
"version": "==0.10.0"
},
"wcwidth": {
"hashes": [
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
],
"version": "==0.1.7"
},
"zipp": {
"hashes": [
"sha256:3718b1cbcd963c7d4c5511a8240812904164b7f381b647143a89d3b98f9bcd8e",
"sha256:f06903e9f1f43b12d371004b4ac7b06ab39a44adc747266928ae6debfa7b3335"
],
"version": "==0.6.0"
}
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ format:
black .
argv-example:
set -eux
set -euxe
echo "HELLO, $WHO"
echo $@
+1 -2
View File
@@ -154,8 +154,7 @@ class TaskScript:
script = shlex_quote(f"{tf} {args}")
else:
script = shlex_quote(f"{tf} {args} 2>&1 | bake-indent")
cmd = f"bash --init-file {shlex_quote(stdlib_path)} -i -c {script} "
cmd = f"bash --init-file {shlex_quote(stdlib_path)} -i -c {script}"
if debug:
print(cmd)
+11 -9
View File
@@ -5,7 +5,7 @@ import crayons
from .bakefile import Bakefile
from .config import config
SAFE_ENVIRONS = ["HOME"]
SAFE_ENVIRONS = ["HOME", "PATH"]
def indent(line):
@@ -26,7 +26,8 @@ def indent(line):
default="__BAKEFILE__",
envvar="BAKEFILE_PATH",
nargs=1,
type=click.Path(),
# TODO: click.Path()?
type=click.STRING,
)
@click.option(
"--list",
@@ -48,8 +49,9 @@ def indent(line):
)
@click.option("--yes", is_flag=True, help="Set mediumsecurity prompts to yes.")
@click.option(
"--fail",
"-x",
"--continue",
"-c",
"_continue",
is_flag=True,
type=click.BOOL,
help="Fail immediately, if any task fails.",
@@ -82,7 +84,7 @@ def task(
bakefile,
arguments,
_list,
fail,
_continue,
environ_json,
shellcheck,
debug,
@@ -105,9 +107,9 @@ def task(
task = None
if bakefile == "__BAKEFILE__":
bakefile = "Bakefile"
bakefile = Bakefile.find(root=".", filename=bakefile)
bakefile = Bakefile.find(root=".", filename="Bakefile")
else:
bakefile = Bakefile(path=bakefile)
if not insecure:
for key in bakefile.environ:
@@ -166,7 +168,7 @@ def task(
)
return_code = task.execute(yes=yes, next_task=next_task, silent=silent)
if fail:
if not _continue:
if not return_code == 0:
click.echo(f"Task {task} failed!")
sys.exit(return_code)
+30
View File
@@ -0,0 +1,30 @@
import os
import pytest
import delegator
import bake.cli as bake_cli
@pytest.fixture
def bake():
def run(*args, fixture="default", assert_ok=True, block=True):
bakefile = os.path.join(
os.path.dirname(__file__), "fixtures", f"{fixture}.Bakefile"
)
cmd = " ".join(["bake", "-b", bakefile] + list(args))
print(f"$ {cmd}")
c = delegator.run(cmd, block=block)
if block and assert_ok:
assert c.return_code == 0
if block:
print(c.out)
print(c.err)
return c
return run
+14
View File
@@ -0,0 +1,14 @@
test1: test2 test3
source ./
test2: test3
echo '2'
test3:
echo '3'
echo:
echo 'hi, kenneth!'
needs-echo: echo
needs-needs: needs-echo
+2
View File
@@ -0,0 +1,2 @@
kinda-dangerous: @confirm
really-dangerous: @confirm:secure
+13
View File
@@ -0,0 +1,13 @@
def test_echo(bake):
c = bake("echo", fixture="1")
assert "kenneth" in c.out
def test_first_level_dep(bake):
c = bake("needs-echo", fixture="1")
assert "kenneth" in c.out
def test_second_level_dep(bake):
c = bake("needs-needs", fixture="1")
assert "kenneth" in c.out
View File
+10
View File
@@ -0,0 +1,10 @@
def test_confirm(bake):
c = bake("kinda-dangerous", fixture="2", block=False)
# c.expect("?", "Y")
# c.block()
assert "kenneth" in c.out
def test_confirm_secure(bake):
c = bake("kinda-dangerous", fixture="2", block=False)
c.expect