You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 1, 2020. It is now read-only.
This is a proof-of-concept of providing a pre-commit
hook for flake8 via docker. It is suggested to instead use flake8 as provided
by pre-commit-hooks as
you'll have slightly better performance and more control over the python
executable.
How does this work?
pre-commit by convention mounts the user's code at /src inside the
container. The executable is fed relative path filename arguments. The hook
may make changes to the files as the source is mounted read-write and the
executables are run as the user.
A few key lines in the Dockerfile make this work:
RUN virtualenv /venv -ppython3 && /venv/bin/pip install flake8
ENV PATH=/venv/bin:$PATH
This creates a virtual environment inside the docker image and puts the
virtualenv on the PATH so executables (such as flake8) can be run.
Lastly, the metadata in hooks.yaml hooks this up:
entry: flake8language: docker
Here flake8 is the executable inside the container and we tell pre-commit
that the language is docker.
How would I use this repository with pre-commit?
Well, you probably wouldn't (and the hook has been labeled as such) but if you
really wanted to you could add this to your .pre-commit-config.yaml:
- repo: https://github.com/pre-commit/pre-commit-docker-flake8rev: ''# Fill this in with a current revisionhooks:
- id: flake8-docker-not-for-production
You'll also need to use at least version 0.10.0 of pre-commit.