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
|
get_versions="docker run --rm
|
||||||
--entrypoint=/code/.tox/py27/bin/python
|
--entrypoint=/code/.tox/py27/bin/python
|
||||||
$TAG
|
$TAG
|
||||||
/code/script/test/versions.py docker/docker"
|
/code/script/test/versions.py docker/docker-ce,moby/moby"
|
||||||
|
|
||||||
if [ "$DOCKER_VERSIONS" == "" ]; then
|
if [ "$DOCKER_VERSIONS" == "" ]; then
|
||||||
DOCKER_VERSIONS="$($get_versions default)"
|
DOCKER_VERSIONS="$($get_versions default)"
|
||||||
|
|
|
@ -37,14 +37,22 @@ import requests
|
||||||
GITHUB_API = 'https://api.github.com/repos'
|
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
|
@classmethod
|
||||||
def parse(cls, version):
|
def parse(cls, version):
|
||||||
|
edition = None
|
||||||
version = version.lstrip('v')
|
version = version.lstrip('v')
|
||||||
version, _, rc = version.partition('-')
|
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)
|
major, minor, patch = version.split('.', 3)
|
||||||
return cls(major, minor, patch, rc)
|
return cls(major, minor, patch, rc, edition)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def major_minor(self):
|
def major_minor(self):
|
||||||
|
@ -61,7 +69,8 @@ class Version(namedtuple('_Version', 'major minor patch rc')):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
rc = '-{}'.format(self.rc) if self.rc else ''
|
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):
|
def group_versions(versions):
|
||||||
|
@ -94,6 +103,7 @@ def get_latest_versions(versions, num=1):
|
||||||
group.
|
group.
|
||||||
"""
|
"""
|
||||||
versions = group_versions(versions)
|
versions = group_versions(versions)
|
||||||
|
num = min(len(versions), num)
|
||||||
return [versions[index][0] for index in range(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)
|
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
|
"""Query the Github API for a list of version tags and return them in
|
||||||
sorted order.
|
sorted order.
|
||||||
|
|
||||||
See https://developer.github.com/v3/repos/#list-tags
|
See https://developer.github.com/v3/repos/#list-tags
|
||||||
"""
|
"""
|
||||||
url = '{}/{}/tags'.format(GITHUB_API, project)
|
versions = []
|
||||||
response = requests.get(url)
|
for project in projects:
|
||||||
response.raise_for_status()
|
url = '{}/{}/tags'.format(GITHUB_API, project)
|
||||||
versions = get_versions(response.json())
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
versions.extend(get_versions(response.json()))
|
||||||
return sorted(versions, reverse=True, key=operator.attrgetter('order'))
|
return sorted(versions, reverse=True, key=operator.attrgetter('order'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +148,7 @@ def parse_args(argv):
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
args = parse_args(argv)
|
args = parse_args(argv)
|
||||||
versions = get_github_releases(args.project)
|
versions = get_github_releases(args.project.split(','))
|
||||||
|
|
||||||
if args.command == 'recent':
|
if args.command == 'recent':
|
||||||
print(' '.join(map(str, get_latest_versions(versions, args.num))))
|
print(' '.join(map(str, get_latest_versions(versions, args.num))))
|
||||||
|
|
Loading…
Reference in New Issue