Skip to content

Commit 7e0f646

Browse files
committed
builder: handle bundle state changes
Move the affected sources to attic whenever the bundle state changes.
1 parent 6e1d3df commit 7e0f646

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

pym/bob/builder.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ def invalidate(self):
6868

6969
CHECKOUT_STATE_VARIANT_ID = None # Key in checkout directory state for step variant-id
7070
CHECKOUT_STATE_BUILD_ONLY = 1 # Key for checkout state of build-only builds
71+
CHECKOUT_STATE_BUNDLE = 2 # Store whether the checkout origin was a bundle or not
7172

7273
# Keys in checkout getDirectoryState that are not directories
73-
CHECKOUT_NON_DIR_KEYS = {CHECKOUT_STATE_VARIANT_ID, CHECKOUT_STATE_BUILD_ONLY}
74+
CHECKOUT_NON_DIR_KEYS = {CHECKOUT_STATE_VARIANT_ID, CHECKOUT_STATE_BUILD_ONLY,
75+
CHECKOUT_STATE_BUNDLE}
7476

7577
def compareDirectoryState(left, right):
7678
"""Compare two directory states while ignoring the SCM specs.
@@ -88,6 +90,10 @@ def compareDirectoryState(left, right):
8890
right = { d : v[0] for d, v in right.items() if d != CHECKOUT_STATE_BUILD_ONLY }
8991
return left == right
9092

93+
def compareBundleState(left, right):
94+
_r = right[CHECKOUT_STATE_BUNDLE] if CHECKOUT_STATE_BUNDLE in right else False
95+
return left[CHECKOUT_STATE_BUNDLE] == _r
96+
9197
def checkoutsFromState(state):
9298
"""Return only the tuples related to SCMs from the checkout state.
9399
@@ -356,7 +362,7 @@ def fmt(step, props):
356362
return fmt
357363

358364
def __init__(self, verbose, force, skipDeps, buildOnly, preserveEnv,
359-
envWhiteList, bobRoot, cleanBuild, noLogFile):
365+
envWhiteList, bobRoot, cleanBuild, noLogFile, unbundle):
360366
self.__wasRun= {}
361367
self.__wasSkipped = {}
362368
self.__wasDownloadTried = {}
@@ -397,6 +403,7 @@ def __init__(self, verbose, force, skipDeps, buildOnly, preserveEnv,
397403
self.__executor = None
398404
self.__attic = True
399405
self.__slimSandbox = False
406+
self.__unbundle = unbundle
400407

401408
def setExecutor(self, executor):
402409
self.__executor = executor
@@ -1102,6 +1109,7 @@ async def _cookCheckoutStep(self, checkoutStep, depth):
11021109
checkoutState = checkoutStep.getScmDirectories().copy()
11031110
checkoutState[CHECKOUT_STATE_VARIANT_ID] = (checkoutDigest, None)
11041111
checkoutState[CHECKOUT_STATE_BUILD_ONLY] = checkoutBuildOnlyState(checkoutStep, checkoutInputHashes)
1112+
checkoutState[CHECKOUT_STATE_BUNDLE] = (self.__unbundle, None)
11051113
currentResultHash = HashOnce(checkoutStep)
11061114
if self.__buildOnly and (BobState().getResultHash(prettySrcPath) is not None):
11071115
inputChanged = checkoutBuildOnlyStateChanged(checkoutState, oldCheckoutState)
@@ -1147,7 +1155,10 @@ async def _cookCheckoutStep(self, checkoutStep, depth):
11471155
elif not checkoutStep.isDeterministic():
11481156
checkoutReason = "indeterministic"
11491157
elif not compareDirectoryState(checkoutState, oldCheckoutState):
1150-
checkoutReason = "recipe changed"
1158+
if not compareBundleState(checkoutState, oldCheckoutState):
1159+
checkoutReason = "bundle mode changed"
1160+
else:
1161+
checkoutReason = "recipe changed"
11511162
elif (checkoutInputHashes != BobState().getInputHashes(prettySrcPath)):
11521163
checkoutReason = "dependency changed"
11531164
elif (checkoutStep.getMainScript() or checkoutStep.getPostRunCmds()) \
@@ -1171,8 +1182,10 @@ async def _cookCheckoutStep(self, checkoutStep, depth):
11711182
BobState().setAtticDirectoryState(atticPath, scmSpec)
11721183
del oldCheckoutState[scmDir]
11731184
BobState().setDirectoryState(prettySrcPath, oldCheckoutState)
1174-
elif scmDigest != checkoutState.get(scmDir, (None, None))[0]:
1185+
elif (scmDigest != checkoutState.get(scmDir, (None, None))[0]) or \
1186+
not compareBundleState(checkoutState, oldCheckoutState):
11751187
canSwitch = (scmDir in scmMap) and scmDigest and \
1188+
compareBundleState(checkoutState, oldCheckoutState) and \
11761189
scmSpec is not None and \
11771190
scmMap[scmDir].canSwitch(getScm(scmSpec)) and \
11781191
os.path.exists(scmPath)

pym/bob/cmds/jenkins/exec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def doJenkinsExecuteRun(argv, bobRoot):
223223
with EventLoopWrapper() as (loop, executor):
224224
setVerbosity(TRACE)
225225
builder = LocalBuilder(TRACE, False, False, False, False, envWhiteList,
226-
bobRoot, False, True)
226+
bobRoot, False, True, False)
227227
builder.setBuildDistBuildIds(dependencyBuildIds)
228228
builder.setExecutor(executor)
229229
builder.setArchiveHandler(getArchiver(

0 commit comments

Comments
 (0)