6 Commits
Author SHA1 Message Date
jpic 0eef6241a7 Breaking it 2020-05-31 13:37:09 +02:00
jpic 879bb6f79e Silence pip output 2020-05-31 13:24:31 +02:00
jpic e733694f2d A bit of work on the command line 2020-05-31 13:22:36 +02:00
jpic 0ec287c977 Tag/build/push refactor 2020-05-31 12:53:57 +02:00
jpic 833cef7527 Typo in ci 2020-05-31 12:28:49 +02:00
jpic 28f555bcf3 Try more build 2020-05-31 12:23:48 +02:00
5 changed files with 49 additions and 40 deletions
+9 -4
View File
@@ -2,15 +2,20 @@ build:
cache:
key: cache
paths: [.cache]
image: quay.io/buildah/stable
image: yourlabs/buildah
script:
- dnf install -y curl python38
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- python3 get-pip.py
- pip3 install -U --user -e .[cli]
- CACHE_DIR=$(pwd)/.cache python3 ./shlaxfile.py build
stage: build
build-itself:
cache:
key: cache
paths: [.cache]
image: shlax:$CI_COMMIT_SHORT_SHA
script: python3 ./shlaxfile.py build
stage: test
test:
image: yourlabs/python
stage: build
+4 -1
View File
@@ -19,7 +19,10 @@ class Pip(Action):
raise Exception('Could not find pip nor python')
# ensure pip module presence
result = await target.exec(python, '-m', 'pip', raises=False)
result = await target.exec(
python, '-m', 'pip',
raises=False, quiet=True
)
if result.rc != 0:
if not os.path.exists('get-pip.py'):
req = request.urlopen(
+24 -9
View File
@@ -20,22 +20,37 @@ class Group(cli2.Group):
self.cmdclass = Command
class TargetArgument(cli2.Argument):
"""DSN of the target to execute on, localhost by default, TBI"""
def __init__(self, cmd, param, doc=None, color=None, default=None):
from shlax.targets.base import Target
super().__init__(cmd, param, doc=self.__doc__, default=Target())
self.alias = ['target', 't']
class Command(cli2.Command):
def call(self, *args, **kwargs):
return self.shlax_target(self.target)
def setargs(self):
cli2.arg('target', cls=TargetArgument)(self.target)
super().setargs()
# that works though, so I went for that
# self['target'] = TargetArgument(
# self,
# self.sig.parameters['target'],
# )
if 'actions' in self:
del self['actions']
def __call__(self, *argv):
from shlax.targets.base import Target
self.shlax_target = Target()
result = super().__call__(*argv)
self.shlax_target.output.results(self.shlax_target)
return result
super().__call__(*argv)
self['target'].value.output.results(self['target'].value)
class ActionCommand(Command):
class ActionCommand(cli2.Command):
def call(self, *args, **kwargs):
self.target = self.target(*args, **kwargs)
return super().call(*args, **kwargs)
from shlax.targets.base import Target
return super().call(Target())
class ConsoleScript(Group):
+3
View File
@@ -18,6 +18,9 @@ class Target:
self.parent = None
self.root = root or os.getcwd()
def __str__(self):
return 'localhost'
@property
def parent(self):
return self._parent or Target()
+9 -26
View File
@@ -63,22 +63,17 @@ class Buildah(Target):
if actions:
actions = actions[len(keep):]
if not actions:
return self.uptodate()
return self.output.success('Image up to date')
else:
self.actions = self.actions[len(keep):]
if not self.actions:
return self.uptodate()
return self.output.success('Image up to date')
self.ctr = (await self.parent.exec('buildah', 'from', self.base)).out
self.root = Path((await self.parent.exec('buildah', 'mount', self.ctr)).out)
return await super().__call__(*actions)
def uptodate(self):
self.clean = None
self.output.success('Image up to date')
return
async def layers(self):
ret = set()
results = await self.parent.exec(
@@ -144,19 +139,15 @@ class Buildah(Target):
return stop
async def clean(self, target, result):
for src, dst in self.mounts.items():
await self.parent.exec('umount', self.root / str(dst)[1:])
if self.root is not None:
await self.parent.exec('buildah', 'umount', self.ctr)
if self.ctr is not None:
if result.status == 'success':
await self.commit()
for src, dst in self.mounts.items():
await self.parent.exec('umount', self.root / str(dst)[1:])
await self.parent.exec('buildah', 'umount', self.ctr)
await self.parent.exec('buildah', 'rm', self.ctr)
if result.status == 'success' and os.getenv('BUILDAH_PUSH'):
if result.status == 'success':
await self.commit()
if os.getenv('BUILDAH_PUSH'):
await self.image.push(target)
async def mount(self, src, dst):
@@ -184,13 +175,6 @@ class Buildah(Target):
for key, value in self.config.items():
await self.parent.exec(f'buildah config --{key} "{value}" {self.ctr}')
self.sha = (await self.parent.exec(
'buildah',
'commit',
'--format=' + image.format,
self.ctr,
)).out
ENV_TAGS = (
# gitlab
'CI_COMMIT_SHORT_SHA',
@@ -214,8 +198,7 @@ class Buildah(Target):
else:
tags = [image.repository]
for tag in tags:
await self.parent.exec('buildah', 'tag', self.sha, tag)
await self.parent.exec('buildah', 'tag', self.image_previous, *tags)
async def mkdir(self, path):
return await self.parent.mkdir(self.path(path))