Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Setup bare bone scripts for builds #2

Merged
merged 1 commit into from
Feb 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_output
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[prune]
non-go = false
go-tests = true
unused-packages = true
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export GO15VENDOREXPERIMENT:=1
export CGO_ENABLED:=0
export GOARCH:=amd64

SHELL:=$(shell which bash)
LOCAL_OS:=$(shell uname | tr A-Z a-z)
GOFILES:=$(shell find . -name '*.go' | grep -v -E '(./vendor)')
GOFLAGS=

all:
#_output/bin/$(LOCAL_OS)/binary
#_output/bin/linux/binary

check:
@gofmt -l -s $(GOFILES) | read; if [ $$? == 0 ]; then gofmt -s -d $(GOFILES); exit 1; fi
@golint -set_exit_status $(shell go list ./...)
@go vet $(shell go list ./...)
@./scripts/verify-gopkg.sh
@go test -v $(shell go list ./... | grep -v '/e2e')

_output/bin/%: GOOS=$(word 1, $(subst /, ,$*))
_output/bin/%: GOARCH=$(word 2, $(subst /, ,$*))
_output/bin/%: GOARCH:=amd64
_output/bin/%: $(GOFILES)
mkdir -p $(dir $@)
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GOFLAGS) -o $@ github.com/coreos/kubecsr/cmd/$(notdir $@)

vendor:
@dep ensure

clean:
rm -rf _output

.PHONY: all check clean vendor
17 changes: 17 additions & 0 deletions scripts/verify-gopkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

# Ensure that all vendored packages are pinned to a specific version. This means
# we never pull HEAD of a dependency, but as a trade-off means we have to manually
# specify the version of transitive dependencies.

TOML=$( grep -P '( |^)name = ".*"' Gopkg.toml | tr -d ' ' | sort )
LOCK=$( grep -P '( |^)name = ".*"' Gopkg.lock | tr -d ' ' | sort )

# '|| true' because diff exits 1 when there's a difference.
DIFF=$( diff <(echo "$TOML") <(echo "$LOCK") || true )
if [ "$DIFF" != "" ]; then
>&2 echo "Difference between Gopkg.lock file and Gopkg.toml detected. Ensure all dependencies are specified in Gopkg.toml:"
>&2 echo ""
>&2 echo "$DIFF"
exit 1
fi