This is an archive of the discontinued LLVM Phabricator instance.

Update Jenkins Build.py to check and upgrade svn version in working dir as necessary.
AbandonedPublic

Authored by sqlbyme on Apr 21 2017, 11:20 AM.

Details

Summary

When we upgrade Xcode versions on the Green Dragon bots we need to also upgrade the SVN version of the current working directory. This patch will allow build.py to do so automatically.

This patch also includes a bit of general cleanup and a typo fix.

Diff Detail

Repository
rL LLVM

Event Timeline

sqlbyme created this revision.Apr 21 2017, 11:20 AM
mehdi_amini added inline comments.Apr 21 2017, 1:17 PM
zorg/jenkins/build.py
175

Can't we run svn upgrade unconditionally?
Why the version check?

907–908

Why this change?

967

I guess we don't care about exception handling?

sqlbyme added inline comments.Apr 21 2017, 3:31 PM
zorg/jenkins/build.py
175

If we run the svn upgrade command unconditionally it will return an error when run on a directory which does not need to be upgraded. When I worked on this with Chris M. internally we settled on this approach to ensure we only run the upgrade command on a working direct which actually requires it.

907–908

The context here is not great. This variable was originally assigned in a try block. If the try block bailed out for some reason the variable would never be assigned. It is used a few lines down in a logger function call. I figured it was better to have it assigned to an empty string just in case it somehow did not get assigned in the try block.

967

No, we want the subprocess to run and return what ever happens. We will let the calling function decide what to do with the error, if anything.

mehdi_amini added inline comments.Apr 21 2017, 3:44 PM
zorg/jenkins/build.py
175

OK but here you always run the upgrade when the svn install is 1.7.23 and higher, I don't see how it address the issue you're describing.

179

why not assert m here and get an easier control flow + indentation?

907–908

FYI: git diff -U99999 allows you to upload patch with context (or arc would do it as well).

I figured it was better to have it assigned to an empty string just in case it somehow did not get assigned in the try block.

Right, but is it related to this patch? Otherwise just commit this separately (along with the whitespace changes here and there if possible).

967

But subprocess.check_output can throw, and you won't restore the path.
Should be something like:

def run_collect_output(cmd, working_dir=None, stderr=None):
    """Run cmd, and return the output"""
    last = os.getcwd()
    try:
        if os.getenv("TESTING"):
            print 'TV: ' + ' '.join(cmd)
            return TEST_VALS[' '.join(cmd)]
        if working_dir:
            os.chdir(working_dir)
        out = subprocess.check_output(cmd, stderr=stderr)
    finally:
      os.chdir(last)

Using a contextmanager would even be cleaner but not sure if it is available everywhere on our installs? http://stackoverflow.com/questions/299446/how-do-i-change-directory-back-to-my-original-working-directory-with-python

sqlbyme abandoned this revision.Apr 24 2017, 1:30 PM

Based on the feedback I have received form Mehdi, I am going to abandon this revision and go refactor this so it makes more sense. Thanks for the feedback Mehdi!