Skip to content

Commit

Permalink
Added Makefile and example of copyright notice.
Browse files Browse the repository at this point in the history
  • Loading branch information
iliafrenkel committed Jul 16, 2021
1 parent f048315 commit be374ed
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
PROJECT_NAME := "go-pb"
USER_NAME := "iliafrenkel"
PKG := "github.com/$(USER_NAME)/$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)

B=$(shell git rev-parse --abbrev-ref HEAD)
BRANCH=$(subst /,-,$(B))
GITREV=$(shell git describe --abbrev=7 --always --tags | cut -d- -f1-2)
REV=$(GITREV)-$(BRANCH)-$(shell date +%Y%m%d-%H:%M:%S)

all: build

info: ## Show the revision
@echo "branch: $(BRANCH)"
@echo "version: $(GITREV)"
@echo "revision: $(REV)"

dep: ## Get the dependencies
@go mod tidy
@go mod download

lint: ## Lint all Golang files
@golint -set_exit_status ${PKG_LIST}

test: ## Run all the unit tests
@go test -short ${PKG_LIST}

test-coverage: ## Run all the unit tests with coverage report
@go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST}
@cat cover.out >> coverage.txt

build: info dep ## Build the binary
- cd cmd && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X 'main.revision=$(REV)' -X 'main.version=$(GITREV)' -X 'main.branch=$(BRANCH)' -s -w" -o ../build/$(PROJECT_NAME)

clean: ## Remove previous build
@rm -f build/$(PROJECT_NAME)

help: ## Print this help message
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: all build clean dep info help lint test test-coverage
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2021 Ilia Frenkel. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.package main
package main

import (
Expand Down

0 comments on commit be374ed

Please sign in to comment.