diff --git a/.bingo/.gitignore b/.bingo/.gitignore new file mode 100755 index 0000000000..4f2055b6e4 --- /dev/null +++ b/.bingo/.gitignore @@ -0,0 +1,12 @@ + +# Ignore everything +* + +# But not these files: +!.gitignore +!*.mod +!README.md +!Variables.mk +!variables.env + +*tmp.mod diff --git a/.bingo/README.md b/.bingo/README.md new file mode 100755 index 0000000000..7a5c2d4f6d --- /dev/null +++ b/.bingo/README.md @@ -0,0 +1,14 @@ +# 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 ` to install that have own module file in this directory. +* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $() variable where is the .bingo/.mod. +* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool. +* For go: Import `.bingo/variables.go` to for variable names. +* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. + +## Requirements + +* Go 1.14+ diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk new file mode 100644 index 0000000000..4f45ce4db1 --- /dev/null +++ b/.bingo/Variables.mk @@ -0,0 +1,121 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.3.1. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +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) +# +BINGO := $(GOBIN)/bingo-v0.3.1 +$(BINGO): $(BINGO_DIR)/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.3.1" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.3.1 "github.com/bwplotka/bingo" + +BUF := $(GOBIN)/buf-v0.37.1 +$(BUF): $(BINGO_DIR)/buf.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)/buf-v0.37.1" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buf.mod -o=$(GOBIN)/buf-v0.37.1 "github.com/bufbuild/buf/cmd/buf" + +CALENS := $(GOBIN)/calens-v0.2.0 +$(CALENS): $(BINGO_DIR)/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_DIR) && $(GO) build -mod=mod -modfile=calens.mod -o=$(GOBIN)/calens-v0.2.0 "github.com/restic/calens" + +FILEB0X := $(GOBIN)/fileb0x-v1.1.4 +$(FILEB0X): $(BINGO_DIR)/fileb0x.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)/fileb0x-v1.1.4" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=fileb0x.mod -o=$(GOBIN)/fileb0x-v1.1.4 "github.com/UnnoTed/fileb0x" + +FLAEX := $(GOBIN)/flaex-v0.2.0 +$(FLAEX): $(BINGO_DIR)/flaex.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)/flaex-v0.2.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=flaex.mod -o=$(GOBIN)/flaex-v0.2.0 "github.com/owncloud/flaex" + +GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.35.2 +$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.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)/golangci-lint-v1.35.2" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.35.2 "github.com/golangci/golangci-lint/cmd/golangci-lint" + +GOLINT := $(GOBIN)/golint-v0.0.0-20201208152925-83fdc39ff7b5 +$(GOLINT): $(BINGO_DIR)/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-20201208152925-83fdc39ff7b5" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golint.mod -o=$(GOBIN)/golint-v0.0.0-20201208152925-83fdc39ff7b5 "golang.org/x/lint/golint" + +GOVERAGE := $(GOBIN)/goverage-v0.0.0-20180129164344-eec3514a20b5 +$(GOVERAGE): $(BINGO_DIR)/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_DIR) && $(GO) build -mod=mod -modfile=goverage.mod -o=$(GOBIN)/goverage-v0.0.0-20180129164344-eec3514a20b5 "github.com/haya14busa/goverage" + +GOX := $(GOBIN)/gox-v1.0.1 +$(GOX): $(BINGO_DIR)/gox.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)/gox-v1.0.1" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=gox.mod -o=$(GOBIN)/gox-v1.0.1 "github.com/mitchellh/gox" + +HUGO := $(GOBIN)/hugo-v0.80.0 +$(HUGO): $(BINGO_DIR)/hugo.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)/hugo-v0.80.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.80.0 "github.com/gohugoio/hugo" + +PROTOC_GEN_DOC := $(GOBIN)/protoc-gen-doc-v1.4.1 +$(PROTOC_GEN_DOC): $(BINGO_DIR)/protoc-gen-doc.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)/protoc-gen-doc-v1.4.1" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=protoc-gen-doc.mod -o=$(GOBIN)/protoc-gen-doc-v1.4.1 "github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc" + +PROTOC_GEN_GO := $(GOBIN)/protoc-gen-go-v1.25.0 +$(PROTOC_GEN_GO): $(BINGO_DIR)/protoc-gen-go.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)/protoc-gen-go-v1.25.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=protoc-gen-go.mod -o=$(GOBIN)/protoc-gen-go-v1.25.0 "google.golang.org/protobuf/cmd/protoc-gen-go" + +PROTOC_GEN_MICRO := $(GOBIN)/protoc-gen-micro-v3.0.0-20210217182006-0f0ace1a44a9 +$(PROTOC_GEN_MICRO): $(BINGO_DIR)/protoc-gen-micro.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)/protoc-gen-micro-v3.0.0-20210217182006-0f0ace1a44a9" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=protoc-gen-micro.mod -o=$(GOBIN)/protoc-gen-micro-v3.0.0-20210217182006-0f0ace1a44a9 "github.com/asim/go-micro/cmd/protoc-gen-micro/v3" + +PROTOC_GEN_MICROWEB := $(GOBIN)/protoc-gen-microweb-v0.0.0-20210224131655-d9b1137a84d4 +$(PROTOC_GEN_MICROWEB): $(BINGO_DIR)/protoc-gen-microweb.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)/protoc-gen-microweb-v0.0.0-20210224131655-d9b1137a84d4" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=protoc-gen-microweb.mod -o=$(GOBIN)/protoc-gen-microweb-v0.0.0-20210224131655-d9b1137a84d4 "github.com/owncloud/protoc-gen-microweb" + +PROTOC_GEN_OPENAPIV2 := $(GOBIN)/protoc-gen-openapiv2-v2.2.0 +$(PROTOC_GEN_OPENAPIV2): $(BINGO_DIR)/protoc-gen-openapiv2.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)/protoc-gen-openapiv2-v2.2.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=protoc-gen-openapiv2.mod -o=$(GOBIN)/protoc-gen-openapiv2-v2.2.0 "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" + +REFLEX := $(GOBIN)/reflex-v0.3.0 +$(REFLEX): $(BINGO_DIR)/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_DIR) && $(GO) build -mod=mod -modfile=reflex.mod -o=$(GOBIN)/reflex-v0.3.0 "github.com/cespare/reflex" + +STATICCHECK := $(GOBIN)/staticcheck-v0.1.2 +$(STATICCHECK): $(BINGO_DIR)/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.1.2" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=staticcheck.mod -o=$(GOBIN)/staticcheck-v0.1.2 "honnef.co/go/tools/cmd/staticcheck" + diff --git a/.bingo/bingo.mod b/.bingo/bingo.mod new file mode 100644 index 0000000000..b390f67606 --- /dev/null +++ b/.bingo/bingo.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/bwplotka/bingo v0.3.1 diff --git a/.bingo/buf.mod b/.bingo/buf.mod new file mode 100644 index 0000000000..43f11f929d --- /dev/null +++ b/.bingo/buf.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/bufbuild/buf v0.37.1 // cmd/buf diff --git a/.bingo/calens.mod b/.bingo/calens.mod new file mode 100644 index 0000000000..d1d84c44b7 --- /dev/null +++ b/.bingo/calens.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/restic/calens v0.2.0 diff --git a/.bingo/fileb0x.mod b/.bingo/fileb0x.mod new file mode 100644 index 0000000000..c800b0701e --- /dev/null +++ b/.bingo/fileb0x.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/UnnoTed/fileb0x v1.1.4 diff --git a/.bingo/flaex.mod b/.bingo/flaex.mod new file mode 100644 index 0000000000..8cd5b2860e --- /dev/null +++ b/.bingo/flaex.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/owncloud/flaex v0.2.0 diff --git a/.bingo/go.mod b/.bingo/go.mod new file mode 100755 index 0000000000..610249af0b --- /dev/null +++ b/.bingo/go.mod @@ -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. \ No newline at end of file diff --git a/.bingo/golangci-lint.mod b/.bingo/golangci-lint.mod new file mode 100644 index 0000000000..d1511a951c --- /dev/null +++ b/.bingo/golangci-lint.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/golangci/golangci-lint v1.35.2 // cmd/golangci-lint diff --git a/.bingo/golint.mod b/.bingo/golint.mod new file mode 100644 index 0000000000..32231fdb3c --- /dev/null +++ b/.bingo/golint.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // golint diff --git a/.bingo/goverage.mod b/.bingo/goverage.mod new file mode 100644 index 0000000000..fe86d9dda4 --- /dev/null +++ b/.bingo/goverage.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 diff --git a/.bingo/gox.mod b/.bingo/gox.mod new file mode 100644 index 0000000000..36ade928fb --- /dev/null +++ b/.bingo/gox.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/mitchellh/gox v1.0.1 diff --git a/.bingo/hugo.mod b/.bingo/hugo.mod new file mode 100644 index 0000000000..a41c59deae --- /dev/null +++ b/.bingo/hugo.mod @@ -0,0 +1,7 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +replace github.com/markbates/inflect => github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6 + +require github.com/gohugoio/hugo v0.80.0 diff --git a/.bingo/protoc-gen-doc.mod b/.bingo/protoc-gen-doc.mod new file mode 100644 index 0000000000..d3306fc62b --- /dev/null +++ b/.bingo/protoc-gen-doc.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/pseudomuto/protoc-gen-doc v1.4.1 // cmd/protoc-gen-doc diff --git a/.bingo/protoc-gen-go.mod b/.bingo/protoc-gen-go.mod new file mode 100644 index 0000000000..cb74984573 --- /dev/null +++ b/.bingo/protoc-gen-go.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require google.golang.org/protobuf v1.25.0 // cmd/protoc-gen-go diff --git a/.bingo/protoc-gen-micro.mod b/.bingo/protoc-gen-micro.mod new file mode 100644 index 0000000000..d5109ef44e --- /dev/null +++ b/.bingo/protoc-gen-micro.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/asim/go-micro/cmd/protoc-gen-micro/v3 v3.0.0-20210217182006-0f0ace1a44a9 diff --git a/.bingo/protoc-gen-microweb.mod b/.bingo/protoc-gen-microweb.mod new file mode 100644 index 0000000000..4ff986d597 --- /dev/null +++ b/.bingo/protoc-gen-microweb.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/owncloud/protoc-gen-microweb v0.0.0-20210224131655-d9b1137a84d4 diff --git a/.bingo/protoc-gen-openapiv2.mod b/.bingo/protoc-gen-openapiv2.mod new file mode 100644 index 0000000000..ae9c4f7f01 --- /dev/null +++ b/.bingo/protoc-gen-openapiv2.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/grpc-ecosystem/grpc-gateway/v2 v2.2.0 // protoc-gen-openapiv2 diff --git a/.bingo/reflex.mod b/.bingo/reflex.mod new file mode 100644 index 0000000000..1c313f1266 --- /dev/null +++ b/.bingo/reflex.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/cespare/reflex v0.3.0 diff --git a/.bingo/staticcheck.mod b/.bingo/staticcheck.mod new file mode 100644 index 0000000000..47bf893085 --- /dev/null +++ b/.bingo/staticcheck.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require honnef.co/go/tools v0.1.2 // cmd/staticcheck diff --git a/.bingo/variables.env b/.bingo/variables.env new file mode 100644 index 0000000000..2b51685cbd --- /dev/null +++ b/.bingo/variables.env @@ -0,0 +1,44 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.3.1. 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. +GOBIN=${GOBIN:=$(go env GOBIN)} + +if [ -z "$GOBIN" ]; then + GOBIN="$(go env GOPATH)/bin" +fi + + +BINGO="${GOBIN}/bingo-v0.3.1" + +BUF="${GOBIN}/buf-v0.37.1" + +CALENS="${GOBIN}/calens-v0.2.0" + +FILEB0X="${GOBIN}/fileb0x-v1.1.4" + +FLAEX="${GOBIN}/flaex-v0.2.0" + +GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.35.2" + +GOLINT="${GOBIN}/golint-v0.0.0-20201208152925-83fdc39ff7b5" + +GOVERAGE="${GOBIN}/goverage-v0.0.0-20180129164344-eec3514a20b5" + +GOX="${GOBIN}/gox-v1.0.1" + +HUGO="${GOBIN}/hugo-v0.80.0" + +PROTOC_GEN_DOC="${GOBIN}/protoc-gen-doc-v1.4.1" + +PROTOC_GEN_GO="${GOBIN}/protoc-gen-go-v1.25.0" + +PROTOC_GEN_MICRO="${GOBIN}/protoc-gen-micro-v3.0.0-20210217182006-0f0ace1a44a9" + +PROTOC_GEN_MICROWEB="${GOBIN}/protoc-gen-microweb-v0.0.0-20210224131655-d9b1137a84d4" + +PROTOC_GEN_OPENAPIV2="${GOBIN}/protoc-gen-openapiv2-v2.2.0" + +REFLEX="${GOBIN}/reflex-v0.3.0" + +STATICCHECK="${GOBIN}/staticcheck-v0.1.2" + diff --git a/.drone.star b/.drone.star index 45f768d85c..16d46b59c1 100644 --- a/.drone.star +++ b/.drone.star @@ -1,5 +1,6 @@ config = { 'modules': [ + # if you add a module here please also add it to the root level Makefile 'accounts', 'glauth', 'graph-explorer', diff --git a/.make/changelog.mk b/.make/changelog.mk new file mode 100644 index 0000000000..fc7939b34f --- /dev/null +++ b/.make/changelog.mk @@ -0,0 +1,3 @@ +.PHONY: changelog +changelog: $(CALENS) + $(CALENS) >| CHANGELOG.md \ No newline at end of file diff --git a/.make/docs.mk b/.make/docs.mk new file mode 100644 index 0000000000..ea3f7182cc --- /dev/null +++ b/.make/docs.mk @@ -0,0 +1,7 @@ +.PHONY: config-docs-generate +config-docs-generate: $(FLAEX) + @echo "$(NAME): generating config docs" + @$(FLAEX) >| ../docs/extensions/$(NAME)/configuration.md + +.PHONY: grpc-docs-generate +grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md \ No newline at end of file diff --git a/.make/generate.mk b/.make/generate.mk new file mode 100644 index 0000000000..4b465174b3 --- /dev/null +++ b/.make/generate.mk @@ -0,0 +1,6 @@ +.PHONY: generate +generate: ci-node-generate ci-go-generate + +.PHONY: embed.yml +embed.yml: $(FILEB0X) + @cd pkg/assets/ && echo -n "$(NAME): embed.go - " && $(FILEB0X) embed.yml diff --git a/.make/go.mk b/.make/go.mk new file mode 100644 index 0000000000..abde2be972 --- /dev/null +++ b/.make/go.mk @@ -0,0 +1,108 @@ +IMPORT := github.com/owncloud/ocis/$(NAME) +BIN := bin +DIST := dist + +ifeq ($(OS), Windows_NT) + EXECUTABLE := $(NAME).exe + UNAME := Windows +else + EXECUTABLE := $(NAME) + UNAME := $(shell uname -s) +endif + +ifeq ($(UNAME), Darwin) + GOBUILD ?= go build -i +else + GOBUILD ?= go build +endif + +PACKAGES ?= $(shell go list ./...) +SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") +GENERATE ?= $(PACKAGES) + +TAGS ?= + +ifndef OUTPUT + ifneq ($(DRONE_TAG),) + OUTPUT ?= $(subst v,,$(DRONE_TAG)) + else + OUTPUT ?= testing + endif +endif + +ifndef VERSION + ifneq ($(DRONE_TAG),) + VERSION ?= $(subst v,,$(DRONE_TAG)) + else + VERSION ?= $(shell git rev-parse --short HEAD) + endif +endif + +ifndef DATE + DATE := $(shell date -u '+%Y%m%d') +endif + +LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" +DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" +GCFLAGS += all=-N -l + +.PHONY: all +all: build + +.PHONY: sync +sync: + go mod download + +.PHONY: clean +clean: + @echo "$(NAME): clean" + go clean -i ./... + rm -rf $(BIN) $(DIST) + +.PHONY: go-mod-tidy +go-mod-tidy: + @echo "$(NAME): go-mod-tidy" + @go mod tidy + +.PHONY: fmt +fmt: + gofmt -s -w $(SOURCES) + +.PHONY: vet +vet: + go vet $(PACKAGES) + +.PHONY: staticcheck +staticcheck: $(STATICCHECK) + $(STATICCHECK) -tags '$(TAGS)' $(PACKAGES) + +.PHONY: lint +lint: $(GOLINT) + for PKG in $(PACKAGES); do $(GOLINT) -set_exit_status $$PKG || exit 1; done; + +.PHONY: test +test: $(GOVERAGE) + @echo + @echo + @echo "$(NAME): test" + @echo + @$(GOVERAGE) -v -coverprofile coverage.out $(PACKAGES) + +.PHONY: go-coverage +go-coverage: + @echo "$(NAME): go-coverage" + @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; + @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" + +.PHONY: install +install: $(SOURCES) + go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) + +.PHONY: build +build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug + +$(BIN)/$(EXECUTABLE): $(SOURCES) + $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) + +$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) + $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) diff --git a/.make/protobuf.mk b/.make/protobuf.mk new file mode 100644 index 0000000000..a2418fbd49 --- /dev/null +++ b/.make/protobuf.mk @@ -0,0 +1,60 @@ +.PHONY: protoc-gen-openapiv2 +protoc-gen-openapiv2: + GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 + + +.PHONY: $(PROTO_SRC)/${NAME}.pb.go +$(PROTO_SRC)/${NAME}.pb.go: $(BUF) protoc-gen-openapiv2 $(PROTOC_GEN_GO) + @echo "$(NAME): generating $(PROTO_SRC)/${NAME}.pb.go" + @$(BUF) protoc \ + -I=$(PROTO_SRC)/ \ + -I=../third_party/ \ + -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ + --plugin protoc-gen-go=$(PROTOC_GEN_GO) \ + --go_out=. \ + $(PROTO_SRC)/${NAME}.proto + +.PHONY: $(PROTO_SRC)/${NAME}.pb.micro.go +$(PROTO_SRC)/${NAME}.pb.micro.go: $(BUF) protoc-gen-openapiv2 $(PROTOC_GEN_MICRO) +@echo "$(NAME): generating $(PROTO_SRC)/${NAME}.pb.micro.go" + @$(BUF) protoc \ + -I=$(PROTO_SRC)/ \ + -I=../third_party/ \ + -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ + --plugin protoc-gen-micro=$(PROTOC_GEN_MICRO) \ + --micro_out=. \ + $(PROTO_SRC)/${NAME}.proto + +.PHONY: $(PROTO_SRC)/${NAME}.pb.web.go +$(PROTO_SRC)/${NAME}.pb.web.go: $(BUF) protoc-gen-openapiv2 $(PROTOC_GEN_MICROWEB) + @echo "$(NAME): generating $(PROTO_SRC)/${NAME}.pb.web.go" + @$(BUF) protoc \ + -I=$(PROTO_SRC)/ \ + -I=../third_party/ \ + -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ + --plugin protoc-gen-microweb=$(PROTOC_GEN_MICROWEB) \ + --microweb_out=. \ + $(PROTO_SRC)/${NAME}.proto + +.PHONY: $(PROTO_SRC)/${NAME}.swagger.json +$(PROTO_SRC)/${NAME}.swagger.json: $(BUF) protoc-gen-openapiv2 $(PROTOC_GEN_OPENAPIV2) + @echo "$(NAME): generating $(PROTO_SRC)/${NAME}.swagger.json" + @$(BUF) protoc \ + -I=$(PROTO_SRC)/ \ + -I=../third_party/ \ + -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ + --plugin protoc-gen-openapiv2=$(PROTOC_GEN_OPENAPIV2) \ + --openapiv2_out=$(PROTO_SRC)/ \ + $(PROTO_SRC)/${NAME}.proto + +.PHONY: ../docs/extensions/${NAME}/grpc.md +../docs/extensions/${NAME}/grpc.md: $(BUF) protoc-gen-openapiv2 $(PROTOC_GEN_DOC) + @echo "$(NAME): generating ../docs/extensions/${NAME}/grpc.md" + @$(BUF) protoc \ + -I=$(PROTO_SRC)/ \ + -I=../third_party/ \ + -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ + --plugin protoc-gen-doc=$(PROTOC_GEN_DOC) \ + --doc_opt=./templates/GRPC.tmpl,grpc.md \ + --doc_out=../docs/extensions/${NAME} \ + $(PROTO_SRC)/${NAME}.proto diff --git a/.make/release.mk b/.make/release.mk new file mode 100644 index 0000000000..7b2b05fb79 --- /dev/null +++ b/.make/release.mk @@ -0,0 +1,33 @@ +.PHONY: changelog +changelog: $(CALENS) ## generate changelog + $(CALENS) -i ../changelog -t ../changelog/CHANGELOG.tmpl >| ../CHANGELOG.md + +.PHONY: release +release: release-dirs release-linux release-windows release-darwin release-copy release-check + +.PHONY: release-dirs +release-dirs: + mkdir -p $(DIST)/binaries $(DIST)/release + +.PHONY: release-linux +release-linux: $(GOX) release-dirs + $(GOX) -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-windows +release-windows: $(GOX) release-dirs + $(GOX) -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-darwin +release-darwin: $(GOX) release-dirs + $(GOX) -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-copy +release-copy: + $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) + +.PHONY: release-check +release-check: + cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) + +.PHONY: release-finish +release-finish: release-copy release-check \ No newline at end of file diff --git a/Makefile b/Makefile index 924fb690f0..08ce51c73f 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ WHITE := $(shell tput -Txterm setaf 7) RESET := $(shell tput -Txterm sgr0) +# if you add a module here please also add it to the .drone.star file OCIS_MODULES = \ accounts \ glauth \ @@ -30,6 +31,8 @@ OCIS_MODULES = \ web \ webdav +include .bingo/Variables.mk + .PHONY: help help: @echo "Please use 'make ' where is one of the following:" @@ -141,3 +144,6 @@ go-coverage: @for mod in $(OCIS_MODULES); do \ echo -n "% coverage $$mod: "; $(MAKE) --no-print-directory -C $$mod go-coverage; \ done + +bingo-update: $(BINGO) + $(BINGO) get -u diff --git a/accounts/Makefile b/accounts/Makefile index 21100343a2..5b3fb2b38b 100644 --- a/accounts/Makefile +++ b/accounts/Makefile @@ -1,178 +1,33 @@ SHELL := bash NAME := accounts -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -HUGO := hugo -PROTO_VERSION := v0 -PROTO_SRC := pkg/proto/$(PROTO_VERSION) - -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif - -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif - -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(IMPORT)/pkg/assets - -FEATURE_PATH ?= "ui/tests/acceptance/features" - -TAGS ?= - -ifndef GOPATH - export GOPATH := $(shell go env GOPATH) -endif -export PATH := $(PATH):$(GOPATH)/bin - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) $(HUGO) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check .PHONY: test-acceptance-webui test-acceptance-webui: ./ui/tests/run-acceptance-test.sh $(FEATURE_PATH) -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf + +############ tooling ############ +include ../.bingo/Variables.mk + +############ go tooling ############ +include ../.make/go.mk + +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate \ grpc-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - -.PHONY: grpc-docs-generate -grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: protobuf # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: yarn-build @@ -188,61 +43,10 @@ node_modules: yarn install --frozen-lockfile ############ protobuf ############ -$(GOPATH)/bin/protoc-gen-go: - go get -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0 +include ../.make/protobuf.mk -$(GOPATH)/bin/protoc-gen-micro: - GO111MODULE=on go get -v github.com/asim/go-micro/cmd/protoc-gen-micro/v3 - -$(GOPATH)/bin/protoc-gen-microweb: - GO111MODULE=off go get -v github.com/owncloud/protoc-gen-microweb - -$(GOPATH)/bin/protoc-gen-openapiv2: - GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 - -$(GOPATH)/bin/protoc-gen-doc: - GO111MODULE=off go get -v github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc - -.PHONY: $(PROTO_SRC)/${NAME}.pb.go -$(PROTO_SRC)/${NAME}.pb.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-go - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --go_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.micro.go -$(PROTO_SRC)/${NAME}.pb.micro.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-micro - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --micro_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.web.go -$(PROTO_SRC)/${NAME}.pb.web.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-microweb - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --microweb_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.swagger.json -$(PROTO_SRC)/${NAME}.swagger.json: $(GOPATH)/bin/protoc-gen-openapiv2 - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --openapiv2_out=$(PROTO_SRC)/ ${NAME}.proto - -.PHONY: ../docs/extensions/${NAME}/grpc.md -../docs/extensions/${NAME}/grpc.md: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-doc - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --doc_opt=./templates/GRPC.tmpl,grpc.md \ - --doc_out=../docs/extensions/${NAME} $(PROTO_SRC)/${NAME}.proto +PROTO_VERSION := v0 +PROTO_SRC := pkg/proto/$(PROTO_VERSION) .PHONY: protobuf protobuf: $(PROTO_SRC)/${NAME}.pb.go \ diff --git a/accounts/pkg/assets/assets.go b/accounts/pkg/assets/assets.go index aaf0dfdcc6..b70b83522c 100644 --- a/accounts/pkg/assets/assets.go +++ b/accounts/pkg/assets/assets.go @@ -15,7 +15,7 @@ import ( _ "golang.org/x/net/webdav" ) -//go:generate go run github.com/UnnoTed/fileb0x embed.yml +//go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { diff --git a/accounts/tools.go b/accounts/tools.go deleted file mode 100644 index f1911ffdcb..0000000000 --- a/accounts/tools.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/restic/calens" -) diff --git a/docs/Makefile b/docs/Makefile index f8115b11c7..e2c5c52fb1 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,5 +1,7 @@ SHELL := bash +include ../.bingo/Variables.mk + .PHONY: help help: @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -25,12 +27,12 @@ docs-copy: ## copy docs to hugo rsync -ax --delete --exclude hugo/ --exclude Makefile --exclude .gitignore --exclude README.md ../. content/; \ .PHONY: docs-serve -docs-serve: docs-generate docs-copy ## serve docs with hugo in docker - @docker run --rm --network host -v $(shell pwd)/hugo:/src owncloudci/hugo:0 server +docs-serve: $(HUGO) docs-generate docs-copy ## serve docs with hugo + cd hugo && $(HUGO) server .PHONY: docs-serve-simple -docs-serve-simple: config-docs-generate docs-copy ## serve docs with hugo installed on system - cd hugo && hugo server +docs-serve-simple: $(HUGO) config-docs-generate docs-copy ## serve docs with hugo without protobuf generation + cd hugo && $(HUGO) server .PHONY: clean clean: ## clean up docs build artifacts diff --git a/glauth/Makefile b/glauth/Makefile index c403dd1121..0b35cdf622 100644 --- a/glauth/Makefile +++ b/glauth/Makefile @@ -1,160 +1,27 @@ SHELL := bash NAME := glauth -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/glauth/tools.go b/glauth/tools.go deleted file mode 100644 index 8a77af67ca..0000000000 --- a/glauth/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/restic/calens" -) diff --git a/graph-explorer/Makefile b/graph-explorer/Makefile index 2ade96ceaa..a87ef3f854 100644 --- a/graph-explorer/Makefile +++ b/graph-explorer/Makefile @@ -1,165 +1,32 @@ SHELL := bash NAME := graph-explorer -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) assets - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: pull-assets # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: .PHONY: pull-assets pull-assets: - rm -Rf assets && mkdir assets/ && curl -slL -o- https://github.com/owncloud/graph-explorer/releases/download/v1.7.10.3/release.tar.gz | tar xvzf - -C assets/ + @rm -Rf assets && mkdir assets/ && curl -slL -o- https://github.com/owncloud/graph-explorer/releases/download/v1.7.10.3/release.tar.gz | tar xvzf - -C assets/ + diff --git a/graph-explorer/pkg/assets/assets.go b/graph-explorer/pkg/assets/assets.go index 68a6e5a745..00c698e7f0 100644 --- a/graph-explorer/pkg/assets/assets.go +++ b/graph-explorer/pkg/assets/assets.go @@ -8,7 +8,7 @@ import ( "github.com/owncloud/ocis/ocis-pkg/log" ) -//go:generate go run github.com/UnnoTed/fileb0x embed.yml +//go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { diff --git a/graph/Makefile b/graph/Makefile index 3dac821c37..36c3854172 100644 --- a/graph/Makefile +++ b/graph/Makefile @@ -1,161 +1,27 @@ SHELL := bash NAME := graph -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/idp/Makefile b/idp/Makefile index 3d01994396..c79308fa4c 100644 --- a/idp/Makefile +++ b/idp/Makefile @@ -1,167 +1,27 @@ SHELL := bash NAME := idp -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -# Assets -LOGO_URL = https://raw.githubusercontent.com/owncloud/assets/main/logo.svg -FAVICON_URL = https://raw.githubusercontent.com/owncloud/assets/main/favicon.ico - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - rm -rf node_modules - rm -rf assets/identifier - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: assets @@ -175,10 +35,14 @@ assets: yarn-build \ assets/identifier/static: mkdir -p assets/identifier/static +LOGO_URL = https://raw.githubusercontent.com/owncloud/assets/main/logo.svg + .PHONY: assets/identifier/static/logo.svg # force overwrite assets/identifier/static/logo.svg: curl -o assets/identifier/static/logo.svg ${LOGO_URL} +FAVICON_URL = https://raw.githubusercontent.com/owncloud/assets/main/favicon.ico + .PHONY: assets/identifier/static/favicon.ico # force overwrite assets/identifier/static/favicon.ico: curl -o assets/identifier/static/favicon.ico ${FAVICON_URL} @@ -192,9 +56,3 @@ yarn-build: node_modules .PHONY: node_modules node_modules: yarn install --frozen-lockfile - -######### - -.PHONY: generate -generate: assets - go generate $(GENERATE) diff --git a/idp/pkg/assets/assets.go b/idp/pkg/assets/assets.go index 9e6884434e..bde8b3a050 100644 --- a/idp/pkg/assets/assets.go +++ b/idp/pkg/assets/assets.go @@ -9,7 +9,7 @@ import ( "github.com/owncloud/ocis/ocis-pkg/log" ) -//go:generate go run github.com/UnnoTed/fileb0x embed.yml +//go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { diff --git a/idp/tools.go b/idp/tools.go deleted file mode 100644 index 0237267076..0000000000 --- a/idp/tools.go +++ /dev/null @@ -1,10 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/haya14busa/goverage" - _ "github.com/owncloud/flaex" - _ "github.com/restic/calens" -) diff --git a/ocis-pkg/Makefile b/ocis-pkg/Makefile index 2f3b3bf668..a8f2454694 100644 --- a/ocis-pkg/Makefile +++ b/ocis-pkg/Makefile @@ -1,91 +1,31 @@ SHELL := bash NAME := ocis-pkg -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - UNAME := Windows -else - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f) -GENERATE ?= $(PACKAGES) - -TAGS ?= - -LDFLAGS += -s -w -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: build -build: - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./... +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: +.PHONY: config-docs-generate +config-docs-generate: + @echo "ocis-pkg: nothing to do" + ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/ocis-pkg/tools.go b/ocis-pkg/tools.go deleted file mode 100644 index bdb15091b1..0000000000 --- a/ocis-pkg/tools.go +++ /dev/null @@ -1,10 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/haya14busa/goverage" - _ "github.com/restic/calens" - _ "golang.org/x/lint/golint" - _ "honnef.co/go/tools/cmd/staticcheck" -) diff --git a/ocis/Makefile b/ocis/Makefile index 0a6d7e2661..191b6b6806 100644 --- a/ocis/Makefile +++ b/ocis/Makefile @@ -1,175 +1,32 @@ SHELL := bash NAME := ocis -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -HUGO := hugo -CONFIG := config/identifier-registration.yaml -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f) -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: help -help: - @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -.PHONY: all -all: build ## build oCIS - -.PHONY: sync -sync: ## download go dependencies - go mod download - -.PHONY: clean -clean: clean-config - go clean -i ./... - rm -rf $(BIN) $(DIST) $(HUGO) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: clean-config -clean-config: - rm -rf $(CONFIG) - rm -rf ldap.crt ldap.key server.crt server.key - -.PHONY: fmt -fmt: ## fmt - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: ## vet - go vet $(PACKAGES) - -.PHONY: lint -lint: ## lint - for PKG in $(PACKAGES); do go run golang.org/x/lint/golint -set_exit_status $$PKG || exit 1; done; - -.PHONY: changelog -changelog: ## generate changelog - go run github.com/restic/calens -i ../changelog -t ../changelog/CHANGELOG.tmpl >| ../CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) ## install - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-linux: $(SOURCES) - GOOS=linux GOARCH=amd64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: staticcheck -staticcheck: ## static check - go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate .PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/$(NAME)/configuration.md +config-docs-generate: $(FLAEX) + @echo "$(NAME): generating config docs" + @$(FLAEX) >| ../docs/$(NAME)/configuration.md ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/ocis/tools.go b/ocis/tools.go deleted file mode 100644 index 9dd061892b..0000000000 --- a/ocis/tools.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/owncloud/flaex" - _ "github.com/restic/calens" -) diff --git a/ocs/Makefile b/ocs/Makefile index ef2ebeb707..0385be61e7 100644 --- a/ocs/Makefile +++ b/ocs/Makefile @@ -1,161 +1,27 @@ SHELL := bash NAME := ocs -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/ocs/tools.go b/ocs/tools.go deleted file mode 100644 index 8a77af67ca..0000000000 --- a/ocs/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/restic/calens" -) diff --git a/onlyoffice/Makefile b/onlyoffice/Makefile index 46b14fb75f..e6fad654dd 100644 --- a/onlyoffice/Makefile +++ b/onlyoffice/Makefile @@ -1,162 +1,27 @@ SHELL := bash NAME := onlyoffice -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -HUGO := hugo -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: yarn-build diff --git a/onlyoffice/pkg/assets/assets.go b/onlyoffice/pkg/assets/assets.go index ca3f8bb11e..f66d198dec 100644 --- a/onlyoffice/pkg/assets/assets.go +++ b/onlyoffice/pkg/assets/assets.go @@ -9,7 +9,7 @@ import ( "github.com/owncloud/ocis/onlyoffice/pkg/config" ) -//go:generate go run github.com/UnnoTed/fileb0x embed.yml +//go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { diff --git a/onlyoffice/tools.go b/onlyoffice/tools.go deleted file mode 100644 index 8a77af67ca..0000000000 --- a/onlyoffice/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/restic/calens" -) diff --git a/proxy/Makefile b/proxy/Makefile index 53c0473379..0a270a1b87 100644 --- a/proxy/Makefile +++ b/proxy/Makefile @@ -1,161 +1,27 @@ SHELL := bash NAME := proxy -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/proxy/tools.go b/proxy/tools.go deleted file mode 100644 index fce36f2420..0000000000 --- a/proxy/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/owncloud/flaex" - _ "github.com/restic/calens" -) diff --git a/settings/Makefile b/settings/Makefile index 073020f41e..66fa9679bc 100644 --- a/settings/Makefile +++ b/settings/Makefile @@ -1,177 +1,33 @@ SHELL := bash NAME := settings -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -PROTO_VERSION := v0 -PROTO_SRC := pkg/proto/$(PROTO_VERSION) - -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif - -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif - -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) -FEATURE_PATH ?= "ui/tests/acceptance/features" - -TAGS ?= - -ifndef GOPATH - export GOPATH := $(shell go env GOPATH) -endif -export PATH := $(PATH):$(GOPATH)/bin - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check .PHONY: test-acceptance-webui test-acceptance-webui: ./ui/tests/run-acceptance-test.sh $(FEATURE_PATH) -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf + +############ tooling ############ +include ../.bingo/Variables.mk + +############ go tooling ############ +include ../.make/go.mk + +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate \ grpc-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - -.PHONY: grpc-docs-generate -grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: protobuf # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: yarn-build @@ -187,61 +43,10 @@ node_modules: yarn install --frozen-lockfile ############ protobuf ############ -$(GOPATH)/bin/protoc-gen-go: - go get -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0 +include ../.make/protobuf.mk -$(GOPATH)/bin/protoc-gen-micro: - GO111MODULE=on go get -v github.com/asim/go-micro/cmd/protoc-gen-micro/v3 - -$(GOPATH)/bin/protoc-gen-microweb: - GO111MODULE=off go get -v github.com/owncloud/protoc-gen-microweb - -$(GOPATH)/bin/protoc-gen-openapiv2: - GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 - -$(GOPATH)/bin/protoc-gen-doc: - GO111MODULE=off go get -v github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc - -.PHONY: $(PROTO_SRC)/${NAME}.pb.go -$(PROTO_SRC)/${NAME}.pb.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-go - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --go_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.micro.go -$(PROTO_SRC)/${NAME}.pb.micro.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-micro - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --micro_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.web.go -$(PROTO_SRC)/${NAME}.pb.web.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-microweb - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --microweb_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.swagger.json -$(PROTO_SRC)/${NAME}.swagger.json: $(GOPATH)/bin/protoc-gen-openapiv2 - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --openapiv2_out=$(PROTO_SRC)/ ${NAME}.proto - -.PHONY: ../docs/extensions/${NAME}/grpc.md -../docs/extensions/${NAME}/grpc.md: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-doc - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --doc_opt=./templates/GRPC.tmpl,grpc.md \ - --doc_out=../docs/extensions/${NAME} $(PROTO_SRC)/${NAME}.proto +PROTO_VERSION := v0 +PROTO_SRC := pkg/proto/$(PROTO_VERSION) .PHONY: protobuf protobuf: $(PROTO_SRC)/${NAME}.pb.go \ diff --git a/settings/pkg/assets/assets.go b/settings/pkg/assets/assets.go index 8daf5e9351..7410d49c31 100644 --- a/settings/pkg/assets/assets.go +++ b/settings/pkg/assets/assets.go @@ -15,7 +15,7 @@ import ( _ "golang.org/x/net/webdav" ) -//go:generate go run github.com/UnnoTed/fileb0x embed.yml +//go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { diff --git a/settings/tools.go b/settings/tools.go deleted file mode 100644 index 89c783a7ee..0000000000 --- a/settings/tools.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/mitchellh/gox" - _ "github.com/restic/calens" - _ "golang.org/x/lint/golint" - // _ "honnef.co/go/tools/cmd/staticcheck" -) diff --git a/storage/Makefile b/storage/Makefile index 22328aa269..25765dfe6b 100644 --- a/storage/Makefile +++ b/storage/Makefile @@ -1,162 +1,27 @@ SHELL := bash NAME := storage -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" - -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ######### +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: diff --git a/storage/tools.go b/storage/tools.go deleted file mode 100644 index fce36f2420..0000000000 --- a/storage/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/owncloud/flaex" - _ "github.com/restic/calens" -) diff --git a/store/Makefile b/store/Makefile index f6642262bb..8376e26b65 100644 --- a/store/Makefile +++ b/store/Makefile @@ -1,234 +1,38 @@ SHELL := bash NAME := store -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -HUGO := hugo -PROTO_VERSION := v0 -PROTO_SRC := pkg/proto/$(PROTO_VERSION) -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef GOPATH - export GOPATH := $(shell go env GOPATH) -endif -export PATH := $(PATH):$(GOPATH)/bin - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ############ +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate \ grpc-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - -.PHONY: grpc-docs-generate -grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: protobuf # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: ############ protobuf ############ -$(GOPATH)/bin/protoc-gen-go: - go get -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0 +include ../.make/protobuf.mk -$(GOPATH)/bin/protoc-gen-micro: - GO111MODULE=on go get -v github.com/asim/go-micro/cmd/protoc-gen-micro/v3 - -$(GOPATH)/bin/protoc-gen-microweb: - GO111MODULE=off go get -v github.com/owncloud/protoc-gen-microweb - -$(GOPATH)/bin/protoc-gen-openapiv2: - GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 - -$(GOPATH)/bin/protoc-gen-doc: - GO111MODULE=off go get -v github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc - -.PHONY: $(PROTO_SRC)/${NAME}.pb.go -$(PROTO_SRC)/${NAME}.pb.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-go - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --go_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.micro.go -$(PROTO_SRC)/${NAME}.pb.micro.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-micro - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --micro_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.web.go -$(PROTO_SRC)/${NAME}.pb.web.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-microweb - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --microweb_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.swagger.json -$(PROTO_SRC)/${NAME}.swagger.json: $(GOPATH)/bin/protoc-gen-openapiv2 - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --openapiv2_out=$(PROTO_SRC)/ ${NAME}.proto - -.PHONY: ../docs/extensions/${NAME}/grpc.md -../docs/extensions/${NAME}/grpc.md: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-doc - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --doc_opt=./templates/GRPC.tmpl,grpc.md \ - --doc_out=../docs/extensions/${NAME} $(PROTO_SRC)/${NAME}.proto +PROTO_VERSION := v0 +PROTO_SRC := pkg/proto/$(PROTO_VERSION) .PHONY: protobuf protobuf: $(PROTO_SRC)/${NAME}.pb.go \ diff --git a/store/reflex.conf b/store/reflex.conf deleted file mode 100644 index eecf7cc27c..0000000000 --- a/store/reflex.conf +++ /dev/null @@ -1,3 +0,0 @@ -# backend --r '^(cmd|pkg)/.*\.go$' -R '^node_modules/' -s -- sh -c 'make bin/ocis-store-debug && bin/ocis-store-debug --log-level debug server --debug-pprof --debug-zpages' -' diff --git a/store/tools.go b/store/tools.go deleted file mode 100644 index 8a77af67ca..0000000000 --- a/store/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/restic/calens" -) diff --git a/thumbnails/Makefile b/thumbnails/Makefile index cb75ed46ea..e2fcecc7aa 100644 --- a/thumbnails/Makefile +++ b/thumbnails/Makefile @@ -1,232 +1,37 @@ SHELL := bash NAME := thumbnails -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -HUGO := hugo -PROTO_VERSION := v0 -PROTO_SRC := pkg/proto/$(PROTO_VERSION) -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef GOPATH - export GOPATH := $(shell go env GOPATH) -endif -export PATH := $(PATH):$(GOPATH)/bin - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ######### +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate \ grpc-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - -.PHONY: grpc-docs-generate -grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: protobuf # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: ############ protobuf ############ -$(GOPATH)/bin/protoc-gen-go: - go get -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0 +include ../.make/protobuf.mk -$(GOPATH)/bin/protoc-gen-micro: - GO111MODULE=on go get -v github.com/asim/go-micro/cmd/protoc-gen-micro/v3 - -$(GOPATH)/bin/protoc-gen-microweb: - GO111MODULE=off go get -v github.com/owncloud/protoc-gen-microweb - -$(GOPATH)/bin/protoc-gen-openapiv2: - GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 - -$(GOPATH)/bin/protoc-gen-doc: - GO111MODULE=off go get -v github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc - -.PHONY: $(PROTO_SRC)/${NAME}.pb.go -$(PROTO_SRC)/${NAME}.pb.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-go - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --go_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.micro.go -$(PROTO_SRC)/${NAME}.pb.micro.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-micro - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --micro_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.pb.web.go -$(PROTO_SRC)/${NAME}.pb.web.go: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-microweb - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --microweb_out=. ${NAME}.proto - -.PHONY: $(PROTO_SRC)/${NAME}.swagger.json -$(PROTO_SRC)/${NAME}.swagger.json: $(GOPATH)/bin/protoc-gen-openapiv2 - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --openapiv2_out=$(PROTO_SRC)/ ${NAME}.proto - -.PHONY: ../docs/extensions/${NAME}/grpc.md -../docs/extensions/${NAME}/grpc.md: $(GOPATH)/bin/protoc-gen-openapiv2 $(GOPATH)/bin/protoc-gen-doc - protoc \ - -I=../third_party/ \ - -I=$(PROTO_SRC)/ \ - -I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/ \ - --doc_opt=./templates/GRPC.tmpl,grpc.md \ - --doc_out=../docs/extensions/${NAME} $(PROTO_SRC)/${NAME}.proto +PROTO_VERSION := v0 +PROTO_SRC := pkg/proto/$(PROTO_VERSION) .PHONY: protobuf protobuf: $(PROTO_SRC)/${NAME}.pb.go \ diff --git a/thumbnails/tools.go b/thumbnails/tools.go deleted file mode 100644 index 2d5012ca21..0000000000 --- a/thumbnails/tools.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/cespare/reflex" - _ "github.com/kballard/go-shellquote" - _ "github.com/ogier/pflag" - _ "github.com/restic/calens" -) diff --git a/web/Makefile b/web/Makefile index 013533f60e..f66136a85f 100644 --- a/web/Makefile +++ b/web/Makefile @@ -1,165 +1,33 @@ SHELL := bash NAME := web -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -WEB_ASSETS_VERSION = v2.0.1 -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) assets - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ######### +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: pull-assets # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: +WEB_ASSETS_VERSION = v2.0.1 + .PHONY: pull-assets pull-assets: - rm -Rf assets && mkdir assets/ && curl -slL -o- https://github.com/owncloud/web/releases/download/$(WEB_ASSETS_VERSION)/web.tar.gz | tar xvzf - -C assets/ + @rm -Rf assets && mkdir assets/ && curl -slL -o- https://github.com/owncloud/web/releases/download/$(WEB_ASSETS_VERSION)/web.tar.gz | tar xzf - -C assets/ diff --git a/web/pkg/assets/assets.go b/web/pkg/assets/assets.go index b675e2ead2..0eca9919cc 100644 --- a/web/pkg/assets/assets.go +++ b/web/pkg/assets/assets.go @@ -9,7 +9,7 @@ import ( "github.com/owncloud/ocis/web/pkg/config" ) -//go:generate go run github.com/UnnoTed/fileb0x embed.yml +//go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { diff --git a/web/tools.go b/web/tools.go deleted file mode 100644 index 8a77af67ca..0000000000 --- a/web/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package main - -import ( - _ "github.com/UnnoTed/fileb0x" - _ "github.com/restic/calens" -) diff --git a/webdav/Makefile b/webdav/Makefile index 4adaebff37..f4ab23837a 100644 --- a/webdav/Makefile +++ b/webdav/Makefile @@ -1,160 +1,27 @@ SHELL := bash NAME := webdav -IMPORT := github.com/owncloud/ocis/$(NAME) -BIN := bin -DIST := dist -ifeq ($(OS), Windows_NT) - EXECUTABLE := $(NAME).exe - UNAME := Windows -else - EXECUTABLE := $(NAME) - UNAME := $(shell uname -s) -endif +############ tooling ############ +include ../.bingo/Variables.mk -ifeq ($(UNAME), Darwin) - GOBUILD ?= go build -i -else - GOBUILD ?= go build -endif +############ go tooling ############ +include ../.make/go.mk -PACKAGES ?= $(shell go list ./...) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") -GENERATE ?= $(PACKAGES) - -TAGS ?= - -ifndef OUTPUT - ifneq ($(DRONE_TAG),) - OUTPUT ?= $(subst v,,$(DRONE_TAG)) - else - OUTPUT ?= testing - endif -endif - -ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) - else - VERSION ?= $(shell git rev-parse --short HEAD) - endif -endif - -ifndef DATE - DATE := $(shell date -u '+%Y%m%d') -endif - -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" -GCFLAGS += all=-N -l - -.PHONY: all -all: build - -.PHONY: sync -sync: - go mod download - -.PHONY: clean -clean: - go clean -i ./... - rm -rf $(BIN) $(DIST) - -.PHONY: go-mod-tidy -go-mod-tidy: - @go mod tidy - -.PHONY: fmt -fmt: - gofmt -s -w $(SOURCES) - -.PHONY: vet -vet: - go vet $(PACKAGES) - -.PHONY: staticcheck -staticcheck: - go run honnef.co/go/tools/cmd/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; - -.PHONY: changelog -changelog: - go run github.com/restic/calens >| CHANGELOG.md - -.PHONY: test -test: - go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) - -.PHONY: go-coverage -go-coverage: - @if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi; - @go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+" - -.PHONY: install -install: $(SOURCES) - go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) - -.PHONY: build -build: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE)-debug - -$(BIN)/$(EXECUTABLE): $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) - -$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) - $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) - -.PHONY: release -release: release-dirs release-linux release-windows release-darwin release-copy release-check - -.PHONY: release-dirs -release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release - -.PHONY: release-linux -release-linux: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-windows -release-windows: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-darwin -release-darwin: release-dirs - go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) - -.PHONY: release-copy -release-copy: - $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) - -.PHONY: release-check -release-check: - cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) - -.PHONY: release-finish -release-finish: release-copy release-check - -.PHONY: watch -watch: - go run github.com/cespare/reflex -c reflex.conf +############ release ######### +include ../.make/release.mk ############ docs generate ############ +include ../.make/docs.mk .PHONY: docs-generate docs-generate: config-docs-generate -.PHONY: config-docs-generate -config-docs-generate: - go run github.com/owncloud/flaex >| ../docs/extensions/$(NAME)/configuration.md - ############ generate ############ -.PHONY: generate -generate: ci-node-generate ci-go-generate +include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: # CI runs ci-node-generate automatically before this target - go generate $(GENERATE) + @go generate $(GENERATE) .PHONY: ci-node-generate ci-node-generate: