Skip to content

Commit

Permalink
Migrate to go mod (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: Juan Jose Medina Godoy <jmedinagodoy@vmware.com>
  • Loading branch information
Juan Jose Medina and juamedgod authored Oct 29, 2021
1 parent 56036d4 commit 9c0c3e4
Show file tree
Hide file tree
Showing 5 changed files with 633 additions and 22 deletions.
9 changes: 5 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.16
working_directory: /go/src/github.com/bitnami/gonit
steps:
- checkout
- run: make get-deps
- run: make get-build-deps
- run: make download
- run: make vet
- run: make lint
- run: make test
- run: make cover
- run: make race-test
- run: make build
- run: make build/arm64
- run: make build TOOL_PATH=dist/gonit/gonit
- run: make build/arm64 TOOL_PATH=dist/gonit/arm64/gonit
- store_artifacts:
path: /go/src/github.com/bitnami/gonit/dist/gonit/gonit
destination: gonit
Expand Down
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.PHONY: test cover build all clean parallelizable-steps

SHELL := /bin/bash
GOPATH ?= $(shell go env GOPATH)
PATH := $(GOPATH)/bin:$(PATH)

PACKAGES := utils database testutils monitor
LINT_PACKAGES = $(PACKAGES) gonittest log cmd
VET_PACKAGES = $(PACKAGES) gonittest log cmd
Expand All @@ -20,40 +24,36 @@ VENDOR := vendor
BUILD_DATE := $(shell date -u '+%Y-%m-%d %I:%M:%S UTC' 2> /dev/null)
GIT_HASH := $(shell git rev-parse HEAD 2> /dev/null)
GO_BUILD := go build -ldflags "-X 'main.buildDate=$(BUILD_DATE)' -X main.commit=$(GIT_HASH) -s -w"
GO_MOD := @go mod
TOOL_PATH ?= $(DIST_DIR)/$(TOOL_NAME)

# This allows forcing the dependencies to finish installing even in parallel mode
all: get-build-deps
all:
@$(MAKE) get-build-deps
@$(MAKE) download
@$(MAKE) -s validate-command-gocovmerge validate-command-golint
@$(MAKE) -s parallelizable-steps

parallelizable-steps: vet lint build test race-test cover

build:
@echo "+ $@"
@mkdir -p $(DIST_DIR)
@$(GO_BUILD) -o $(DIST_DIR)/gonit .
@strip $(DIST_DIR)/gonit
@echo "*** Gonit binary created under $(DIST_DIR)/gonit ***"
download:
$(GO_MOD) download

build/arm64:
@echo "+ $@"
build/%:
@echo "+ Building GOARCH=$(*F)"
@mkdir -p $(DIST_DIR)
@GOARCH=arm64 $(GO_BUILD) -o $(DIST_DIR)/arm64/gonit .
@echo "*** Gonit binary created under $(DIST_DIR)/arm64/gonit ***"
@GOARCH=$(*F) $(GO_BUILD) -o $(TOOL_PATH) .
@echo "*** Gonit binary created under $(TOOL_PATH) ***"

build: build/amd64

clean:
-rm -rf $(BUILD_DIR)
-rm -rf $(DIST_DIR)

get-deps:
@echo "+ Downloading dependencies"
@go get ./...
@$(MAKE) get-build-deps

get-build-deps:
@echo "+ Downloading build dependencies"
@go get golang.org/x/tools/cmd/goimports
@go get github.com/tools/godep
@go get golang.org/x/lint/golint
@go get github.com/wadey/gocovmerge

Expand Down
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/bitnami/gonit

go 1.13

require (
github.com/VividCortex/godaemon v1.0.0
github.com/julienschmidt/httprouter v1.3.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.2.1
github.com/stretchr/testify v1.7.0
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359
golang.org/x/tools v0.1.7 // indirect
)
Loading

0 comments on commit 9c0c3e4

Please sign in to comment.