Title: [233088] trunk/Tools
Revision
233088
Author
ross.kirsl...@sony.com
Date
2018-06-22 12:08:28 -0700 (Fri, 22 Jun 2018)

Log Message

[WinCairo][Buildbot] Test bots should use same WinCairoRequirements version as the triggering build
https://bugs.webkit.org/show_bug.cgi?id=186857

Reviewed by Lucas Forschler.

* BuildSlaveSupport/built-product-archive:
(archiveBuiltProduct):
(extractBuiltProduct):
Save and restore the WinCairoRequirements version using the build archive.

* Scripts/download-github-release.py: Renamed from Tools/Scripts/download-latest-github-release.py.
Generalize download script -- get the latest version by default, but allow an arbitrary version to be specified.

* Scripts/update-vswhere.py:
Consume renamed script.

* Scripts/update-webkit-wincairo-libs.py:
Consume renamed script and specify a version to download when a config file is present.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/built-product-archive (233087 => 233088)


--- trunk/Tools/BuildSlaveSupport/built-product-archive	2018-06-22 18:32:45 UTC (rev 233087)
+++ trunk/Tools/BuildSlaveSupport/built-product-archive	2018-06-22 19:08:28 UTC (rev 233088)
@@ -220,6 +220,13 @@
 
         removeDirectoryIfExists(thinDirectory)
         copyBuildFiles(binDirectory, thinBinDirectory, ['*.ilk'])
+
+        # Save WinCairoRequirements version for test bot use
+        if platform == 'wincairo':
+            shutil.copy(
+                os.path.join(os.getenv('WEBKIT_LIBRARIES'), 'WinCairoRequirements.zip.version'),
+                os.path.join(thinDirectory, 'WinCairoRequirements.zip.config'))
+
         if createZip(thinDirectory, configuration):
             return 1
 
@@ -270,8 +277,13 @@
         return unzipArchive(_topLevelBuildDirectory, configuration)
     elif platform in ('win', 'gtk', 'wpe', 'wincairo'):
         print 'Extracting', _configurationBuildDirectory
-        return unzipArchive(_configurationBuildDirectory, configuration)
+        if unzipArchive(_configurationBuildDirectory, configuration)
+            return 1
 
+        # Restore WinCairoRequirements version for test bot use
+        if platform == 'wincairo':
+            shutil.move(os.path.join(_configurationBuildDirectory, 'WinCairoRequirements.zip.config'), os.getenv('WEBKIT_LIBRARIES'))
 
+
 if __name__ == '__main__':
     sys.exit(main())

Modified: trunk/Tools/ChangeLog (233087 => 233088)


--- trunk/Tools/ChangeLog	2018-06-22 18:32:45 UTC (rev 233087)
+++ trunk/Tools/ChangeLog	2018-06-22 19:08:28 UTC (rev 233088)
@@ -1,3 +1,24 @@
+2018-06-22  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        [WinCairo][Buildbot] Test bots should use same WinCairoRequirements version as the triggering build
+        https://bugs.webkit.org/show_bug.cgi?id=186857
+
+        Reviewed by Lucas Forschler.
+
+        * BuildSlaveSupport/built-product-archive:
+        (archiveBuiltProduct):
+        (extractBuiltProduct):
+        Save and restore the WinCairoRequirements version using the build archive.
+
+        * Scripts/download-github-release.py: Renamed from Tools/Scripts/download-latest-github-release.py.
+        Generalize download script -- get the latest version by default, but allow an arbitrary version to be specified.
+
+        * Scripts/update-vswhere.py:
+        Consume renamed script.
+
+        * Scripts/update-webkit-wincairo-libs.py:
+        Consume renamed script and specify a version to download when a config file is present.
+
 2018-06-20  Darin Adler  <da...@apple.com>
 
         [Cocoa] Use the isDirectory: variants of NSURL methods more to eliminate unnecessary file system activity

Copied: trunk/Tools/Scripts/download-github-release.py (from rev 233087, trunk/Tools/Scripts/download-latest-github-release.py) (0 => 233088)


