Skip to content

Commit

Permalink
Adding make build process
Browse files Browse the repository at this point in the history
  • Loading branch information
c0sco committed May 24, 2019
1 parent b5b0ce2 commit 2ca1da8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ env:
go:
- 1.12.x

gobuild_args: -v -coverprofile c.out

install:
- GO111MODULE=off go get -v github.com/codeclimate/test-reporter

before_script:
- test-reporter before-build

script:
- make test

after_script:
- test-reporter after-build --coverage-input-type gocov --exit-code $TRAVIS_TEST_RESULT
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PKG := $(shell head -1 go.mod | sed -e 's/module //')
OUT := $(shell basename ${PKG})
VERSION := $(shell git describe --tag --long --dirty)
PKG_LIST := $(shell go list ${PKG}/...)
GO_FILES := $(shell find . -name '*.go')

all: build

build:
go build -v -o ${OUT} -ldflags="-X main.version=${VERSION}" ${PKG}

c.out:
go test -coverprofile=c.out -v ${PKG}/...

test: c.out

coverhtml: test
go tool cover -html=c.out

vet:
@go vet ${PKG_LIST}

lint:
@for file in ${GO_FILES} ; do \
golint $$file ; \
done

static: vet lint
go build -v -o ${OUT}-${VERSION} -a \
-tags netgo \
-gcflags=all=-trimpath=${GOPATH} \
-asmflags=all=-trimpath=${GOPATH} \
-ldflags="-extldflags \"-static\" -w -s -X main.version=${VERSION}" \
${PKG}

clean:
rm -f ${OUT} ${OUT}-v* c.out

.PHONY: build test coverhtml vet lint static clean
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ authentication to an otherwise unsecured API, and easily adaptable to other auth
Build and Test
---

Standard Go build and test methods apply. Uses modules (Go 1.11+).
This project uses Go and make to build and test. Go 1.11+ is required for the use of Go modules.

```bash
go test -cover ./...
go build -o auth-plug
# Run tests
make test

# Run the standard build process
make build

# Build a statically linked binary for release
make static
```

Configure and Run
Expand Down

0 comments on commit 2ca1da8

Please sign in to comment.