Skip to content

Commit

Permalink
First version of pre-commit-python
Browse files Browse the repository at this point in the history
  • Loading branch information
devste committed May 12, 2019
1 parent 0e0e763 commit a950429
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
fail_fast: false
repos:
- repo: local
hooks:
- id: black-check
name: Check python files with black
entry: black
args: [--check]
language: system
types: [python]
- repo: local
hooks:
- id: black-fix
name: Format python files with black
entry: black
language: system
verbose: true
stages: [manual]
types: [python]
- repo: local
hooks:
- id: pylint
name: Check python files with pylint
entry: pylint
language: system
types: [python]
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM petzi/pre-commit:1.15.2-9
RUN apk add --no-cache \
gcc \
musl-dev \
python3-dev
COPY requirements.txt /
RUN pip3 install --no-cache-dir -r requirements.txt
COPY .pre-commit-config.yaml /
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Makefile for petzi/docker-pre-commit
# Make targets to help in the development of this docker image

.DEFAULT_GOAL := help

# Docker configuration
DOCKER=docker
# Docker build configuration
DOCKER_TAG=petzi/pre-commit-python

# Docker run configuration for the main image
DOCKER_VOL=-v "${PWD}:/src"
DOCKER_WD=-w "/src"
DOCKER_RUN_TEST=$(DOCKER) run --rm $(DOCKER_VOL) $(DOCKER_WD)

# The help command is inspired by this post:
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: build
build: ## Build the images on development
$(DOCKER) build -t $(DOCKER_TAG) .

.PHONY: test
test: ## Run each image once to test the build result
$(DOCKER_RUN_TEST) $(DOCKER_TAG) --all-files
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black==19.3b0
pylint==2.3.1
3 changes: 3 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pylint: disable=missing-docstring
def hello():
print("Hello world")

0 comments on commit a950429

Please sign in to comment.