--- trunk/Tools/Scripts/download-github-release.py	                        (rev 0)
+++ trunk/Tools/Scripts/download-github-release.py	2018-06-22 19:08:28 UTC (rev 233088)
@@ -0,0 +1,157 @@
+#! /usr/bin/env python
+#
+# Copyright (C) 2017 Sony Interactive Entertainment Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import argparse
+import json
+import os
+import sys
+import urllib2
+
+PUBLIC_GITHUB_API_ENDPOINT = 'https://api.github.com/'
+
+DESCRIPTION = '''Downloads a release binary from a GitHub repository.
+(Requests the latest release unless a specific tag is provided.)
+
+Intended for download of vswhere.exe and WinCairoRequirements.zip,
+but may be used for arbitrary binaries / repositories.
+
+Checks whether the desired version already exists in the output directory
+(by looking for a .version file saved alongside the release binary) --
+if so, download is skipped; otherwise any existing version is overwritten.
+'''
+
+
+class Status:
+    DOWNLOADED = 0
+    UP_TO_DATE = 1
+    COULD_NOT_FIND = 2
+    USING_EXISTING = 3
+
+
+def parse_args(argv):
+    parser = argparse.ArgumentParser(description=DESCRIPTION, formatter_class=argparse.RawDescriptionHelpFormatter)
+    parser.add_argument('repo', help='GitHub repository slug (e.g., "org/repo")')
+    parser.add_argument('filename', help='filename of release binary to download (e.g., "foo.exe", "bar.zip")')
+    parser.add_argument('-o', '--output-dir', default='.', help='output directory (defaults to working directory)')
+    parser.add_argument('-e', '--endpoint', default=PUBLIC_GITHUB_API_ENDPOINT, help='GitHub API endpoint (defaults to api.github.com)')
+    parser.add_argument('-t', '--token', default=None, help='GitHub API OAuth token (for private repos/endpoints)')
+    parser.add_argument('-r', '--release-tag', default=None, help='release tag to download (defaults to latest)')
+    return parser.parse_args(argv)
+
+
+def find_release(endpoint, repo, filename, token, tag):
+    release_name = 'tags/{}'.format(tag) if tag else 'latest'
+    url = ''.format(endpoint.rstrip('/'), repo, release_name)
+
+    request = urllib2.Request(url)
+    request.add_header('Accept', 'application/vnd.github.v3+json')
+    if token:
+        request.add_header('Authorization', 'token {}'.format(token))
+
+    try:
+        response = urllib2.urlopen(request)
+    except urllib2.URLError as error:
+        print(error)
+        return None, None
+
+    data = ""
+    for asset in data['assets']:
+        if asset['name'] == filename:
+            version_info = {'tag_name': data['tag_name'], 'updated_at': asset['updated_at']}
+            return asset['url'], version_info
+    return None, None
+
+
+def download_release(source_url, target_path, token):
+    request = urllib2.Request(source_url)
+    request.add_header('Accept', 'application/octet-stream')
+    if token:
+        request.add_header('Authorization', 'token {}'.format(token))
+
+    with open(target_path, 'wb') as file:
+        file.write(urllib2.urlopen(request).read())
+
+
+def load_version_info(version_info_path):
+    if not os.path.exists(version_info_path):
+        return None
+
+    with open(version_info_path) as file:
+        return json.load(file)
+
+
+def save_version_info(version_info_path, version_info):
+    with open(version_info_path, 'w') as file:
+        json.dump(version_info, file)
+
+
+def main(argv):
+    args = parse_args(argv)
+
+    binary_path = os.path.join(args.output_dir, args.filename)
+    version_info_path = binary_path + '.version'
+
+    print('Updating {}...'.format(args.filename))
+
+    existing_version_info = load_version_info(version_info_path)
+    if existing_version_info:
+        print('Found existing release: {}'.format(existing_version_info['tag_name']))
+    else:
+        print('No existing release found.')
+
+    release_title = 'release "{}"'.format(args.release_tag) if args.release_tag else 'latest release'
+    print('Seeking {} from {}...'.format(release_title, args.repo))
+    release_url, target_version_info = find_release(args.endpoint, args.repo, args.filename, args.token, args.release_tag)
+
+    if not target_version_info:
+        if existing_version_info:
+            print('Falling back to existing release!')
+            return Status.USING_EXISTING
+
+        print('No release found!')
+        return Status.COULD_NOT_FIND
+
+    print('Found release to download: {}'.format(target_version_info['tag_name']))
+
+    if target_version_info == existing_version_info:
+        print('Already up-to-date!')
+        return Status.UP_TO_DATE
+
+    if not os.path.exists(args.output_dir):
+        os.makedirs(args.output_dir)
+
+    print('Downloading to {}...'.format(os.path.abspath(args.output_dir)))
+    download_release(release_url, binary_path, args.token)
+    save_version_info(version_info_path, target_version_info)
+    print('Done!')
+
+    return Status.DOWNLOADED
+
+
+if __name__ == '__main__':
+    result = main(sys.argv[1:])
+
+    if result == Status.COULD_NOT_FIND:
+        sys.exit(1)

