Add automatic build test
This commit is contained in:
parent
5b11100e0a
commit
8b145e6378
@ -97,6 +97,16 @@ class Output:
|
||||
|
||||
return line
|
||||
|
||||
def test(self, action):
|
||||
if self.debug is True:
|
||||
self(''.join([
|
||||
self.colors['purplebold'],
|
||||
'! TEST ',
|
||||
self.colors['reset'],
|
||||
action.colorized(),
|
||||
'\n',
|
||||
]))
|
||||
|
||||
def clean(self, action):
|
||||
if self.debug is True:
|
||||
self(''.join([
|
||||
|
||||
@ -20,7 +20,7 @@ class Buildah(Localhost):
|
||||
The build script iterates over visitors and runs the build functions, it
|
||||
also provides wrappers around the buildah command.
|
||||
"""
|
||||
contextualize = Localhost.contextualize + ['mnt', 'ctr', 'mount']
|
||||
contextualize = Localhost.contextualize + ['mnt', 'ctr', 'mount', 'image']
|
||||
|
||||
def __init__(self, base, *args, commit=None, push=False, cmd=None, **kwargs):
|
||||
if isinstance(base, Action):
|
||||
@ -56,6 +56,18 @@ class Buildah(Localhost):
|
||||
def __repr__(self):
|
||||
return f'Base({self.base})'
|
||||
|
||||
async def __call__(self, *args, **kwargs):
|
||||
result = await super().__call__(*args, **kwargs)
|
||||
if 'test' in self.kwargs and self.is_runnable():
|
||||
self.output.test(self)
|
||||
await self.action('Docker',
|
||||
*self.kwargs['test'].actions,
|
||||
image=self.image,
|
||||
mount={'.': '/app'},
|
||||
workdir='/app',
|
||||
)(*args, **kwargs)
|
||||
return result
|
||||
|
||||
async def config(self, line):
|
||||
"""Run buildah config."""
|
||||
return await self.exec(f'buildah config {line} {self.ctr}', buildah=False)
|
||||
|
||||
@ -10,7 +10,9 @@ class Docker(Localhost):
|
||||
contextualize = Localhost.contextualize + ['mnt', 'ctr', 'mount']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.image = Image(kwargs.get('image', 'alpine'))
|
||||
self.image = kwargs.get('image', 'alpine')
|
||||
if not isinstance(self.image, Image):
|
||||
self.image = Image(image)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.context['ctr'] = None
|
||||
|
||||
|
||||
21
shlaxfile.py
21
shlaxfile.py
@ -3,6 +3,11 @@ from shlax.contrib.gitlab import *
|
||||
|
||||
PYTEST = 'py.test -svv tests'
|
||||
|
||||
test = Script(
|
||||
Pip('.[test]'),
|
||||
Run(PYTEST),
|
||||
)
|
||||
|
||||
build = Buildah(
|
||||
'quay.io/podman/stable',
|
||||
Packages('python38', 'buildah', 'unzip', 'findutils', 'python3-yaml', upgrade=False),
|
||||
@ -14,23 +19,15 @@ build = Buildah(
|
||||
mkdir -p /usr/local/lib/python3.8/site-packages/
|
||||
sh -c "cd setuptools-* && python3.8 setup.py install"
|
||||
easy_install-3.8 pip
|
||||
echo python3.8 -m pip > /usr/bin/pip
|
||||
chmod +x /usr/bin/pip
|
||||
'''),
|
||||
Copy('shlax/', 'setup.py', '/app'),
|
||||
),
|
||||
Pip('/app', pip='python3.8 -m pip'),
|
||||
Pip('/app'),
|
||||
commit='yourlabs/shlax',
|
||||
workdir='/app',
|
||||
)
|
||||
|
||||
test = Script(
|
||||
Pip('.[test]'),
|
||||
Run(PYTEST),
|
||||
)
|
||||
|
||||
buildtest = Docker(
|
||||
*test.actions,
|
||||
mount={'.': '/app'},
|
||||
workdir='/app',
|
||||
test=test,
|
||||
)
|
||||
|
||||
pypi = Run(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user