GitLabCI can now execute the same jobs it generates for gitlab
This commit is contained in:
parent
6924d39590
commit
2ea37fb01d
@ -1,14 +1,8 @@
|
||||
build:
|
||||
image: yourlabs/shlax
|
||||
script: ./shlaxfile.py build
|
||||
stage: build
|
||||
build: {image: yourlabs/shlax, script: ./shlaxfile.py build, stage: build}
|
||||
pypi:
|
||||
image: yourlabs/python
|
||||
only:
|
||||
- tags
|
||||
only: [tags]
|
||||
script: ./shlaxfile.py pypi
|
||||
stage: deploy
|
||||
test:
|
||||
image: yourlabs/shlax
|
||||
script: ./shlaxfile.py test
|
||||
stage: test
|
||||
test: {image: 'yourlabs/shlax:$CI_COMMIT_SHORT_SHA', script: ./shlaxfile.py test,
|
||||
stage: test}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from copy import deepcopy
|
||||
import yaml
|
||||
|
||||
from shlax import *
|
||||
@ -8,10 +9,14 @@ class GitLabCI(Script):
|
||||
output = dict()
|
||||
for key, value in self.kwargs.items():
|
||||
if isinstance(value, dict):
|
||||
output[key] = value
|
||||
output[key] = deepcopy(value)
|
||||
output[key]['script'] = './shlaxfile.py ' + key
|
||||
image = output[key].get('image', 'alpine')
|
||||
if hasattr(image, 'image'):
|
||||
output[key]['image'] = image.image.repository + ':$CI_COMMIT_SHORT_SHA'
|
||||
else:
|
||||
output[key] = value
|
||||
|
||||
output = yaml.dump(output)
|
||||
if kwargs['debug'] is True:
|
||||
self.output(output)
|
||||
@ -19,5 +24,20 @@ class GitLabCI(Script):
|
||||
with open('.gitlab-ci.yml', 'w+') as f:
|
||||
f.write(output)
|
||||
|
||||
from shlax.cli import cli
|
||||
for arg in args:
|
||||
job = self.kwargs[arg]
|
||||
_args = []
|
||||
if not isinstance(job['image'], str):
|
||||
await job['image'](**kwargs)
|
||||
image = str(job['image'].image)
|
||||
_args.append('recreate')
|
||||
else:
|
||||
image = job['image']
|
||||
await Docker(
|
||||
*cli.shlaxfile.actions[arg].actions,
|
||||
image=image
|
||||
)(*_args, **kwargs)
|
||||
|
||||
def colorized(self):
|
||||
return type(self).__name__
|
||||
|
||||
@ -61,4 +61,4 @@ class Image:
|
||||
return await action.exec(*args, **self.kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return self.repository
|
||||
return f'{self.repository}:{self.tags[-1]}'
|
||||
|
||||
@ -34,7 +34,7 @@ gitlabci = GitLabCI(
|
||||
),
|
||||
test=dict(
|
||||
stage='test',
|
||||
image='yourlabs/shlax',
|
||||
image=build,
|
||||
),
|
||||
pypi=dict(
|
||||
stage='deploy',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user