Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
56710c49
Commit
56710c49
authored
6 years ago
by
Jürg Billeter
Browse files
Options
Downloads
Patches
Plain Diff
buildelement.py: Support batching for integration and build commands
parent
c4b86ea7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
buildstream/buildelement.py
+11
-12
11 additions, 12 deletions
buildstream/buildelement.py
tests/integration/sandbox-bwrap.py
+1
-1
1 addition, 1 deletion
tests/integration/sandbox-bwrap.py
with
12 additions
and
13 deletions
buildstream/buildelement.py
+
11
−
12
View file @
56710c49
...
...
@@ -127,7 +127,7 @@ artifact collection purposes.
"""
import
os
from
.
import
Element
,
Scope
,
ElementError
from
.
import
Element
,
Scope
from
.
import
SandboxFlags
...
...
@@ -207,6 +207,10 @@ class BuildElement(Element):
# Setup environment
sandbox
.
set_environment
(
self
.
get_environment
())
# Enable command batching across prepare() and assemble()
self
.
configure_prepare_assemble_batch
(
SandboxFlags
.
ROOT_READ_ONLY
,
collect
=
self
.
get_variable
(
'
install-root
'
))
def
stage
(
self
,
sandbox
):
# Stage deps in the sandbox root
...
...
@@ -215,7 +219,7 @@ class BuildElement(Element):
# Run any integration commands provided by the dependencies
# once they are all staged and ready
with
s
elf
.
timed_activity
(
"
Integrating sandbox
"
):
with
s
andbox
.
batch
(
0
,
label
=
"
Integrating sandbox
"
):
for
dep
in
self
.
dependencies
(
Scope
.
BUILD
):
dep
.
integrate
(
sandbox
)
...
...
@@ -223,14 +227,13 @@ class BuildElement(Element):
self
.
stage_sources
(
sandbox
,
self
.
get_variable
(
'
build-root
'
))
def
assemble
(
self
,
sandbox
):
# Run commands
for
command_name
in
_command_steps
:
commands
=
self
.
__commands
[
command_name
]
if
not
commands
or
command_name
==
'
configure-commands
'
:
continue
with
s
elf
.
timed_activity
(
"
Running {}
"
.
format
(
command_name
)):
with
s
andbox
.
batch
(
SandboxFlags
.
ROOT_READ_ONLY
,
label
=
"
Running {}
"
.
format
(
command_name
)):
for
cmd
in
commands
:
self
.
__run_command
(
sandbox
,
cmd
,
command_name
)
...
...
@@ -254,7 +257,7 @@ class BuildElement(Element):
def
prepare
(
self
,
sandbox
):
commands
=
self
.
__commands
[
'
configure-commands
'
]
if
commands
:
with
s
elf
.
timed_activity
(
"
Running configure-commands
"
):
with
s
andbox
.
batch
(
SandboxFlags
.
ROOT_READ_ONLY
,
label
=
"
Running configure-commands
"
):
for
cmd
in
commands
:
self
.
__run_command
(
sandbox
,
cmd
,
'
configure-commands
'
)
...
...
@@ -282,13 +285,9 @@ class BuildElement(Element):
return
commands
def
__run_command
(
self
,
sandbox
,
cmd
,
cmd_name
):
self
.
status
(
"
Running {}
"
.
format
(
cmd_name
),
detail
=
cmd
)
# Note the -e switch to 'sh' means to exit with an error
# if any untested command fails.
#
exitcode
=
sandbox
.
run
([
'
sh
'
,
'
-c
'
,
'
-e
'
,
cmd
+
'
\n
'
],
SandboxFlags
.
ROOT_READ_ONLY
)
if
exitcode
!=
0
:
raise
ElementError
(
"
Command
'
{}
'
failed with exitcode {}
"
.
format
(
cmd
,
exitcode
),
collect
=
self
.
get_variable
(
'
install-root
'
))
sandbox
.
run
([
'
sh
'
,
'
-c
'
,
'
-e
'
,
cmd
+
'
\n
'
],
SandboxFlags
.
ROOT_READ_ONLY
,
label
=
cmd
)
This diff is collapsed.
Click to expand it.
tests/integration/sandbox-bwrap.py
+
1
−
1
View file @
56710c49
...
...
@@ -58,5 +58,5 @@ def test_sandbox_bwrap_return_subprocess(cli, tmpdir, datafiles):
})
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
element_name
])
result
.
assert_task_error
(
error_domain
=
ErrorDomain
.
ELEMENT
,
error_reason
=
None
)
result
.
assert_task_error
(
error_domain
=
ErrorDomain
.
SANDBOX
,
error_reason
=
"
command-failed
"
)
assert
"
sandbox-bwrap/command-exit-42.bst|Command
'
exit 42
'
failed with exitcode 42
"
in
result
.
stderr
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment