From 857812a58c6e5077de61a5201f67c8859cb55e92 Mon Sep 17 00:00:00 2001 From: Yanis Rigaudeau Date: Fri, 22 Sep 2023 00:21:35 +0200 Subject: [PATCH] add test stage --- .drone.yml | 13 +++++++++++-- Dockerfile | 24 +++++++++++++++++------- docker-compose.yml | 5 ++++- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index d005122..c3c0f16 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ kind: pipeline type: docker -name: default +name: dj-embe steps: - name: check @@ -12,7 +12,16 @@ steps: commands: - docker build --target check . - - name: build + - name: test + image: docker:24.0.6-cli + privileged: true + volumes: + - name: docker-socket + path: /var/run/docker.sock + commands: + - docker build --target test . + + - name: deploy image: docker/compose:alpine-1.29.2 privileged: true volumes: diff --git a/Dockerfile b/Dockerfile index 89fe069..e6fc120 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,33 +5,43 @@ RUN --mount=type=cache,target=/var/cache/apk \ -FROM core as check +FROM core as build WORKDIR /app RUN --mount=type=cache,target=/root/.cache/pip \ pip install poethepoet -COPY ./poetry.lock ./pyproject.toml poetry.toml ./ +COPY ./poetry.lock ./pyproject.toml ./poetry.toml ./ -RUN --mount=type=cache,target=/root/.cache/pypoetry\ +RUN --mount=type=cache,target=/root/.cache/pypoetry \ poetry install --sync COPY ./test ./test COPY ./dj-embe ./dj-embe + + +FROM build as check + RUN poe lint -#RUN poe test -FROM core as build +FROM build as test + +RUN poe test + + + +FROM core as run WORKDIR /app -COPY ./poetry.lock ./pyproject.toml poetry.toml ./ +COPY ./poetry.lock ./pyproject.toml ./poetry.toml ./ COPY ./dj-embe ./dj-embe -RUN poetry install --without dev --sync +RUN --mount=type=cache,target=/root/.cache/pypoetry \ + poetry install --without dev --sync CMD poetry run python dj-embe diff --git a/docker-compose.yml b/docker-compose.yml index be02632..3a6462a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,10 @@ services: - apps build: context: . - target: build + target: run + volumes: + - /tmp/dj-embe/config.toml:/app/config.toml:ro + - /tmp/dj-embe/download:/download:rw networks: apps: