-
Notifications
You must be signed in to change notification settings - Fork 3
/
tasks.py
32 lines (24 loc) · 893 Bytes
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pathlib import Path
from invoke import Context, task
ROOT = Path(__file__).parent.resolve()
@task
def testclean(ctx: Context):
"""
Cleans up leftover test containers.
Container cleanup is normally done in test fixtures.
This is skipped if debugged tests are stopped halfway.
"""
result = ctx.run('docker ps -aq --filter "name=pytest"', hide='stdout')
containers = result.stdout.strip().replace('\n', ' ')
if containers:
ctx.run(f'docker rm -f {containers}')
@task
def build(ctx: Context):
with ctx.cd(ROOT):
ctx.run('rm -rf dist')
ctx.run('poetry build --format sdist')
ctx.run('poetry export --without-hashes -f requirements.txt -o dist/requirements.txt')
@task(pre=[build])
def image(ctx: Context, tag='local'):
with ctx.cd(ROOT):
ctx.run(f'docker build -t ghcr.io/brewblox/brewblox-tilt:{tag} .')