Commit f940911d authored by Noé Gaumont's avatar Noé Gaumont 🐙
Browse files

fix: remove MATRIX and ALIASES

parent c220f416812d
...@@ -6,6 +6,13 @@ import sys ...@@ -6,6 +6,13 @@ import sys
import logging import logging
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional, List from typing import Optional, List
from itertools import product
LOG = logging.getLogger(__name__)
REGISTRY = 'logilab/cubicweb'
CWREPO = 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/'
@dataclass @dataclass
class CubicWebImage: class CubicWebImage:
...@@ -23,10 +30,11 @@ class CubicWebImage: ...@@ -23,10 +30,11 @@ class CubicWebImage:
return self.cubicweb_version.rsplit('.', 1)[0] return self.cubicweb_version.rsplit('.', 1)[0]
def __le__(self, other): def __le__(self, other):
lversion = self.cubicweb_version.split(".") lversion = [int(v) for v in self.cubicweb_version.split(".")]
rversion = other.cubicweb_version.split(".") rversion = [int(v) for v in other.cubicweb_version.split(".")]
return lversion <= rversion return lversion <= rversion
def __gt__(self, other): def __gt__(self, other):
return not self <= other return not self <= other
...@@ -47,26 +55,6 @@ class CubicWebImage: ...@@ -47,26 +55,6 @@ class CubicWebImage:
return f"{REGISTRY}:{self.base_docker_image}-{self.cubicweb_major_version}" return f"{REGISTRY}:{self.base_docker_image}-{self.cubicweb_major_version}"
LOG = logging.getLogger(__name__)
REGISTRY = 'logilab/cubicweb'
CWREPO = 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/'
MATRIX = [
# (['py27'], ['stretch', 'buster'], [None, '3.25', '3.26'],
# [None, 'onbuild']),
# (['py35'], ['stretch'], [None, '3.26', '3.27'], [None, 'onbuild']),
(['py37'], ['buster'], ['3.29'], [None, 'onbuild']),
]
ALIASES = (
# ('3.25', 'py27-buster-3.25'),
# ('3.26', 'py37-buster-3.26'),
# ('3.27', 'py37-buster-3.27'),
# ('3.28', 'py37-buster-3.28'),
('3.29', 'py37-buster-3.29'),
# ('dev', 'py37-buster-dev'),
# ('latest', 'py37-buster-3.29'),
('buildpackage', 'buster-buildpackage'),
)
def run(*args): def run(*args):
LOG.info('%s', ' '.join(args)) LOG.info('%s', ' '.join(args))
...@@ -93,13 +81,15 @@ def _cwdev(_cache={}): ...@@ -93,13 +81,15 @@ def _cwdev(_cache={}):
def get_major_tags(images: List[CubicWebImage]): def get_major_tags(images: List[CubicWebImage]):
latest = {} latest = {}
for cwimage in [img for img in images if img.package_version != 'dev']: for cwimage in images:
if cwimage.package_version == 'dev':
continue
version = cwimage.cubicweb_major_version version = cwimage.cubicweb_major_version
if version not in latest: if version not in latest:
latest[version] = cwimage latest[version] = cwimage
else: elif latest[version] <= cwimage:
if latest[version] <= cwimage: latest[version] = cwimage
latest[version] = cwimage
last_major = max(latest.values()) last_major = max(latest.values())
latest['latest'] = last_major latest['latest'] = last_major
return latest return latest
...@@ -121,7 +111,7 @@ def tag_aliases(images: List[CubicWebImage], last_debian_dist: str): ...@@ -121,7 +111,7 @@ def tag_aliases(images: List[CubicWebImage], last_debian_dist: str):
check_call('docker', 'tag', f'{REGISTRY}:{last_debian_dist}-buildpackage', f"{REGISTRY}:buildpackage") check_call('docker', 'tag', f'{REGISTRY}:{last_debian_dist}-buildpackage', f"{REGISTRY}:buildpackage")
def build_image(image: CubicWebImage, onbuild: Optional[str], no_cache=False, registry=None): def build_image(image: CubicWebImage, onbuild: Optional[str], no_cache=False):
args = {} args = {}
dockerfile = 'Dockerfile' dockerfile = 'Dockerfile'
if onbuild is not None: if onbuild is not None:
...@@ -169,38 +159,37 @@ def build_buildpackage(dist): ...@@ -169,38 +159,37 @@ def build_buildpackage(dist):
def get_cubicweb_images(debian_dists: List[str], python_versions: List[str]): def get_cubicweb_images(debian_dists: List[str], python_versions: List[str]):
images = [] images = []
for dist in debian_dists: for dist, python_version in product(debian_dists, python_versions):
for python_version in python_versions: python = 'python' if python_version == 'py27' else 'python3'
python = 'python' if python_version == 'py27' else 'python3' check_call(
check_call( 'docker',
'docker', 'build',
'build', '.',
'.', '-f',
'-f', 'Dockerfile.getversion',
'Dockerfile.getversion', '-t',
'-t', 'cubicweb:getversion',
'cubicweb:getversion', '--build-arg',
'--build-arg', f'DIST={dist}',
f'DIST={dist}', '--build-arg',
'--build-arg', f"PYTHON={python}"
f"PYTHON={python}" )
versions = check_output(
'docker', 'run', '--rm', 'cubicweb:getversion'
).splitlines()
# filter release candidate version
valid_versions = [
version for version in versions if '~rc' not in version
]
for version in valid_versions:
image = CubicWebImage(
python=python_version,
debian=dist,
package_name=f'{python}-cubicweb',
package_version=version
) )
versions = check_output( images.append(image)
'docker', 'run', '--rm', 'cubicweb:getversion'
).splitlines()
# filter release candidate version
valid_versions = [
version for version in versions if '~rc' not in version
]
for version in valid_versions:
image = CubicWebImage(
python=python_version,
debian=dist,
package_name=f'{python}-cubicweb',
package_version=version
)
images.append(image)
return images return images
def build(debian_dists: List[str], images: List[CubicWebImage]=[], rebuild=False): def build(debian_dists: List[str], images: List[CubicWebImage]=[], rebuild=False):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment