1 Commits
Author SHA1 Message Date
DrClaw ad069a1aa0 dnf stuff 2020-06-02 09:54:34 +00:00
5 changed files with 38 additions and 49 deletions
+2 -9
View File
@@ -2,20 +2,13 @@ build:
cache:
key: cache
paths: [.cache]
image: yourlabs/buildah
image: quay.io/buildah/stable
script:
- dnf install -y python3-pip
- 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
+1 -4
View File
@@ -19,10 +19,7 @@ class Pip(Action):
raise Exception('Could not find pip nor python')
# ensure pip module presence
result = await target.exec(
python, '-m', 'pip',
raises=False, quiet=True
)
result = await target.exec(python, '-m', 'pip', raises=False)
if result.rc != 0:
if not os.path.exists('get-pip.py'):
req = request.urlopen(
+9 -24
View File
@@ -20,37 +20,22 @@ 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 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, *args, **kwargs):
return self.shlax_target(self.target)
def __call__(self, *argv):
super().__call__(*argv)
self['target'].value.output.results(self['target'].value)
from shlax.targets.base import Target
self.shlax_target = Target()
result = super().__call__(*argv)
self.shlax_target.output.results(self.shlax_target)
return result
class ActionCommand(cli2.Command):
class ActionCommand(Command):
def call(self, *args, **kwargs):
self.target = self.target(*args, **kwargs)
from shlax.targets.base import Target
return super().call(Target())
return super().call(*args, **kwargs)
class ConsoleScript(Group):
-3
View File
@@ -18,9 +18,6 @@ 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()
+26 -9
View File
@@ -63,17 +63,22 @@ class Buildah(Target):
if actions:
actions = actions[len(keep):]
if not actions:
return self.output.success('Image up to date')
return self.uptodate()
else:
self.actions = self.actions[len(keep):]
if not self.actions:
return self.output.success('Image up to date')
return self.uptodate()
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(
@@ -139,15 +144,19 @@ class Buildah(Target):
return stop
async def clean(self, target, result):
if self.ctr is not None:
for src, dst in self.mounts.items():
await self.parent.exec('umount', self.root / str(dst)[1:])
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()
await self.parent.exec('buildah', 'rm', self.ctr)
if result.status == 'success':
await self.commit()
if os.getenv('BUILDAH_PUSH'):
if result.status == 'success' and os.getenv('BUILDAH_PUSH'):
await self.image.push(target)
async def mount(self, src, dst):
@@ -175,6 +184,13 @@ 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',
@@ -198,7 +214,8 @@ class Buildah(Target):
else:
tags = [image.repository]
await self.parent.exec('buildah', 'tag', self.image_previous, *tags)
for tag in tags:
await self.parent.exec('buildah', 'tag', self.sha, tag)
async def mkdir(self, path):
return await self.parent.mkdir(self.path(path))