• This repository has been archived on 31/Aug/2019
  • Stars
    star
    131
  • Rank 267,255 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Toolkit for checks on a Go project before committing via pre-commit git hook. Includes coverage. Fast.

Warning

This tool was designed in older times (2015), when:

  • go test ./... wasn't running tests in parallel
  • go test -i improved build performance (this is not true anymore)
  • go test wasn't using a local cache

As such, it is recommended to stop using this tool.

pre-commit-go

pre-commit-go project includes two tools:

  • pcg to run checks on a Go project on commit and on push via git hooks.
    • DESIGN.md: Designed to be correct, fast, simple, versatile and safe. No check ever modify any file.
    • CI_SETUP.md: Native Continuous Integration service (CI) support.
    • CONFIGURATION.md: Configuration is easy, flexible and extensible.
    • TUTORIAL.md: Short tutorial.
  • covg which is a yet-another-coverage-tool. It's more parallel than any other coverage tool and has native support for global inference.

Or watch the short presentation about pre-commit-go.

Warning

pre-commit-go is under heavy development. If you plan to use it as part of a CI, please make sure to pin your version or track it closely. We'll eventually settle and keep backward compability but the tool is not mature yet, so simply vendor it for now.

Usage

Setup

go get github.com/maruel/pre-commit-go/cmd/...

Use built-in help to list all options and commands:

pcg help

Run from within a git checkout inside $GOPATH. This installs the git hooks within .git/hooks and runs the checks in mode pre-push. It runs the checks on the diff against @{upstream}:

pcg

Bypassing hook

It may become necessary to commit something known to be broken. To bypass the pre-commit hook, use:

git commit --no-verify  (or -n)
git push --no-verify    (-n does something else! <3 git)

Running coverage

covg

You can use the -g flag to enable global inference, that is, coverage induced by a unit test will work across package boundary.

Example coverage output

$ ./cov -i "*.pb.go" -min 50
common/bit_field
  coverage: 100.0% (17/17) >= 50.0%; Functions: 0 untested / 0 partially / 8 completely
common/cache
  common/cache/cache.go:166 memory.Add            66.7% (6/9) 167,172,175
  common/cache/lru.go:79    orderedDict.popOldest 66.7% (2/3) 84
  common/cache/lru.go:200   lruDict.UnmarshalJSON 63.6% (7/11) 202,205,208,213
  common/cache/cache.go:276 disk.Add              60.0% (9/15) 277,282,291-292,295-296
  common/cache/lru.go:28    entry.UnmarshalJSON   60.0% (6/10) 31,34,41,44
  common/cache/lru.go:107   orderedDict.pushBack  40.0% (2/5) 108-110
  coverage: 84.8% (117/138) >= 50.0%; Functions: 0 untested / 6 partially / 35 completely
common/clock
  common/clock/systemclock.go:33 systemClock.NewTimer  0.0% (0/1)
  common/clock/systemclock.go:29 systemClock.Sleep     0.0% (0/1)
  coverage: 95.2% (40/42) >= 50.0%; Functions: 2 untested / 0 partially / 18 completely

Configuration

See Configuration for more details if you want to tweak the default checks. The default checks are meant to be sensible, you can list them with:

pcg info

Continous integration support

pcg is designed to be used as part of CI. This is described in its own page.

  • Travis: Build Status
  • CircleCI: Build Status
  • Drone: Build Status
  • Codeship: Build Status
  • Coveralls: Coverage Status

More Repositories

1

panicparse

Crash your app in style (Golang)
Go
3,479
star
2

serve-dir

"python -m SimpleHTTPServer" but FAST
Go
62
star
3

natural

Natural sorting (natsort) in Go
Go
36
star
4

dlibox

Home automation that does not depend on the internet
Go
25
star
5

go-lepton

Serves images taken on a FLIR Lepton connected to a Raspberry Pi SPI port to over HTTP.
Go
25
star
6

circular

Efficient thread-safe circular byte buffer to keep in-memory logs
Go
21
star
7

subcommands

Permits a Go application to implement subcommands support similar to what is supported by the 'go' tool.
Go
21
star
8

temperature

Converts between color temperature in Kelvin and in RGB (Golang)
Go
19
star
9

rs

Reed-Solomon error correction code in Go
Go
17
star
10

mapreduce

A simple cachable mapreduce Golang implementation
Go
12
star
11

bolide-esp8266

A automatisable 40$ wifi enabled race car 🚗
C++
12
star
12

nin

nin: I love the sound of my build. Build system in Go.
C++
11
star
13

market_track

Google Apps script for Google Sheets to track exchange rates, international stocks and funds
JavaScript
11
star
14

serve-mp4

Serves transcoded MP4's for ChromeCast and ChromeOS
Go
11
star
15

webskel

A template to make free web site generated by Hugo, hosted on GitHub pages, using CloudFlare for HTTPS
HTML
11
star
16

pat

Performance Analysis Toolbox for Go programs.
Go
8
star
17

hugo-tidy

Docker image to generate the fastest (minified, gzipped) web site via Hugo
Shell
8
star
18

dumbcas

Backup tool based on a simple Content Addressed Datastore
Go
7
star
19

anim1d

Idempotent 1D animation system
Go
6
star
20

interrupt

Package interrupt is a single global way to handle process interruption in Go
Go
6
star
21

interfaceGUID

Calculates a unique hash based identifier for a Go interface.
Go
6
star
22

msgbus

A simplified interface to MQTT
Go
5
star
23

ansi256

RGB to terminal color palette function in Go
Go
4
star
24

bench

A collection of low level Go and CPU benchmarks
Go
3
star
25

fastbezier

Fast bezier cubic curve evaluation over uint16 domain in Go and generator for C
Go
3
star
26

bin_pub

Contains all my public scripts and configuration, under a BSD license
Python
3
star
27

fortuna

Fortuna cryptographic random number generator in Go
Go
3
star
28

landslide

Generate a slideshow using the slides that power the html5-slides presentation
Python
3
star
29

restroom

Go
2
star
30

ml

Playing with jupyterlab + with various ML libraries
Jupyter Notebook
2
star
31

meetin

Enlighten your meetings.
Go
2
star
32

bambu_studio

Quickly setup Bambu Studio as a proper application in Ubuntu, with a one liner to upgrade to the latest version.
Shell
2
star
33

ut

Compact testing utilities to shorten Go unit tests.
Go
2
star
34

argent

Scripts to manage money
Python
1
star
35

covg

yet another coverage tool
Go
1
star
36

mastodon-sample

Sample repository to help setup Mastodon with docker-compose
Shell
1
star
37

git-scan

Starts a web server to answer oracle questions about the git repository [Experimental]
Go
1
star
38

http-503

Trivial AppEngine app to return an http error code on all requests.
Python
1
star
39

ffa3

FlashForge Adventurer 3 Go tooling
Go
1
star
40

resilience

Package resilience exposes an http.Handler that returns an HTTP failure randomly to improve client resiliency.
Go
1
star
41

are_you_there_hass

Chrome Extension to report desktop lock state to Home Assistant
JavaScript
1
star
42

halloween2018

Go
1
star
43

psf

Leverage .psf fonts found on unix hosts for use in Go programs
Go
1
star
44

emperor-esp8266

Control a MWELabs Emperor 1510 chair with an ESP8266
Shell
1
star
45

git-hooks-go

Stale project; DO NOT USE.
Python
1
star
46

git_utils

Collection of small git utilities useful to me, that also happen to work on Windows (written in python)
Python
1
star