Fix exit codes
This commit is contained in:
parent
44dd1bc6a6
commit
bcbe66a37f
@ -16,6 +16,12 @@ build-itself:
|
||||
script: python3 ./shlaxfile.py build push=docker://docker.io/yourlabs/shlax:$CI_COMMIT_REF
|
||||
stage: test
|
||||
|
||||
test-exitcode:
|
||||
image: yourlabs/shlax:$CI_COMMIT_SHORT_SHA
|
||||
script:
|
||||
- tests/shlaxfail.py build || [ $? -eq 1 ]
|
||||
- tests/shlaxsuccess.py build
|
||||
|
||||
test:
|
||||
image: yourlabs/python
|
||||
stage: build
|
||||
|
||||
10
shlax/cli.py
10
shlax/cli.py
@ -60,13 +60,13 @@ class Command(cli2.Command):
|
||||
except ProcFailure:
|
||||
# just output the failure without TB, as command was already
|
||||
# printed anyway
|
||||
pass
|
||||
|
||||
if self['target'].value.results:
|
||||
if self['target'].value.results[-1].status == 'failure':
|
||||
self.exit_code = 1
|
||||
self['target'].value.output.results(self['target'].value)
|
||||
|
||||
if result and result.status == 'success':
|
||||
self.exit_code = 0
|
||||
else:
|
||||
self.exit_code = 1
|
||||
return result
|
||||
|
||||
|
||||
class ActionCommand(cli2.Command):
|
||||
|
||||
18
tests/shlaxfail.py
Executable file
18
tests/shlaxfail.py
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Shlaxfile for shlax itself.
|
||||
"""
|
||||
|
||||
from shlax.shortcuts import *
|
||||
|
||||
shlax = Container(
|
||||
build=Buildah(
|
||||
Packages('prout', upgrade=False),
|
||||
base='alpine',
|
||||
commit='shlaxfail',
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(Group(doc=__doc__).load(shlax).entry_point())
|
||||
17
tests/shlaxsuccess.py
Executable file
17
tests/shlaxsuccess.py
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Shlaxfile for shlax itself.
|
||||
"""
|
||||
|
||||
from shlax.shortcuts import *
|
||||
|
||||
shlax = Container(
|
||||
build=Buildah(
|
||||
base='alpine',
|
||||
commit='shlaxsuccess',
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(Group(doc=__doc__).load(shlax).entry_point())
|
||||
Loading…
x
Reference in New Issue
Block a user