diff --git a/script/test/all b/script/test/all index 7151a75e1..0c6ea6065 100755 --- a/script/test/all +++ b/script/test/all @@ -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)" diff --git a/script/test/versions.py b/script/test/versions.py index 97383ad99..46872ed9a 100755 --- a/script/test/versions.py +++ b/script/test/versions.py @@ -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))))