diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6ab1710..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM python:alpine AS base - -RUN \ - --mount=type=cache,target=/var/cache/apk \ - apk add -U make - -WORKDIR /app \ No newline at end of file diff --git a/Makefile b/Makefile index 9391a51..c39ce93 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,19 @@ +SRC := spiff_element_units +TESTS := tests + DEV_SERVICE := dev +MY_USER := $(shell id -u) +MY_GROUP := $(shell id -g) +ME := $(MY_USER):$(MY_GROUP) +AS_ME := docker compose run -u $(ME) $(DEV_SERVICE) + .PHONY: all all: dev-env dev-env: docker compose build --progress=plain $(DEV_SERVICE) + +.PHONY: tests +tests: + $(AS_ME) unittest-parallel -vs $(TESTS) -p test_*.py -t . diff --git a/dev/Dockerfile b/dev/Dockerfile new file mode 100644 index 0000000..a5f68b6 --- /dev/null +++ b/dev/Dockerfile @@ -0,0 +1,13 @@ +FROM python:alpine AS base + +RUN \ + --mount=type=cache,target=/var/cache/apk \ + apk add -U make + +RUN python -m pip install --upgrade pip + +WORKDIR /app + +COPY dev/requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt \ No newline at end of file diff --git a/dev/requirements.txt b/dev/requirements.txt new file mode 100644 index 0000000..f70d4d2 --- /dev/null +++ b/dev/requirements.txt @@ -0,0 +1 @@ +unittest-parallel == 1.5.3 diff --git a/docker-compose.yml b/docker-compose.yml index 6cf909f..32e99f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,4 +2,8 @@ services: dev: container_name: spiff-element-units-dev build: - dockerfile: Dockerfile \ No newline at end of file + context: . + dockerfile: dev/Dockerfile + volumes: + - ./spiff_element_units:/app/spiff_element_units + - ./tests:/app/tests \ No newline at end of file diff --git a/spiff_element_units/__init__.py b/spiff_element_units/__init__.py index e69de29..feb40fd 100644 --- a/spiff_element_units/__init__.py +++ b/spiff_element_units/__init__.py @@ -0,0 +1,2 @@ +def this_returns_true(): + return True diff --git a/tests/test_sanity.py b/tests/test_sanity.py new file mode 100644 index 0000000..69ec81f --- /dev/null +++ b/tests/test_sanity.py @@ -0,0 +1,7 @@ +from unittest import TestCase + +from spiff_element_units import this_returns_true + +class SanityTest(TestCase): + def test_it_returns_true(self): + assert this_returns_true()