GitLab cache
This commit is contained in:
parent
4f405a8709
commit
47db32ad0c
@ -11,7 +11,11 @@ test:
|
||||
build:
|
||||
stage: test
|
||||
image: yourlabs/podctl
|
||||
script: pip install . && podctl build
|
||||
script: pip install . && CACHE_DIR=$(pwd)/.cache podctl build
|
||||
cache:
|
||||
paths:
|
||||
- .cache
|
||||
key: cache
|
||||
|
||||
pypi:
|
||||
stage: deploy
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
@ -42,11 +43,11 @@ class Packages:
|
||||
raise Exception('Packages does not yet support this distro')
|
||||
|
||||
def build(self, script):
|
||||
cache = f'.cache/{self.mgr}'
|
||||
script.mount(
|
||||
'$(pwd)/' + cache,
|
||||
f'/var/cache/{self.mgr}'
|
||||
)
|
||||
if 'CACHE_DIR' in os.environ:
|
||||
cache = os.path.join(os.getenv('CACHE_DIR'), self.mgr)
|
||||
else:
|
||||
cache = os.path.join(os.getenv('HOME'), '.cache', self.mgr)
|
||||
script.mount(cache, f'/var/cache/{self.mgr}')
|
||||
|
||||
if self.mgr == 'apk':
|
||||
# special step to enable apk cache
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
import os
|
||||
|
||||
|
||||
class Pip:
|
||||
def __init__(self, *pip_packages, pip=None):
|
||||
self.pip_packages = pip_packages
|
||||
@ -16,7 +19,11 @@ class Pip:
|
||||
_pip=pip2
|
||||
fi
|
||||
''')
|
||||
script.mount('.cache/pip', '/root/.cache/pip')
|
||||
if 'CACHE_DIR' in os.environ:
|
||||
cache = os.path.join(os.getenv('CACHE_DIR'), 'pip')
|
||||
else:
|
||||
cache = os.path.join(os.getenv('HOME'), '.cache', 'pip')
|
||||
script.mount(cache, '/root/.cache/pip')
|
||||
script.run('sudo $_pip install --upgrade pip')
|
||||
source = [p for p in self.pip_packages if p.startswith('/')]
|
||||
if source:
|
||||
|
||||
@ -16,6 +16,8 @@ from unittest import mock
|
||||
from podctl.visitors import packages
|
||||
packages.subprocess.check_call = mock.Mock()
|
||||
|
||||
os.environ['CACHE_DIR'] = '/test'
|
||||
|
||||
|
||||
def script_test(name, *visitors):
|
||||
result = str(Container(*visitors).script('build'))
|
||||
|
||||
@ -16,8 +16,8 @@ mnt=$(buildah mount $ctr)
|
||||
echo "Packages.pre_build"
|
||||
echo "Packages.build"
|
||||
buildah run --user root $ctr -- mkdir -p /var/cache/apk
|
||||
mkdir -p $(pwd)/.cache/apk
|
||||
mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk
|
||||
mkdir -p /test/apk
|
||||
mount -o bind /test/apk $mnt/var/cache/apk
|
||||
mounts=("$mnt/var/cache/apk" "${mounts[@]}")
|
||||
buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache
|
||||
old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)"
|
||||
|
||||
@ -19,8 +19,8 @@ echo "Packages.pre_build"
|
||||
echo "User.pre_build"
|
||||
echo "Packages.build"
|
||||
buildah run --user root $ctr -- mkdir -p /var/cache/apk
|
||||
mkdir -p $(pwd)/.cache/apk
|
||||
mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk
|
||||
mkdir -p /test/apk
|
||||
mount -o bind /test/apk $mnt/var/cache/apk
|
||||
mounts=("$mnt/var/cache/apk" "${mounts[@]}")
|
||||
buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache
|
||||
old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user