Skip to content

Commit

Permalink
Docker compose with test script for local testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
peteradrichem committed Jan 4, 2025
1 parent 9cb1e40 commit a300985
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# syntax=docker/dockerfile:1
FROM python:3.9-slim-bullseye AS test

LABEL org.opencontainers.image.authors="[email protected]"
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 ./
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:

test:
container_name: xul-test
build:
target: test

command: ./test.sh
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ line_length = 100

[tool.mypy]
cache_dir = "/tmp/.mypy_cache"
exclude = ["^docs/"]
exclude = ["^docs/", "^build/"]
pretty = true

[tool.ruff]
Expand Down
23 changes: 23 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit a300985

Please sign in to comment.