Skip to content

Instantly share code, notes, and snippets.

@nl5887
Last active August 28, 2019 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nl5887/3121149c1bcd7941f9f9441e16d35ab2 to your computer and use it in GitHub Desktop.
Save nl5887/3121149c1bcd7941f9f9441e16d35ab2 to your computer and use it in GitHub Desktop.
Git pre-commit script that will validate build
#!/bin/bash
set -e
DEST=$(mktemp -d)
SRC=$(pwd)
pushd .
cd $DEST; git clone $SRC/.git . >/dev/null 2>&1
cd $SRC; git diff -P --cached | patch -p1 -d $DEST >/dev/null
cd $DEST go test -v -race -run=. -bench=. ./...
cd $DEST golangci-lint run ./...
cd $DEST; go build .
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment