commit 9bad2724b1e793c44104442c725e1af372843a58 Author: Benjamin Renard Date: Thu Jan 19 14:43:06 2023 +0100 Initial release diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1df9b95 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +# Pre-commit hooks to run tests and ensure code is cleaned. +# See https://pre-commit.com for more information +repos: +#- repo: local +# hooks: +# - id: pytest +# name: pytest +# entry: python3 -m pytest tests +# language: system +# types: [python] +# pass_filenames: false +- repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + require_serial: true +- repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: ['--max-line-length=100'] +- repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: ['--keep-percent-format', '--py37-plus'] +- repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black + args: ['--target-version', 'py37', '--line-length', '100'] +- repo: https://github.com/PyCQA/isort + rev: 5.11.4 + hooks: + - id: isort + args: ['--profile', 'black', '--line-length', '100'] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9351e72 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +from debian:stable-slim + +RUN apt-get update && apt-get install --no-install-recommends -y python3-all python3-dev python3-pip python3-venv build-essential pylint3 git pre-commit && apt-get clean && rm -fr rm -rf /var/lib/apt/lists/* +RUN mkdir /tmp/src +COPY .pre-commit-config.yaml fake_python_module /tmp/src/ +RUN cd /tmp/src && git init && git add * && pre-commit autoupdate && pre-commit run --all-files && rm -fr /tmp/src diff --git a/README.md b/README.md new file mode 100644 index 0000000..899fa24 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Docker image to run pre-commit on Python apps/libraries + +Image with common dependencies to run pre-commit in Python apps/libraries: + +- common python packages: `python3-all python3-dev python3-pip python3-venv pylint3` +- `build-essential` to allow local python package using `pip` +- `pre-commit` and `git` commands + +To use it: + +```bash +docker run -it -v "$(pwd)":/src -w /src brenard/python-pre-commit +``` diff --git a/fake_python_module/__init__.py b/fake_python_module/__init__.py new file mode 100644 index 0000000..e69de29