From a300985586ca3a9bc6e941840cabfbcac20fc821 Mon Sep 17 00:00:00 2001 From: Peter Adrichem Date: Sat, 4 Jan 2025 16:37:15 +0100 Subject: [PATCH] Docker compose with test script for local testing. --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker-compose.yml | 8 ++++++++ pyproject.toml | 2 +- test.sh | 23 +++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 test.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1652952 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# syntax=docker/dockerfile:1 +FROM python:3.9-slim-bullseye AS test + +LABEL org.opencontainers.image.authors="Peter.Adrichem@gmail.com" +LABEL description="Xul Dockerfile" +LABEL version="1.0" + +# Packages. +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get install --no-install-recommends -y \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* /var/cache/debconf/*-old + +ENV PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1 + +# Recent pip, setuptools and wheel. +RUN pip install --upgrade pip setuptools wheel + +# Create workdir +WORKDIR /app + +# Install package. +COPY pyproject.toml ./ +COPY src src +COPY docs docs +RUN pip install .[test] + +# Copy test script. +COPY test.sh ./ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d002674 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + + test: + container_name: xul-test + build: + target: test + + command: ./test.sh diff --git a/pyproject.toml b/pyproject.toml index 017571f..bef1a1a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ line_length = 100 [tool.mypy] cache_dir = "/tmp/.mypy_cache" -exclude = ["^docs/"] +exclude = ["^docs/", "^build/"] pretty = true [tool.ruff] diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..be80d38 --- /dev/null +++ b/test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -u # crash on missing env +set -e # stop on any error + +echo() { + builtin echo -e "$@" +} + + +echo "Lint checks (Ruff)" +ruff check --diff + +echo "\nCheck import sort (isort)" +isort --check --diff . + +echo "\nCheck formatting (Black)" +black --check --diff . + +echo "\nCheck typing (mypy)" +mypy . + +echo "\nChecks complete"