def test_create(self): gyp_to_android.main(self.__tmp_dir) # Now there should be a file named 'Android.mk' inside __tmp_dir path_to_android_mk = os.path.join(self.__tmp_dir, test_variables.ANDROID_MK) self.assertTrue(os.path.exists(path_to_android_mk))
def _Run(self): with misc.ChDir(EXTERNAL_SKIA): # Check to see whether there is an upstream yet. if not UPSTREAM_REMOTE_NAME in shell_utils.run([GIT, 'remote', 'show']): try: shell_utils.run([GIT, 'remote', 'add', UPSTREAM_REMOTE_NAME, SKIA_REPO_URL]) except shell_utils.CommandFailedException as e: if 'remote %s already exists' % UPSTREAM_REMOTE_NAME in e.output: # Accept this error. The upstream remote name should have been in # the output of git remote show, which would have made us skip this # redundant command anyway. print ('%s was already added. Why did it not show in git remote' ' show?' % UPSTREAM_REMOTE_NAME) else: raise e # Update the upstream remote. shell_utils.run([GIT, 'fetch', UPSTREAM_REMOTE_NAME]) # Create a stack of commits to submit, one at a time, until we reach a # commit that has already been merged. commit_stack = [] head = git_utils.ShortHash('HEAD') print 'HEAD is at %s' % head if self._got_revision: # Merge the revision that started this build. commit = git_utils.ShortHash(self._got_revision) else: raise Exception('This build has no _got_revision to merge!') print ('Starting with %s, look for commits that have not been merged to ' 'HEAD' % commit) while not git_utils.AIsAncestorOfB(commit, head): print 'Adding %s to list of commits to merge.' % commit commit_stack.append(commit) if git_utils.IsMerge(commit): # Skia's commit history is not linear. There is no obvious way to # merge each branch in, one commit at a time. So just start with the # merge commit. print '%s is a merge. Skipping merge of its parents.' % commit break commit = git_utils.ShortHash(commit + '~1') else: print '%s has already been merged.' % commit if len(commit_stack) == 0: raise BuildStepWarning('Nothing to merge; did someone already merge %s?' ' Exiting.' % commit) print 'Merging %s commit(s):\n%s' % (len(commit_stack), '\n'.join(reversed(commit_stack))) # Now we have a list of commits to merge. while len(commit_stack) > 0: commit_to_merge = commit_stack.pop() print 'Attempting to merge ' + commit_to_merge # Start the merge. try: shell_utils.run([GIT, 'merge', commit_to_merge, '--no-commit']) except shell_utils.CommandFailedException: # Merge conflict. There may be a more elegant solution, but for now, # undo the merge, and allow (/make) a human to do it. git_utils.MergeAbort() raise Exception('Failed to merge %s. Fall back to manual human ' 'merge.' % commit_to_merge) # Grab the upstream version of SkUserConfig, which will be used to # generate Android's version. shell_utils.run([GIT, 'checkout', commit_to_merge, '--', UPSTREAM_USER_CONFIG]) # We don't want to commit the upstream version, so remove it from the # index. shell_utils.run([GIT, 'reset', 'HEAD', UPSTREAM_USER_CONFIG]) # Now generate Android.mk and SkUserConfig.h gyp_failed = False try: gyp_to_android.main() except AssertionError as e: print e # Failed to generate the makefiles. Make a human fix the problem. git_utils.MergeAbort() raise Exception('Failed to generate makefiles for %s. Fall back to ' 'manual human merge.' % commit_to_merge) except SystemExit as e: gyp_failed = True if not gyp_failed: git_utils.Add('Android.mk') git_utils.Add(ANDROID_USER_CONFIG) git_utils.Add(os.path.join('tests', 'Android.mk')) git_utils.Add(os.path.join('tools', 'Android.mk')) git_utils.Add(os.path.join('bench', 'Android.mk')) git_utils.Add(os.path.join('gm', 'Android.mk')) git_utils.Add(os.path.join('dm', 'Android.mk')) # Remove upstream user config, which is no longer needed. os.remove(UPSTREAM_USER_CONFIG) # Create a new branch. shell_utils.run([REPO, 'start', LOCAL_BRANCH_NAME, '.']) try: orig_msg = shell_utils.run([GIT, 'show', commit_to_merge, '--format="%s"', '-s']).rstrip() message = 'Merge %s into master-skia\n\n' + SKIA_REV_URL if gyp_failed: message += '\n\nFIXME: Failed to generate makefiles!' shell_utils.run([GIT, 'commit', '-m', message % (orig_msg, commit_to_merge)]) except shell_utils.CommandFailedException: # It is possible that someone else already did the merge (for example, # if they are testing a build slave). Clean up and exit. RepoAbandon(LOCAL_BRANCH_NAME) raise BuildStepWarning('Nothing to merge; did someone already merge ' '%s?' % commit_to_merge) # For some reason, sometimes the bot's authentication from sync_android # does not carry over to this step. Authenticate again. with GitAuthenticate(): # Now push to master-skia branch try: shell_utils.run([GIT, 'push', MASTER_SKIA_URL, MASTER_SKIA_REFS]) except shell_utils.CommandFailedException: # It's possible someone submitted in between our sync and push or # push failed for some other reason. Abandon and let the next # attempt try again. RepoAbandon(LOCAL_BRANCH_NAME) raise BuildStepFailure('git push failed!') # Our branch is no longer needed. Remove it. shell_utils.run([REPO, 'sync', '-j32', '.']) shell_utils.run([REPO, 'prune', '.']) # If gyp failed, this probably means there was an error in the gyp # files. We still want to push the commit. This way, when it gets # fixed with a future commit, we don't remain hung up on this one. if gyp_failed: raise BuildStepFailure('Merged %s, but failed to generate makefiles.' ' Is there a mistake in the gyp files?' % commit_to_merge)
def _Run(self): with misc.ChDir(EXTERNAL_SKIA): # Set up git config properly. shell_utils.run([GIT, 'config', 'user.email', '"*****@*****.**"']) shell_utils.run([GIT, 'config', 'user.name', '"Skia_Android Canary Bot"']) # Check to see whether there is an upstream yet. if not UPSTREAM_REMOTE_NAME in shell_utils.run([GIT, 'remote', 'show']): shell_utils.run([GIT, 'remote', 'add', UPSTREAM_REMOTE_NAME, SKIA_REPO_URL]) # Update the upstream remote. shell_utils.run([GIT, 'fetch', UPSTREAM_REMOTE_NAME]) # Start the merge. try: shell_utils.run([GIT, 'merge', UPSTREAM_BRANCH_NAME, '--no-commit']) except shell_utils.CommandFailedException: # Merge conflict. There may be a more elegant solution, but for now, # undo the merge, and allow (/make) a human to do it. shell_utils.run([GIT, 'merge', '--abort']) raise Exception('Merge failed. Fall back to manual human merge.') # Grab the upstream version of SkUserConfig, which will be used to # generate Android's version. shell_utils.run([GIT, 'checkout', UPSTREAM_BRANCH_NAME, '--', UPSTREAM_USER_CONFIG]) # We don't want to commit the upstream version, so remove it from the # index. shell_utils.run([GIT, 'reset', 'HEAD', UPSTREAM_USER_CONFIG]) # Now generate Android.mk and SkUserConfig.h sys.path.append(os.path.join(os.getcwd(), PLATFORM_TOOLS_BIN)) import gyp_to_android gyp_to_android.main() shell_utils.run([GIT, 'add', 'Android.mk']) shell_utils.run([GIT, 'add', ANDROID_USER_CONFIG]) shell_utils.run([GIT, 'add', os.path.join('tests', 'Android.mk')]) # Remove upstream user config, which is no longer needed. shell_utils.run(['rm', UPSTREAM_USER_CONFIG]) # Create a new branch. shell_utils.run([REPO, 'start', LOCAL_BRANCH_NAME, '.']) # Figure out the revision being merged, and use it to write the commit # message. commit_message = shell_utils.run([GIT, 'show', UPSTREAM_BRANCH_NAME]) rev_index = commit_message.find(GIT_SVN_ID) + len(GIT_SVN_ID) rev_end = commit_message.find(' ', rev_index) revision = commit_message[rev_index:rev_end] try: shell_utils.run([GIT, 'commit', '-m', 'Merge Skia at r' + revision]) except shell_utils.CommandFailedException: # It is possible that someone else already did the merge (for example, # if they are testing a build slave). Clean up and exit. shell_utils.run([REPO, 'abandon', LOCAL_BRANCH_NAME]) raise Exception('Nothing to merge; did someone already merge r%s?' % revision) # Now push to master-skia branch shell_utils.run([GIT, 'push', MASTER_SKIA_URL, MASTER_SKIA_REFS]) # Our branch is no longer needed. Remove it. shell_utils.run([REPO, 'sync', '-j32', '.']) shell_utils.run([REPO, 'prune', '.'])
def _Run(self): with misc.ChDir(EXTERNAL_SKIA): # Check to see whether there is an upstream yet. if not UPSTREAM_REMOTE_NAME in shell_utils.run( [GIT, 'remote', 'show']): try: shell_utils.run([ GIT, 'remote', 'add', UPSTREAM_REMOTE_NAME, SKIA_REPO_URL ]) except shell_utils.CommandFailedException as e: if 'remote %s already exists' % UPSTREAM_REMOTE_NAME in e.output: # Accept this error. The upstream remote name should have been in # the output of git remote show, which would have made us skip this # redundant command anyway. print( '%s was already added. Why did it not show in git remote' ' show?' % UPSTREAM_REMOTE_NAME) else: raise e # Update the upstream remote. shell_utils.run([GIT, 'fetch', UPSTREAM_REMOTE_NAME]) # Create a stack of commits to submit, one at a time, until we reach a # commit that has already been merged. commit_stack = [] head = git_utils.ShortHash('HEAD') print 'HEAD is at %s' % head if self._got_revision: # Merge the revision that started this build. commit = git_utils.ShortHash(self._got_revision) else: raise Exception('This build has no _got_revision to merge!') print( 'Starting with %s, look for commits that have not been merged to ' 'HEAD' % commit) while not git_utils.AIsAncestorOfB(commit, head): print 'Adding %s to list of commits to merge.' % commit commit_stack.append(commit) if git_utils.IsMerge(commit): # Skia's commit history is not linear. There is no obvious way to # merge each branch in, one commit at a time. So just start with the # merge commit. print '%s is a merge. Skipping merge of its parents.' % commit break commit = git_utils.ShortHash(commit + '~1') else: print '%s has already been merged.' % commit if len(commit_stack) == 0: raise BuildStepWarning( 'Nothing to merge; did someone already merge %s?' ' Exiting.' % commit) print 'Merging %s commit(s):\n%s' % (len(commit_stack), '\n'.join( reversed(commit_stack))) # Now we have a list of commits to merge. while len(commit_stack) > 0: commit_to_merge = commit_stack.pop() print 'Attempting to merge ' + commit_to_merge # Start the merge. try: shell_utils.run( [GIT, 'merge', commit_to_merge, '--no-commit']) except shell_utils.CommandFailedException: # Merge conflict. There may be a more elegant solution, but for now, # undo the merge, and allow (/make) a human to do it. git_utils.MergeAbort() raise Exception( 'Failed to merge %s. Fall back to manual human ' 'merge.' % commit_to_merge) # Grab the upstream version of SkUserConfig, which will be used to # generate Android's version. shell_utils.run([ GIT, 'checkout', commit_to_merge, '--', UPSTREAM_USER_CONFIG ]) # We don't want to commit the upstream version, so remove it from the # index. shell_utils.run([GIT, 'reset', 'HEAD', UPSTREAM_USER_CONFIG]) # Now generate Android.mk and SkUserConfig.h gyp_failed = False try: gyp_to_android.main() except AssertionError as e: print e # Failed to generate the makefiles. Make a human fix the problem. git_utils.MergeAbort() raise Exception( 'Failed to generate makefiles for %s. Fall back to ' 'manual human merge.' % commit_to_merge) except SystemExit as e: gyp_failed = True if not gyp_failed: git_utils.Add('Android.mk') git_utils.Add(ANDROID_USER_CONFIG) git_utils.Add(os.path.join('tests', 'Android.mk')) git_utils.Add(os.path.join('tools', 'Android.mk')) git_utils.Add(os.path.join('bench', 'Android.mk')) git_utils.Add(os.path.join('gm', 'Android.mk')) git_utils.Add(os.path.join('dm', 'Android.mk')) # Remove upstream user config, which is no longer needed. os.remove(UPSTREAM_USER_CONFIG) # Create a new branch. shell_utils.run([REPO, 'start', LOCAL_BRANCH_NAME, '.']) try: orig_msg = shell_utils.run( [GIT, 'show', commit_to_merge, '--format="%s"', '-s']).rstrip() message = 'Merge %s into master-skia\n\n' + SKIA_REV_URL if gyp_failed: message += '\n\nFIXME: Failed to generate makefiles!' shell_utils.run([ GIT, 'commit', '-m', message % (orig_msg, commit_to_merge) ]) except shell_utils.CommandFailedException: # It is possible that someone else already did the merge (for example, # if they are testing a build slave). Clean up and exit. RepoAbandon(LOCAL_BRANCH_NAME) raise BuildStepWarning( 'Nothing to merge; did someone already merge ' '%s?' % commit_to_merge) # For some reason, sometimes the bot's authentication from sync_android # does not carry over to this step. Authenticate again. with GitAuthenticate(): # Now push to master-skia branch try: shell_utils.run( [GIT, 'push', MASTER_SKIA_URL, MASTER_SKIA_REFS]) except shell_utils.CommandFailedException: # It's possible someone submitted in between our sync and push or # push failed for some other reason. Abandon and let the next # attempt try again. RepoAbandon(LOCAL_BRANCH_NAME) raise BuildStepFailure('git push failed!') # Our branch is no longer needed. Remove it. shell_utils.run([REPO, 'sync', '-j32', '.']) shell_utils.run([REPO, 'prune', '.']) # If gyp failed, this probably means there was an error in the gyp # files. We still want to push the commit. This way, when it gets # fixed with a future commit, we don't remain hung up on this one. if gyp_failed: raise BuildStepFailure( 'Merged %s, but failed to generate makefiles.' ' Is there a mistake in the gyp files?' % commit_to_merge)