Skip to content

Commit

Permalink
Use bingo and drop dariwn/386
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Mar 14, 2021
1 parent 9b3a1fc commit 2838f40
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 12 deletions.
12 changes: 12 additions & 0 deletions .bingo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# Ignore everything
*

# But not these files:
!.gitignore
!*.mod
!README.md
!Variables.mk
!variables.env

*tmp.mod
13 changes: 13 additions & 0 deletions .bingo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Project Development Dependencies.

This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo.

* Run `bingo get` to install all tools having each own module file in this directory.
* Run `bingo get <tool>` to install <tool> that have own module file in this directory.
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod.
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool
* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies.

## Requirements

* Go 1.14+
54 changes: 54 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.2.2. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
GO ?= $(shell which go)

# Bellow generated variables ensure that every time a tool under each variable is invoked, the correct version
# will be used; reinstalling only if needed.
# For example for bingo variable:
#
# In your main Makefile (for non array binaries):
#
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
#
#command: $(BINGO)
# @echo "Running bingo"
# @$(BINGO) <flags/args..>
#
BINGO := $(GOBIN)/bingo-v0.2.3
$(BINGO): .bingo/bingo.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/bingo-v0.2.3"
@cd .bingo && $(GO) build -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.2.3 "github.com/bwplotka/bingo"

CALENS := $(GOBIN)/calens-v0.2.0
$(CALENS): .bingo/calens.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/calens-v0.2.0"
@cd .bingo && $(GO) build -modfile=calens.mod -o=$(GOBIN)/calens-v0.2.0 "github.com/restic/calens"

GOLINT := $(GOBIN)/golint-v0.0.0-20200302205851-738671d3881b
$(GOLINT): .bingo/golint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golint-v0.0.0-20200302205851-738671d3881b"
@cd .bingo && $(GO) build -modfile=golint.mod -o=$(GOBIN)/golint-v0.0.0-20200302205851-738671d3881b "golang.org/x/lint/golint"

GOVERAGE := $(GOBIN)/goverage-v0.0.0-20180129164344-eec3514a20b5
$(GOVERAGE): .bingo/goverage.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/goverage-v0.0.0-20180129164344-eec3514a20b5"
@cd .bingo && $(GO) build -modfile=goverage.mod -o=$(GOBIN)/goverage-v0.0.0-20180129164344-eec3514a20b5 "github.com/haya14busa/goverage"

REFLEX := $(GOBIN)/reflex-v0.3.0
$(REFLEX): .bingo/reflex.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/reflex-v0.3.0"
@cd .bingo && $(GO) build -modfile=reflex.mod -o=$(GOBIN)/reflex-v0.3.0 "github.com/cespare/reflex"

STATICCHECK := $(GOBIN)/staticcheck-v0.0.1-2020.1.6
$(STATICCHECK): .bingo/staticcheck.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/staticcheck-v0.0.1-2020.1.6"
@cd .bingo && $(GO) build -modfile=staticcheck.mod -o=$(GOBIN)/staticcheck-v0.0.1-2020.1.6 "honnef.co/go/tools/cmd/staticcheck"

9 changes: 9 additions & 0 deletions .bingo/bingo.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require (
github.com/bwplotka/bingo v0.2.3
golang.org/x/mod v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
13 changes: 13 additions & 0 deletions .bingo/calens.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require (
github.com/Masterminds/sprig/v3 v3.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/restic/calens v0.2.0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
)
1 change: 1 addition & 0 deletions .bingo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files.
8 changes: 8 additions & 0 deletions .bingo/golint.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require (
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // golint
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect
)
9 changes: 9 additions & 0 deletions .bingo/reflex.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require (
github.com/cespare/reflex v0.3.0
github.com/fsnotify/fsnotify v1.4.9 // indirect
golang.org/x/sys v0.0.0-20201028094953-708e7fb298ac // indirect
)
8 changes: 8 additions & 0 deletions .bingo/staticcheck.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require (
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect
honnef.co/go/tools v0.0.1-2020.1.6 // cmd/staticcheck
)
22 changes: 22 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.2.2. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk.
local gobin=$(go env GOBIN)

if [ -z "$gobin" ]; then
gobin="$(go env GOPATH)/bin"
fi


BINGO="${gobin}/bingo-v0.2.3"

CALENS="${gobin}/calens-v0.2.0"

GOLINT="${gobin}/golint-v0.0.0-20200302205851-738671d3881b"

GOVERAGE="${gobin}/goverage-v0.0.0-20180129164344-eec3514a20b5"

REFLEX="${gobin}/reflex-v0.3.0"

STATICCHECK="${gobin}/staticcheck-v0.0.1-2020.1.6"

22 changes: 10 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include .bingo/Variables.mk

SHELL := bash
NAME := prometheus-scw-sd
IMPORT := github.com/promhippie/$(NAME)
Expand Down Expand Up @@ -72,24 +74,24 @@ vet:
go vet $(PACKAGES)

.PHONY: staticcheck
staticcheck:
go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES)
staticcheck: $(STATICCHECK)
$(STATICCHECK) -tags '$(TAGS)' $(PACKAGES)

.PHONY: lint
lint:
for PKG in $(PACKAGES); do go run golang.org/x/lint/golint -set_exit_status $$PKG || exit 1; done;
lint: $(GOLINT)
for PKG in $(PACKAGES); do $(GOLINT) -set_exit_status $$PKG || exit 1; done;

.PHONY: generate
generate:
go generate $(GENERATE)

.PHONY: changelog
changelog:
go run github.com/restic/calens >| CHANGELOG.md
changelog: $(CALENS)
$(CALENS) >| CHANGELOG.md

.PHONY: test
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
go test -coverprofile coverage.out $(PACKAGES)

.PHONY: install
install: $(SOURCES)
Expand Down Expand Up @@ -155,12 +157,8 @@ $(DIST)/$(EXECUTABLE)-$(OUTPUT)-linux-mips64le:

.PHONY: release-darwin
release-darwin: $(DIST) \
$(DIST)/$(EXECUTABLE)-$(OUTPUT)-darwin-386 \
$(DIST)/$(EXECUTABLE)-$(OUTPUT)-darwin-amd64

$(DIST)/$(EXECUTABLE)-$(OUTPUT)-darwin-386:
GOOS=darwin GOARCH=386 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)

$(DIST)/$(EXECUTABLE)-$(OUTPUT)-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)

Expand Down Expand Up @@ -192,4 +190,4 @@ docs:

.PHONY: watch
watch:
go run github.com/cespare/reflex -c reflex.conf
$(REFLEX) -c reflex.conf
7 changes: 7 additions & 0 deletions changelog/unreleased/bingo-dev-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change: Use bingo for development tooling

We switched to use [bingo](github.com/bwplotka/bingo) for fetching development
and build tools based on fixed defined versions to reduce the dependencies
listed within the regular go.mod file within this project.

https://github.com/promhippie/prometheus-scw-sd/issues/15
6 changes: 6 additions & 0 deletions changelog/unreleased/drop-darwin-386.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change: Drop dariwn/386 release builds

We dropped the build of 386 builds on Darwin as this architecture is not
supported by current Go versions anymore.

https://github.com/promhippie/prometheus-scw-sd/issues/17

0 comments on commit 2838f40

Please sign in to comment.