mirror of https://github.com/docker/compose.git
Take editions into account when selecting test engine versions
Get candidates from moby/moby and docker/docker-ce repos Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
e8e2eb6e59
commit
821bd54663
|
@ -14,7 +14,7 @@ docker run --rm \
|
|||
get_versions="docker run --rm
|
||||
--entrypoint=/code/.tox/py27/bin/python
|
||||
$TAG
|
||||
/code/script/test/versions.py docker/docker"
|
||||
/code/script/test/versions.py docker/docker-ce,moby/moby"
|
||||
|
||||
if [ "$DOCKER_VERSIONS" == "" ]; then
|
||||
DOCKER_VERSIONS="$($get_versions default)"
|
||||
|
|
|
@ -37,14 +37,22 @@ import requests
|
|||
GITHUB_API = 'https://api.github.com/repos'
|
||||
|
||||
|
||||
class Version(namedtuple('_Version', 'major minor patch rc')):
|
||||
class Version(namedtuple('_Version', 'major minor patch rc edition')):
|
||||
|
||||
@classmethod
|
||||
def parse(cls, version):
|
||||
edition = None
|
||||
version = version.lstrip('v')
|
||||
version, _, rc = version.partition('-')
|
||||
if rc:
|
||||
if 'rc' not in rc:
|
||||
edition = rc
|
||||
rc = None
|
||||
elif '-' in rc:
|
||||
edition, rc = rc.split('-')
|
||||
|
||||
major, minor, patch = version.split('.', 3)
|
||||
return cls(major, minor, patch, rc)
|
||||
return cls(major, minor, patch, rc, edition)
|
||||
|
||||
@property
|
||||
def major_minor(self):
|
||||
|
@ -61,7 +69,8 @@ class Version(namedtuple('_Version', 'major minor patch rc')):
|
|||
|
||||
def __str__(self):
|
||||
rc = '-{}'.format(self.rc) if self.rc else ''
|
||||
return '.'.join(map(str, self[:3])) + rc
|
||||
edition = '-{}'.format(self.edition) if self.edition else ''
|
||||
return '.'.join(map(str, self[:3])) + edition + rc
|
||||
|
||||
|
||||
def group_versions(versions):
|
||||
|
@ -94,6 +103,7 @@ def get_latest_versions(versions, num=1):
|
|||
group.
|
||||
"""
|
||||
versions = group_versions(versions)
|
||||
num = min(len(versions), num)
|
||||
return [versions[index][0] for index in range(num)]
|
||||
|
||||
|
||||
|
@ -112,16 +122,18 @@ def get_versions(tags):
|
|||
print("Skipping invalid tag: {name}".format(**tag), file=sys.stderr)
|
||||
|
||||
|
||||
def get_github_releases(project):
|
||||
def get_github_releases(projects):
|
||||
"""Query the Github API for a list of version tags and return them in
|
||||
sorted order.
|
||||
|
||||
See https://developer.github.com/v3/repos/#list-tags
|
||||
"""
|
||||
url = '{}/{}/tags'.format(GITHUB_API, project)
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
versions = get_versions(response.json())
|
||||
versions = []
|
||||
for project in projects:
|
||||
url = '{}/{}/tags'.format(GITHUB_API, project)
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
versions.extend(get_versions(response.json()))
|
||||
return sorted(versions, reverse=True, key=operator.attrgetter('order'))
|
||||
|
||||
|
||||
|
@ -136,7 +148,7 @@ def parse_args(argv):
|
|||
|
||||
def main(argv=None):
|
||||
args = parse_args(argv)
|
||||
versions = get_github_releases(args.project)
|
||||
versions = get_github_releases(args.project.split(','))
|
||||
|
||||
if args.command == 'recent':
|
||||
print(' '.join(map(str, get_latest_versions(versions, args.num))))
|
||||
|
|
Loading…
Reference in New Issue