Deleted: trunk/Tools/Scripts/download-latest-github-release.py (233087 => 233088)


--- trunk/Tools/Scripts/download-latest-github-release.py	2018-06-22 18:32:45 UTC (rev 233087)
+++ trunk/Tools/Scripts/download-latest-github-release.py	2018-06-22 19:08:28 UTC (rev 233088)
@@ -1,153 +0,0 @@
-#! /usr/bin/env python
-#
-# Copyright (C) 2017 Sony Interactive Entertainment Inc.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 2.  Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import argparse
-import json
-import os
-import sys
-import urllib2
-
-PUBLIC_GITHUB_API_ENDPOINT = 'https://api.github.com/'
-
-DESCRIPTION = '''Downloads the latest release binary from a GitHub repository.
-
-Intended for download of vswhere.exe and WinCairoRequirements.zip,
-but may be used for arbitrary binaries / repositories.
-
-Checks whether the latest version already exists in the output directory
-(by looking for a .version file saved alongside the release binary) --
-if so, download is skipped; otherwise any existing version is overwritten.
-'''
-
-
-class Status:
-    DOWNLOADED = 0
-    UP_TO_DATE = 1
-    COULD_NOT_FIND = 2
-    USING_EXISTING = 3
-
-
-def parse_args(argv):
-    parser = argparse.ArgumentParser(description=DESCRIPTION, formatter_class=argparse.RawDescriptionHelpFormatter)
-    parser.add_argument('repo', help='GitHub repository slug (e.g., "org/repo")')
-    parser.add_argument('filename', help='filename of release binary to download (e.g., "foo.exe", "bar.zip")')
-    parser.add_argument('-o', '--output-dir', default='.', help='output directory (defaults to working directory)')
-    parser.add_argument('-e', '--endpoint', default=PUBLIC_GITHUB_API_ENDPOINT, help='GitHub API endpoint (defaults to api.github.com)')
-    parser.add_argument('-t', '--token', default=None, help='GitHub API OAuth token (for private repos/endpoints)')
-    return parser.parse_args(argv)
-
-
-def find_latest_release(endpoint, repo, filename, token):
-    url = ''.format(endpoint.rstrip('/'), repo)
-
-    request = urllib2.Request(url)
-    request.add_header('Accept', 'application/vnd.github.v3+json')
-    if token:
-        request.add_header('Authorization', 'token {}'.format(token))
-
-    try:
-        response = urllib2.urlopen(request)
-    except urllib2.URLError as error:
-        print(error)
-        return None, None
-
-    data = ""
-    for asset in data['assets']:
-        if asset['name'] == filename:
-            version_info = {'tag_name': data['tag_name'], 'updated_at': asset['updated_at']}
-            return asset['url'], version_info
-    return None, None
-
-
-def download_release(source_url, target_path, token):
-    request = urllib2.Request(source_url)
-    request.add_header('Accept', 'application/octet-stream')
-    if token:
-        request.add_header('Authorization', 'token {}'.format(token))
-
-    with open(target_path, 'wb') as file:
-        file.write(urllib2.urlopen(request).read())
-
-
-def load_version_info(version_info_path):
-    if not os.path.exists(version_info_path):
-        return None
-
-    with open(version_info_path) as file:
-        return json.load(file)
-
-
-def save_version_info(version_info_path, version_info):
-    with open(version_info_path, 'w') as file:
-        json.dump(version_info, file)
-
-
-def main(argv):
-    args = parse_args(argv)
-
-    binary_path = os.path.join(args.output_dir, args.filename)
-    version_info_path = binary_path + '.version'
-
-    print('Updating {}...'.format(args.filename))
-
-    existing_version_info = load_version_info(version_info_path)
-    if existing_version_info:
-        print('Found existing release: {}'.format(existing_version_info['tag_name']))
-    else:
-        print('No existing release found.')
-
-    print('Seeking latest release from {}...'.format(args.repo))
-    release_url, latest_version_info = find_latest_release(args.endpoint, args.repo, args.filename, args.token)
-
-    if not latest_version_info:
-        if existing_version_info:
-            print('Falling back to existing release!')
-            return Status.USING_EXISTING
-
-        print('No release found!')
-        return Status.COULD_NOT_FIND
-
-    print('Found latest release: {}'.format(latest_version_info['tag_name']))
-
-    if latest_version_info == existing_version_info:
-        print('Already up-to-date!')
-        return Status.UP_TO_DATE
-
-    if not os.path.exists(args.output_dir):
-        os.makedirs(args.output_dir)
-
-    print('Downloading to {}...'.format(os.path.abspath(args.output_dir)))
-    download_release(release_url, binary_path, args.token)
-    save_version_info(version_info_path, latest_version_info)
-    print('Done!')
-
-    return Status.DOWNLOADED
-
-
-if __name__ == '__main__':
-    result = main(sys.argv[1:])
-
-    if result == Status.COULD_NOT_FIND:
-        sys.exit(1)

