This commit is contained in:
2019-09-23 00:25:26 -04:00
parent cb554f2cfa
commit 3b250d0343
4 changed files with 46 additions and 41 deletions
+19 -24
View File
@@ -2,39 +2,34 @@
REGISTRY=${REGISTRY:-docker.pkg.github.com}
USERNAME=${USERNAME:-kennethreitz}
install: install/system install/python
test: python/test docker/test
release: test release/pypi release/docker
//: //system //python
//system:
lazy_brew pipenv
//python: @skip:key=Pipfile.lock //system
pipenv install --dev
python/test: install/python
unset BAKE_SILENT
pipenv run pytest
docker/bash: docker/build
docker-compose run --entrypoint bash bake
docker/test: docker/build
test: docker/build
docker-compose run --entrypoint bash bake -c 'set -ex && pip3 install pytest && pytest'
release: test release//pypi release//docker
docker/build:
# Build the images.
set -ex && docker-compose build
docker/build/full:
docker/bash: @interactive docker/build
docker-compose run --entrypoint bash bake
docker//build/full:
# Build the images.
set -ex && docker-compose build --no-cache
install/python: @skip:key=Pipfile.lock install/system
pipenv install --dev
install/system:
lazy_brew pipenv
release/pypi: install/python
release//pypi: //python
pipenv run python setup.py upload
release/docker: docker/build/full release/docker/github
release//docker: docker//build/full release//docker/github
release/docker/github: docker/build/full
release//docker/github: docker//build/full
set -ux
declare -a IMAGES=('bake:core' 'bake:latest')
@@ -49,13 +44,13 @@ release/docker/github: docker/build/full
docker push "$REMOTE_IMAGE"
done
release/docker/dockerhub: docker/build/full
release/docker/dockerhub: docker//build/full
docker-compose push
ci: ci/setup
//ci: //ci/setup
set -ex && mkdir -p reports/pytest && pytest --junitxml=reports/pytest/report.xml
ci/setup: @skip:key=Pipfile.lock
//ci/setup: @skip:key=Pipfile.lock
pipenv install --dev --deploy --system
random/python/ip:
@@ -64,7 +59,7 @@ random/python/ip:
r = requests.get('https://httpbin.org/ip')
print(r.json()['origin'].split(',')[0])
random/clis:
random/cli:
bake:red 'Testing subcommands.'
bake:step 'sub-task'
echo 'I should *not* be red.' | bake:red | bake:indent | bake:notred
+11 -11
View File
@@ -17,15 +17,18 @@ from .exceptions import FilterNotAvailable, NoBakefileFound, TaskNotInBashfile
class Bakefile:
def __init__(self, *, path):
def __init__(self, *, path, debug=False):
self.path = path
self.environ = os.environ
self._chunks = []
self.args = []
self.debug = debug
if not os.path.exists(path):
raise NoBakefileFound()
self.cache = Cache(bf=self, debug=self.debug)
# Set environment variables for 'bake's that run underneath of us.
os.environ["BAKE_SKIP_DONE"] = "1"
os.environ["BAKE_SILENT"] = "1"
@@ -36,10 +39,6 @@ class Bakefile:
self._tasks = None
self._graph = None
@property
def cache(self):
return Cache(bf=self)
@property
def graph(self):
if self._graph:
@@ -236,6 +235,7 @@ class Bakefile:
class BaseAction:
do_skip = None
do_interactive = None
@property
def is_filter(self):
@@ -251,6 +251,7 @@ class TaskFilter(BaseAction):
self.bf = bf
self.__uuid = uuid4().hex
self.do_skip = None
self.do_interactive = None
def __str__(self):
"""Used for terminal display."""
@@ -332,7 +333,7 @@ class TaskFilter(BaseAction):
question = str(click.style("?", fg="green", bold=True))
click.confirm(f" {question} Do you want to continue?", abort=True)
return ("confirmed", True)
# return ("confirmed", True)
def execute_skip_if(self, *, key, **kwargs):
"""Determines if it is appropriate to skip the dependent TaskScript."""
@@ -341,7 +342,6 @@ class TaskFilter(BaseAction):
key_path = os.path.abspath(key)
if not os.path.exists(key_path):
self.do_skip = False
# return ("skip", False)
return
key = sha256(key.encode("utf-8")).hexdigest()
@@ -355,11 +355,9 @@ class TaskFilter(BaseAction):
if old_hash == current_hash:
self.do_skip = True
# return ("skip", True)
return
self.do_skip = False
# return ("skip", False)
return
def execute(self, yes=False, **kwargs):
@@ -368,9 +366,11 @@ class TaskFilter(BaseAction):
…but I was too tired to approach that problem. I continue to be.
"""
if self.name == "confirm":
return self.execute_confirm(yes=yes, **self.arguments)
self.execute_confirm(yes=yes, **self.arguments)
elif self.name == "skip":
return self.execute_skip_if(yes=yes, **self.arguments)
self.execute_skip_if(yes=yes, **self.arguments)
elif self.name == "interactive":
self.do_interactive = True
class FakeTaskScript(BaseAction):
+2 -2
View File
@@ -4,7 +4,7 @@ import delegator
PREFIX = "bake"
SEPERATOR = "."
__all__ = ['Cache']
__all__ = ["Cache"]
class Cache:
@@ -75,7 +75,7 @@ class Cache:
if self.debug:
click.echo(f" {click.style('$', fg='green')} {cmd}", err=True)
c = delegator.run()
c = delegator.run(cmd)
if c.ok:
return c.out.strip()
else:
+14 -4
View File
@@ -351,9 +351,15 @@ def entrypoint(
edges = list()
skips = []
interactives = []
for edge in edges:
if edge.do_skip is not None:
skips.append(edge.do_skip)
if edge.do_interactive is not None:
interactives.append(edge.do_interactive)
force_interactive = bool(len(interactives))
if not all(skips or [False]):
# TODO: fully implement this?
@@ -368,7 +374,10 @@ def entrypoint(
err=True,
)
usually_bash_task = task.execute(
yes=yes, debug=debug, silent=silent, interactive=interactive
yes=yes,
debug=debug,
silent=silent,
interactive=force_interactive or interactive,
)
if not _continue:
@@ -384,9 +393,10 @@ def entrypoint(
# This happens when it's a task filter.
elif isinstance(usually_bash_task, tuple):
key, value = (
usually_bash_task
) # But, in this instance, clearly isn't.
# key, value = (
# usually_bash_task
# ) # But, in this instance, clearly isn't.
pass
else:
click.echo(
click.style(" + ", fg="green")