Add pre-commit to the repo
continuous-integration/drone/push Build is passing Details

This adds pre-commit which can be used to enforce consistent style
and common errors (like committing large files)
This commit is contained in:
IamTheFij 2019-11-21 15:30:19 -08:00
parent b808df7365
commit 9b9f803231
7 changed files with 50 additions and 15 deletions

View File

@ -13,6 +13,12 @@ steps:
commands:
- make test
- name: check
image: python:3
commands:
- pip install pre-commit==1.20.0
- make check
- name: notify
image: drillster/drone-email
settings:

19
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,19 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-added-large-files
- id: check-yaml
args:
- --allow-multiple-documents
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- repo: git://github.com/dnephin/pre-commit-golang
rev: v0.3.5
hooks:
- id: go-fmt
- id: go-imports
# - id: gometalinter
# - id: golangci-lint

View File

@ -29,6 +29,16 @@ test:
@go tool cover -func=coverage.out | awk -v target=80.0% \
'/^total:/ { print "Total coverage: " $$3 " Minimum coverage: " target; if ($$3+0.0 >= target+0.0) print "ok"; else { print "fail"; exit 1; } }'
# Installs pre-commit hooks
.PHONY: install-hooks
install-hooks:
pre-commit install --install-hooks
# Checks files for encryption
.PHONY: check
check:
pre-commit run --all-files
.PHONY: clean
clean:
rm -f ./minitor-go

View File

@ -2,10 +2,11 @@ package main
import (
"errors"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"os"
"gopkg.in/yaml.v2"
)
// Config type is contains all provided user configuration

View File

@ -2,10 +2,10 @@ package main
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
// "github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
// TODO: Not sure if this is the best way to handle. A global instance for

View File

@ -6,4 +6,3 @@ monitors:
alert_down: [ 'alert_down', 'log_shell', 'log_command' ]
# alert_every: -1
alert_every: 0