From fe70c69b0c0a0c50328bd1b1c0c027565dedf666 Mon Sep 17 00:00:00 2001 From: jpic Date: Sun, 16 Feb 2020 18:39:50 +0100 Subject: [PATCH] Update shlax in shlax --- shlax/actions/__init__.py | 1 - shlax/actions/commit.py | 87 --------------------------------------- shlaxfile.py | 4 +- 3 files changed, 2 insertions(+), 90 deletions(-) delete mode 100644 shlax/actions/commit.py diff --git a/shlax/actions/__init__.py b/shlax/actions/__init__.py index 7519565..44accfa 100644 --- a/shlax/actions/__init__.py +++ b/shlax/actions/__init__.py @@ -1,4 +1,3 @@ -from .commit import Commit from .copy import Copy from .packages import Packages # noqa from .base import Action # noqa diff --git a/shlax/actions/commit.py b/shlax/actions/commit.py deleted file mode 100644 index ee6dd55..0000000 --- a/shlax/actions/commit.py +++ /dev/null @@ -1,87 +0,0 @@ -import os -import subprocess - -from .base import Action - -from ..exceptions import WrongResult - -CI_VARS = ( - # gitlab - 'CI_COMMIT_SHORT_SHA', - 'CI_COMMIT_REF_NAME', - 'CI_COMMIT_TAG', - # CircleCI - 'CIRCLE_SHA1', - 'CIRCLE_TAG', - 'CIRCLE_BRANCH', -) - - -class Commit(Action): - def __init__(self, repo, tags=None, format=None, push=None, registry=None): - self.repo = repo - self.registry = registry or 'localhost' - self.push = push or os.getenv('CI') - - # figure out registry host - if '/' in self.repo and not registry: - first = self.repo.split('/')[0] - if '.' in first or ':' in first: - self.registry = self.repo.split('/')[0] - - # docker.io currently has issues with oci format - self.format = format or 'oci' - if self.registry == 'docker.io': - self.format = 'docker' - - self.tags = tags or [] - - # figure tags from CI vars - if not self.tags: - for name in CI_VARS: - value = os.getenv(name) - if value: - self.tags.append(value) - - # filter out tags which resolved to None - self.tags = [t for t in self.tags if t is not None] - - # default tag by default ... - if not self.tags: - self.tags = ['latest'] - - async def call(self, *args, ctr=None, **kwargs): - self.sha = (await self.parent.parent.exec( - 'buildah', - 'commit', - '--format=' + self.format, - ctr, - )).out - - if 'master' in self.tags: - self.tags.append('latest') - - if self.tags: - tags = ' '.join([f'{self.repo}:{tag}' for tag in self.tags]) - await script.exec('buildah', 'tag', self.sha, self.repo, tags) - - if self.push: - user = os.getenv('DOCKER_USER') - passwd = os.getenv('DOCKER_PASS') - if user and passwd and os.getenv('CI') and self.registry: - await script.exec( - 'podman', - 'login', - '-u', - user, - '-p', - passwd, - self.registry, - ) - - for tag in self.tags: - await script.exec('podman', 'push', f'{self.repo}:{tag}') - await script.umount() - - def __repr__(self): - return f'Commit({self.registry}/{self.repo}:{self.tags})' diff --git a/shlaxfile.py b/shlaxfile.py index 26f7a36..004530d 100755 --- a/shlaxfile.py +++ b/shlaxfile.py @@ -38,12 +38,12 @@ gitlabci = GitLabCI( build=dict( stage='build', image='yourlabs/shlax', - script='CACHE_DIR=$(pwd)/.cache ./shlaxfile.py -d shlax build push', + script='pip install -U --user -e . && CACHE_DIR=$(pwd)/.cache ./shlaxfile.py -d shlax build push', cache=dict(paths=['.cache'], key='cache'), ), test=dict( stage='test', - script='./shlaxfile.py -d test', + script='pip install -U --user -e . && ./shlaxfile.py -d test', image=build, ), pypi=dict(