Modified: trunk/Tools/Scripts/update-vswhere.py (233087 => 233088)


--- trunk/Tools/Scripts/update-vswhere.py	2018-06-22 18:32:45 UTC (rev 233087)
+++ trunk/Tools/Scripts/update-vswhere.py	2018-06-22 19:08:28 UTC (rev 233088)
@@ -28,7 +28,7 @@
 import os
 import stat
 
-download = importlib.import_module('download-latest-github-release')
+download = importlib.import_module('download-github-release')
 
 repo = 'Microsoft/vswhere'
 file = 'vswhere.exe'

Modified: trunk/Tools/Scripts/update-webkit-wincairo-libs.py (233087 => 233088)


--- trunk/Tools/Scripts/update-webkit-wincairo-libs.py	2018-06-22 18:32:45 UTC (rev 233087)
+++ trunk/Tools/Scripts/update-webkit-wincairo-libs.py	2018-06-22 19:08:28 UTC (rev 233088)
@@ -24,18 +24,26 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import importlib
+import json
 import os.path
 import sys
 import zipfile
 
-download = importlib.import_module('download-latest-github-release')
+download = importlib.import_module('download-github-release')
 
 repo = 'WebKitForWindows/WinCairoRequirements'
 file = 'WinCairoRequirements.zip'
 output = 'WebKitLibraries/win'
+options = [repo, file, '-o', output]
 
-result = download.main(['-o', output, repo, file])
+# Check if there's a specific version to request
+config_path = os.path.join(output, file) + '.config'
+if os.path.exists(config_path):
+    with open(config_path) as config_file:
+        options += ['-r', json.load(config_file)['tag_name']]
 
+result = download.main(options)
+
 # Only unzip if required
 if result == download.Status.DOWNLOADED:
     print('Extracting release to {}...'.format(output))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to