Skip to content

Instantly share code, notes, and snippets.

@Viranchee
Last active September 6, 2023 19:54
Show Gist options
  • Save Viranchee/04edb1fa8fcb1ef535dbceb8f2697941 to your computer and use it in GitHub Desktop.
Save Viranchee/04edb1fa8fcb1ef535dbceb8f2697941 to your computer and use it in GitHub Desktop.
Swift-timeline-test
import urllib.request
import datetime
import os
import subprocess
# path = "/Volumes/vissd/SWIFT_NIGHTLIES/"
path = "/Users/viranchee/SWIFT_NIGHTLIES/"
swift_version = "5.4.1"
start_date = datetime.date(2021, 1,1) # 2021,05,29 : Last swift 5.5 downloaded
end_date = datetime.date(2022, 12, 31)
advance_days = 1
def url_downloader(url, save_path, file_name):
# Download the file from URL, save it to save_path with name file_name
request = urllib.request.Request(url)
request.get_method = lambda: 'HEAD'
try:
response = urllib.request.urlopen(request)
print("Downloading file: " + file_name)
urllib.request.urlretrieve(url, save_path + file_name)
return True
except urllib.error.HTTPError:
print("File: " + file_name + " does not exist!")
return False
except urllib.error.URLError:
print("File: " + file_name + " does not exist!!")
return False
def downloadSwiftNightly(date, swift_version, save_path):
file_name = "swift-" + swift_version + "-DEVELOPMENT-SNAPSHOT-" + date + "-a-osx.pkg"
url = "https://download.swift.org/swift-" + swift_version + "-branch/xcode/swift-" + swift_version + "-DEVELOPMENT-SNAPSHOT-" + date + "-a/swift-" + swift_version + "-DEVELOPMENT-SNAPSHOT-" + date + "-a-osx.pkg"
return url_downloader(url, save_path, file_name)
def downloadSwiftRelease(swift_version, save_path):
# url = https://download.swift.org/swift-5.8.1-release/xcode/swift-5.8.1-RELEASE/swift-5.8.1-RELEASE-osx.pkg
file_name = "swift-" + swift_version + "-RELEASE-osx.pkg"
url = "https://download.swift.org/swift-" + swift_version + "-release/xcode/swift-" + swift_version + "-RELEASE/" + file_name
return url_downloader(url, save_path, file_name)
# Download Swift Nightlies for Swift 5.4
def downloadManyNightlies(start_date, end_date, swift_version, path):
date = start_date
while date <= end_date:
downloaded = downloadSwiftNightly(date.strftime("%Y-%m-%d"), swift_version, path)
if downloaded == True:
extra_add = advance_days
else:
extra_add = 1
date += datetime.timedelta(days=extra_add)
def toolchain_installer(path):
for filename in os.listdir(path):
if filename.endswith(".pkg"):
print("Installing: " + filename)
subprocess.call(["sudo", "installer", "-pkg", path + filename, "-target", "/"])
def toolchain_run_test(path, argument):
toolchain_dir = "/Library/Developer/Toolchains/"
for filename in os.listdir(path):
if filename.endswith(".pkg"):
toolchain_name = filename[:-8] + ".xctoolchain"
cmd = toolchain_dir + toolchain_name + "/usr/bin/swift " + argument
print(cmd)
subprocess.call(cmd, shell=True)
# downloadManyNightlies(start_date, end_date, swift_version, path)
downloadSwiftRelease("5.4.1", path)
downloadSwiftRelease("5.4.2", path)
downloadSwiftRelease("5.4.3", path)
toolchain_installer(path)
toolchain_run_test(path, "/Users/viranchee/appleSwift/swift/test/AutoDiff/compiler_crashers_fixed/rdar71319547-generated-decls-shall-not-be-resilient.swift")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment