Commit feacdbfc authored by Romain's avatar Romain Committed by GitHub

Merge pull request #1176 from mathbunnyru/asalikhov/pre_commit

Run pre-commit hooks server side
parents c47a268c 668cc931
......@@ -40,9 +40,11 @@ jobs:
- name: Install Dev Dependencies
run: |
python -m pip install --upgrade pip
make -C main dev-env lint-install
make -C main dev-env hadolint-install
- name: Lint Dockerfiles
run: make -C main lint-all
run: make -C main hadolint-all
- name: Run pre-commit hooks
run: make -C main pre-commit-all
- name: Build Docker Images
run: make -C main build-test-all
- name: Run Post-Build Hooks
......
......@@ -24,14 +24,3 @@ repos:
rev: v1.5.4
hooks:
- id: autopep8
- repo: local
hooks:
- id: hadolint
name: Hadolint linter
description: Runs Hadolint to check for Dockerfile best practices
language: system
# Exclude ppc64le Dockerfile since cannot check their build easily
exclude: ppc64
types:
- dockerfile
entry: hadolint
......@@ -23,7 +23,7 @@ endif
ALL_IMAGES:=$(ALL_STACKS)
# Linter
# Dockerfile Linter
HADOLINT="${HOME}/hadolint"
HADOLINT_VERSION="v1.18.0"
......@@ -121,17 +121,17 @@ img-rm-dang: ## remove dangling images (tagged None)
@echo "Removing dangling images ..."
-docker rmi --force $(shell docker images -f "dangling=true" -q) 2> /dev/null
lint/%: ARGS?=
lint/%: ## lint the dockerfile(s) for a stack
hadolint/%: ARGS?=
hadolint/%: ## lint the dockerfile(s) for a stack
@echo "Linting Dockerfiles in $(notdir $@)..."
@git ls-files --exclude='Dockerfile*' --ignored $(notdir $@) | grep -v ppc64 | xargs -L 1 $(HADOLINT) $(ARGS)
@echo "Linting done!"
lint-all: $(foreach I,$(ALL_IMAGES),lint/$(I) ) ## lint all stacks
hadolint-all: $(foreach I,$(ALL_IMAGES),hadolint/$(I) ) ## lint all stacks
lint-build-test-all: $(foreach I,$(ALL_IMAGES),lint/$(I) arch_patch/$(I) build/$(I) test/$(I) ) ## lint, build and test all stacks
hadolint-build-test-all: $(foreach I,$(ALL_IMAGES),hadolint/$(I) arch_patch/$(I) build/$(I) test/$(I) ) ## lint, build and test all stacks
lint-install: ## install hadolint
hadolint-install: ## install hadolint
@echo "Installing hadolint at $(HADOLINT) ..."
@curl -sL -o $(HADOLINT) "https://github.com/hadolint/hadolint/releases/download/$(HADOLINT_VERSION)/hadolint-$(shell uname -s)-$(shell uname -m)"
@chmod 700 $(HADOLINT)
......@@ -139,7 +139,7 @@ lint-install: ## install hadolint
@$(HADOLINT) --version
pre-commit-all: ## run pre-commit hook on all files
@pre-commit run --all
@pre-commit run --all-files
pre-commit-install: ## set up the git hook scripts
@pre-commit --version
......
......@@ -43,7 +43,7 @@ There is a specific `make` target to install the linter.
By default `hadolint` will be installed in `${HOME}/hadolint`.
```bash
$ make lint-install
$ make hadolint-install
# Installing hadolint at /Users/romain/hadolint ...
# Installation done!
......@@ -57,7 +57,7 @@ $ make lint-install
The linter can be run per stack.
```bash
$ make lint/scipy-notebook
$ make hadolint/scipy-notebook
# Linting Dockerfiles in scipy-notebook...
# scipy-notebook/Dockerfile:4 DL3006 Always tag the version of an image explicitly
......@@ -69,11 +69,11 @@ $ make lint/scipy-notebook
# make: *** [lint/scipy-notebook] Error 1
```
Optionally you can pass arguments to the linter.
Optionally you can pass arguments to the hadolint.
```bash
# Use a different export format
$ make lint/scipy-notebook ARGS="--format codeclimate"
$ make hadolint/scipy-notebook ARGS="--format codeclimate"
```
#### All the Stacks
......@@ -81,7 +81,7 @@ $ make lint/scipy-notebook ARGS="--format codeclimate"
The linter can be run against all the stacks.
```bash
$ make lint-all
$ make hadolint-all
```
### Ignoring Rules
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment