Compare commits
No commits in common. "67125661fdbb3f5c65ef67e0f652d30e7fbeb265" and "0bb3d86ab3ef0abfba6b3b1464ae07f10448d2ff" have entirely different histories.
67125661fd
...
0bb3d86ab3
3 changed files with 8 additions and 24 deletions
|
@ -5,13 +5,11 @@ PWD=`pwd`
|
||||||
if [ -d "$PWD/venv" ]
|
if [ -d "$PWD/venv" ]
|
||||||
then
|
then
|
||||||
echo "Run pylint inside venv ($PWD/venv)..."
|
echo "Run pylint inside venv ($PWD/venv)..."
|
||||||
[ ! -e "$PWD/venv/bin/pylint" ] && $PWD/venv/bin/python -m pip install pylint
|
|
||||||
$PWD/venv/bin/pylint "$@"
|
$PWD/venv/bin/pylint "$@"
|
||||||
exit $?
|
exit $?
|
||||||
elif [ -e "$PWD/pyproject.toml" ]
|
elif [ -e "$PWD/pyproject.toml" ]
|
||||||
then
|
then
|
||||||
echo "Run pylint using poetry..."
|
echo "Run pylint using poetry..."
|
||||||
poetry run pylint --version > /dev/null 2>&1 || poetry run python -m pip install pylint
|
|
||||||
poetry run pylint "$@"
|
poetry run pylint "$@"
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,6 +2,6 @@ from debian:stable-slim
|
||||||
|
|
||||||
RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y python3-all python3-dev python3-pip python3-venv build-essential pylint git && apt-get clean && rm -fr rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y python3-all python3-dev python3-pip python3-venv build-essential pylint git && apt-get clean && rm -fr rm -rf /var/lib/apt/lists/*
|
||||||
RUN pip install pre-commit --break-system-packages
|
RUN pip install pre-commit --break-system-packages
|
||||||
RUN mkdir /src && git config --global --add safe.directory /src
|
RUN mkdir /tmp/src
|
||||||
COPY .pre-commit-config.yaml .pre-commit-pylint fake_python_module /src/
|
COPY .pre-commit-config.yaml .pre-commit-pylint fake_python_module /tmp/src/
|
||||||
RUN cd /src && git init && git add * && pre-commit autoupdate && pre-commit run --all-files && rm -fr /src
|
RUN cd /tmp/src && git init && git add * && pre-commit autoupdate && pre-commit run --all-files && rm -fr /tmp/src
|
||||||
|
|
22
README.md
22
README.md
|
@ -1,31 +1,17 @@
|
||||||
# Docker image to run pre-commit on Python apps/libraries
|
# Docker image to run pre-commit on Python apps/libraries
|
||||||
|
|
||||||
Debian stable based image with common dependencies 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 pylint`
|
- common python packages: `python3-all python3-dev python3-pip python3-venv pylint3`
|
||||||
- `build-essential` to allow local python package using `pip`
|
- `build-essential` to allow local python package using `pip`
|
||||||
- `pre-commit` and `git` commands
|
- `pre-commit` and `git` commands
|
||||||
- pre-install `pre-commit` environments for `ruff`, `pyupgrade`, `black`, `isort`,
|
- pre-install `pre-commit` environments for `pylint`, `pyupgrade`, `black` and `isort`
|
||||||
`flake8`, `codespell`, `yamllint`, `prettier`, `pylint` and `bandit`.
|
|
||||||
|
|
||||||
To use it:
|
To use it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run \
|
docker run -it -v "$(pwd)":/src -w /src brenard/python-pre-commit
|
||||||
-it --rm \
|
|
||||||
-v "$(pwd)":/src -w /src \
|
|
||||||
brenard/python-pre-commit \
|
|
||||||
pre-commit run --all-files
|
pre-commit run --all-files
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** an example `.pre-commit-config.yaml` file is provided with Docker image source.
|
**Note:** an example `.pre-commit-config.yaml` file is provided with Docker image source.
|
||||||
To test it on your project, use to following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run \
|
|
||||||
-it --rm \
|
|
||||||
-v "$(pwd)":/src -w /src \
|
|
||||||
-v "$(pwd)/.pre-commit-config.yaml":/src/.pre-commit-config.yaml \
|
|
||||||
brenard/python-pre-commit \
|
|
||||||
pre-commit run --all-files
|
|
||||||
```
|
|
||||||
|
|
Loading…
Reference in a new issue