Skip to content

Commit

Permalink
fixed: simplify makefile and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Oct 10, 2019
1 parent 2911d41 commit 8697fbd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 72 deletions.
20 changes: 1 addition & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,7 @@ before_install:
- go get -u github.com/golangci/golangci-lint/cmd/golangci-lint@latest

script:
- |
golangci-lint run \
--disable-all \
--exclude-use-default=false \
--enable=errcheck \
--enable=goimports \
--enable=ineffassign \
--enable=golint \
--enable=unused \
--enable=structcheck \
--enable=staticcheck \
--enable=varcheck \
--enable=deadcode \
--enable=unconvert \
--enable=misspell \
--enable=prealloc \
--enable=nakedret \
./...
- go test ./... -race -cover -covermode=atomic -coverprofile=unit_coverage.cov
- make

after_success:
- bash <(curl -s https://codecov.io/bash)
50 changes: 4 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := /bin/bash -o pipefail

PROJECT_SHA ?= $(shell git rev-parse HEAD)
PROJECT_VERSION ?= $(lastword $(shell git tag --sort version:refname --merged $(shell git rev-parse --abbrev-ref HEAD)))
PROJECT_RELEASE ?= dev

export GO111MODULE = on

ci: lint test codecov build_linux build_darwin build_windows package
@echo "ci artifacts dir layout: https://github.com/aporeto-inc/builder/wiki#dir-layout"
mkdir -p artifacts/
echo "$(PROJECT_SHA)" > artifacts/src_sha
echo "$(PROJECT_VERSION)" > artifacts/src_semver
echo "$(PROJECT_BRANCH)" > artifacts/src_branch
if [[ -d docker/ ]] ; then cp -r docker/ artifacts/docker/ ; fi
if [[ -d build/ ]] ; then cp -r build/ artifacts/build/ ; fi

default: lint test

lint:
# --enable=unparam
golangci-lint run \
--disable-all \
--exclude-use-default=false \
Expand All @@ -35,46 +22,17 @@ lint:
--enable=misspell \
--enable=prealloc \
--enable=nakedret \
--enable=unparam \
./...

test:
@ echo 'mode: atomic' > unit_coverage.cov
@ for d in $(shell go list ./... | grep -v vendor); do \
go test -race -coverprofile=profile.out -covermode=atomic "$$d" && \
if [ -f profile.out ]; then tail -q -n +2 profile.out >> unit_coverage.cov; rm -f profile.out; fi; \
done;

coverage_aggregate:
@ mkdir -p artifacts
@ for f in `find . -maxdepth 1 -name '*.cov' -type f`; do \
filename="$${f##*/}" && \
go tool cover -html=$$f -o artifacts/$${filename%.*}.html; \
done;

codecov: coverage_aggregate
bash <(curl -s https://codecov.io/bash)
go test ./... -race -cover -covermode=atomic -coverprofile=unit_coverage.cov

prebuild:
mkdir -p ./build/{darwin,linux,windows}

.PHONY: build
build:
&& go build
CGO_ENABLED=0 go build

build_linux: prebuild
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
cp ./tg ./build/linux

build_darwin: prebuild
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build
cp ./tg ./build/darwin

build_windows:
echo "not working" > ./build/windows/tg

package: build_linux
mkdir -p ./docker/app
cp ./tg ./docker/app

container: package
cd docker && docker build -t gcr.io/aporetodev/tg:$(PROJECT_VERSION) .
7 changes: 0 additions & 7 deletions docker/Dockerfile

This file was deleted.

0 comments on commit 8697fbd

Please sign in to comment.