Initial QSfera import
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The following grep will filter out every line containing an `env` annotation
|
||||
# it will ignore every line that already has a valid `introductionVersion` annotation
|
||||
#
|
||||
# valid examples:
|
||||
#
|
||||
# introductionVersion:"%%NEXT%%"
|
||||
# introductionVersion:"pre5.0"
|
||||
# introductionVersion:"5.0"
|
||||
# introductionVersion:"4.9.3-rc5"
|
||||
# introductionVersion:"5.0.1-cheesecake"
|
||||
# introductionVersion:"5.10.100.15"
|
||||
# introductionVersion:"0.0"
|
||||
#
|
||||
# invalid examples:
|
||||
#
|
||||
# introductionVersion:"5.0cheesecake"
|
||||
# introductionVersion:"5"
|
||||
# introductionVersion:"5blueberry"
|
||||
# introductionVersion:"5-lasagna"
|
||||
# introductionVersion:"4.9.3rc5"
|
||||
|
||||
ERROR=0
|
||||
|
||||
SEMVER_REGEX="([0-9]|[1-9][0-9]*)(\.([0-9]|[1-9][0-9]*)){1,2}(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?"
|
||||
|
||||
QUERY_INTRO=$(git grep -n "env:" -- '*.go' |grep -v -P "introductionVersion:\"($SEMVER_REGEX|(%%NEXT%%))\""|grep -v "_test.go"|grep -v "vendor/")
|
||||
RESULTS_INTRO=$(echo "${QUERY_INTRO}"|wc -l)
|
||||
if [ "${QUERY_INTRO}" != "" ] && [ "${RESULTS_INTRO}" -gt 0 ]; then
|
||||
echo "==============================================================================================="
|
||||
echo "The following ${RESULTS_INTRO} items contain an invalid or missing introductionVersion annotation:"
|
||||
echo "==============================================================================================="
|
||||
echo "$QUERY_INTRO"
|
||||
ERROR=1
|
||||
else
|
||||
echo "All introductionVersion annotations are valid"
|
||||
fi
|
||||
|
||||
# The following grep will filter out every line containing an `env` annotation
|
||||
# it will ignore every line that has allready a valid `desc` annotation
|
||||
|
||||
QUERY_DESC=$(git grep -n "env:" -- '*.go' |grep -v -P "desc:\".{10,}\""|grep -v "_test.go"|grep -v "vendor/")
|
||||
|
||||
RESULTS_DESC=$(echo "${QUERY_DESC}"|wc -l)
|
||||
if [ "${QUERY_DESC}" != "" ] && [ "${RESULTS_DESC}" -gt 0 ]; then
|
||||
echo "==============================================================================================="
|
||||
echo "The following ${RESULTS_DESC} items contain an invalid or missing description annotation:"
|
||||
echo "==============================================================================================="
|
||||
echo "$QUERY_DESC"
|
||||
ERROR=1
|
||||
else
|
||||
echo "All description annotations are valid"
|
||||
fi
|
||||
exit ${ERROR}
|
||||
@@ -0,0 +1,49 @@
|
||||
####################
|
||||
### generate
|
||||
####################
|
||||
.PHONY: generate
|
||||
generate: generate-prod # production is always the default
|
||||
|
||||
.PHONY: generate-prod-default
|
||||
generate-prod-default: node-generate-prod go-generate
|
||||
|
||||
.PHONY: generate-dev-default
|
||||
generate-dev-default: node-generate-dev go-generate
|
||||
|
||||
.PHONY: node-generate-dev-default
|
||||
node-generate-dev-default: node-generate-prod
|
||||
|
||||
.PHONY: node-generate-prod-default
|
||||
node-generate-prod-default: noop
|
||||
|
||||
.PHONY: go-generate-default
|
||||
go-generate-default: noop
|
||||
|
||||
####################
|
||||
### licenses
|
||||
####################
|
||||
.PHONY: ci-go-check-licenses-default
|
||||
ci-go-check-licenses-default: noop
|
||||
|
||||
.PHONY: ci-go-save-licenses-default
|
||||
ci-go-save-licenses-default: noop
|
||||
|
||||
.PHONY: ci-node-check-licenses-default
|
||||
ci-node-check-licenses-default: noop
|
||||
|
||||
.PHONY: ci-node-save-licenses-default
|
||||
ci-node-save-licenses-default: noop
|
||||
|
||||
####################
|
||||
### misc
|
||||
####################
|
||||
.PHONY: vet
|
||||
vet: noop
|
||||
|
||||
.PHONY: noop
|
||||
noop:
|
||||
@echo -e "- $(MAKECMDGOALS): no action required\n"
|
||||
|
||||
.PHONY: %
|
||||
%: %-default
|
||||
@ true
|
||||
@@ -0,0 +1,4 @@
|
||||
CONFIG_DOCS_BASE_PATH ?= ../../docs/services
|
||||
|
||||
.PHONY: grpc-docs-generate
|
||||
grpc-docs-generate: buf-generate
|
||||
@@ -0,0 +1,133 @@
|
||||
OC_REPO := github.com/qsfera/server
|
||||
IMPORT := $(OC_REPO)/$(NAME)
|
||||
BIN := bin
|
||||
DIST := dist
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
EXECUTABLE := $(NAME).exe
|
||||
UNAME := Windows
|
||||
else
|
||||
EXECUTABLE := $(NAME)
|
||||
UNAME := $(shell uname -s)
|
||||
endif
|
||||
|
||||
GOBUILD ?= go build
|
||||
|
||||
SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*")
|
||||
|
||||
TAGS ?=
|
||||
|
||||
ifndef OUTPUT
|
||||
ifneq ($(CI_COMMIT_TAG),)
|
||||
OUTPUT ?= $(subst v,,$(CI_COMMIT_TAG))
|
||||
else
|
||||
OUTPUT ?= testing
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(VERSION), daily)
|
||||
STRING ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo local)
|
||||
else ifeq ($(VERSION),)
|
||||
STRING ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo local)
|
||||
endif
|
||||
|
||||
|
||||
ifndef DATE
|
||||
DATE := $(shell date -u '+%Y%m%d')
|
||||
endif
|
||||
|
||||
LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -s -w \
|
||||
-X "$(OC_REPO)/pkg/version.Edition=$(EDITION)" \
|
||||
-X "$(OC_REPO)/pkg/version.String=$(STRING)" \
|
||||
-X "$(OC_REPO)/pkg/version.Tag=$(VERSION)" \
|
||||
-X "$(OC_REPO)/pkg/version.Date=$(DATE)"
|
||||
|
||||
DEBUG_LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn \
|
||||
-X "$(OC_REPO)/pkg/version.Edition=$(EDITION)" \
|
||||
-X "$(OC_REPO)/pkg/version.String=$(STRING)" \
|
||||
-X "$(OC_REPO)/pkg/version.Tag=$(VERSION)" \
|
||||
-X "$(OC_REPO)/pkg/version.Date=$(DATE)"
|
||||
|
||||
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathValue=/var/lib/qsfera"
|
||||
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathValue=/etc/qsfera"
|
||||
|
||||
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:
|
||||
@echo "- $(NAME): fmt"
|
||||
gofmt -s -w $(SOURCES)
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
@go test -v -tags '$(TAGS)' -coverprofile coverage.out ./...
|
||||
|
||||
.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-all
|
||||
build-all: build build-debug
|
||||
|
||||
.PHONY: build
|
||||
build: $(BIN)/$(EXECUTABLE)
|
||||
|
||||
.PHONY: build-debug
|
||||
build-debug: $(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: watch
|
||||
watch: $(REFLEX)
|
||||
$(REFLEX) -c reflex.conf
|
||||
|
||||
debug-linux-docker-amd64: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=amd64 \
|
||||
go build \
|
||||
-gcflags="all=-N -l" \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=exe \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(DEBUG_LDFLAGS) $(DOCKER_LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-linux-amd64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
debug-linux-docker-arm64: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=arm64 \
|
||||
go build \
|
||||
-gcflags="all=-N -l" \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=exe \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(DEBUG_LDFLAGS) $(DOCKER_LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-linux-arm64' \
|
||||
./cmd/$(NAME)
|
||||
@@ -0,0 +1,48 @@
|
||||
# On OSX the PATH variable isn't exported unless "SHELL" is also set, see: http://stackoverflow.com/a/25506676
|
||||
SHELL = /bin/bash
|
||||
NODE_BINDIR = ./node_modules/.bin
|
||||
export PATH := $(PATH):$(NODE_BINDIR)
|
||||
|
||||
INPUT_FILES = ./ui
|
||||
|
||||
# Where to write the files generated by this makefile.
|
||||
OUTPUT_DIR = ./l10n
|
||||
|
||||
# Template file
|
||||
TEMPLATE_FILE = ./l10n/template.pot
|
||||
|
||||
# Name of the generated .po files for each available locale.
|
||||
LOCALE_FILES = $(shell find l10n/locale -name '*.po' 2> /dev/null)
|
||||
|
||||
.PHONY: l10n-push
|
||||
l10n-push:
|
||||
cd $(OUTPUT_DIR) && tx push -s --skip
|
||||
|
||||
.PHONY: l10n-pull
|
||||
l10n-pull:
|
||||
cd $(OUTPUT_DIR) && tx pull -a --skip --minimum-perc=75
|
||||
|
||||
.PHONY: l10n-clean
|
||||
l10n-clean:
|
||||
rm -f $(TEMPLATE_FILE)
|
||||
rm -rf $(OUTPUT_DIR)/locale
|
||||
|
||||
.PHONY: l10n-read
|
||||
l10n-read: node_modules $(TEMPLATE_FILE)
|
||||
|
||||
.PHONY: l10n-write
|
||||
l10n-write: node_modules $(OUTPUT_DIR)/translations.json
|
||||
|
||||
# Create a main .pot template, then generate .po files for each available language.
|
||||
# Thanks to Systematic: https://github.com/Polyconseil/systematic/blob/866d5a/mk/main.mk#L167-L183
|
||||
$(TEMPLATE_FILE):
|
||||
# Extract gettext strings from each template file and create a POT dictionary template.
|
||||
# Generate .po files for each available language.
|
||||
export GETTEXT_SOURCES=`find $(INPUT_FILES) -name '*.vue' -o -name '*.js'`; \
|
||||
node ./node_modules/easygettext/src/extract-cli.js --attribute v-translate --output $(OUTPUT_DIR)/template.pot $$GETTEXT_SOURCES;
|
||||
|
||||
# Generate translations.json file from .pot template.
|
||||
.PHONY: $(OUTPUT_DIR)/translations.json
|
||||
$(OUTPUT_DIR)/translations.json:
|
||||
rm -rf $(OUTPUT_DIR)/translations.json
|
||||
gettext-compile --output $(OUTPUT_DIR)/translations.json $(LOCALE_FILES);
|
||||
@@ -0,0 +1,24 @@
|
||||
SHA1_LOCK_FILE := $(abspath $(CURDIR)/../../protogen/buf.sha1.lock)
|
||||
|
||||
# bingo creates symlinks from the -l option in GOBIN, from where
|
||||
# we can easily use it with buf. To have the symlinks inside this
|
||||
# repo and on a known location, we set GOBIN to .bingo in the root
|
||||
# of the repository (therefore we need to cd ../..)
|
||||
.PHONY: protoc-deps
|
||||
protoc-deps: $(BINGO)
|
||||
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/go-micro/generator/cmd/protoc-gen-micro
|
||||
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/owncloud/protoc-gen-microweb
|
||||
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
|
||||
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/favadi/protoc-go-inject-tag
|
||||
|
||||
.PHONY: buf-generate
|
||||
buf-generate: $(SHA1_LOCK_FILE)
|
||||
@find $(abspath $(CURDIR)/../../protogen/proto/) -type f -print0 | sort -z | xargs -0 sha1sum > buf.sha1.lock.tmp
|
||||
@cmp $(SHA1_LOCK_FILE) buf.sha1.lock.tmp --quiet || $(MAKE) -B $(SHA1_LOCK_FILE)
|
||||
@rm -f buf.sha1.lock.tmp
|
||||
|
||||
$(SHA1_LOCK_FILE): $(BUF) protoc-deps
|
||||
@echo "generating protobuf content"
|
||||
cd ../../protogen/proto && $(BUF) generate
|
||||
find $(abspath $(CURDIR)/../../protogen/proto/) -type f -print0 | sort -z | xargs -0 sha1sum > $(SHA1_LOCK_FILE)
|
||||
@@ -0,0 +1,131 @@
|
||||
.PHONY: changelog
|
||||
changelog: $(CALENS) ## generate changelog
|
||||
$(CALENS) -i ../changelog -t ../changelog/CHANGELOG.tmpl >| ../CHANGELOG.md
|
||||
|
||||
.PHONY: release
|
||||
release: release-dirs release-linux release-darwin release-copy release-check
|
||||
|
||||
.PHONY: release-dirs
|
||||
release-dirs:
|
||||
@mkdir -p $(DIST)/binaries $(DIST)/release
|
||||
|
||||
# docker specific packaging flags
|
||||
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathValue=/var/lib/qsfera"
|
||||
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathValue=/etc/qsfera"
|
||||
|
||||
# We can't link statically when vips is enabled but we still
|
||||
# prefer static linking where possible
|
||||
ifndef ENABLE_VIPS
|
||||
DOCKER_LDFLAGS += -extldflags "-static"
|
||||
endif
|
||||
|
||||
release-linux-docker-amd64: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=amd64 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=pie \
|
||||
-trimpath \
|
||||
-ldflags '$(LDFLAGS) $(DOCKER_LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-linux-amd64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
release-linux-docker-arm: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=arm \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-trimpath \
|
||||
-ldflags '$(LDFLAGS) $(DOCKER_LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-linux-arm' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
@# https://github.com/golang/go/issues/50405
|
||||
@# -buildmode=pie not easily doable for arm
|
||||
|
||||
release-linux-docker-arm64: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=arm64 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=pie \
|
||||
-trimpath \
|
||||
-ldflags '$(LDFLAGS) $(DOCKER_LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-linux-arm64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
.PHONY: release-linux
|
||||
release-linux: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=amd64 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=pie \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-linux-amd64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
GOOS=linux \
|
||||
GOARCH=386 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-linux-386' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
GOOS=linux \
|
||||
GOARCH=arm64 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=pie \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-linux-arm64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
GOOS=linux \
|
||||
GOARCH=arm \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-linux-arm' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
@# https://github.com/golang/go/issues/50405
|
||||
@# -buildmode=pie not easily doable for arm
|
||||
|
||||
.PHONY: release-darwin
|
||||
release-darwin: release-dirs
|
||||
GOOS=darwin \
|
||||
GOARCH=amd64 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=pie \
|
||||
-trimpath \
|
||||
-ldflags '$(LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-darwin-amd64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
GOOS=darwin \
|
||||
GOARCH=arm64 \
|
||||
go build \
|
||||
-tags 'netgo,$(TAGS)' \
|
||||
-buildmode=pie \
|
||||
-trimpath \
|
||||
-ldflags '$(LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-darwin-arm64' \
|
||||
./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
|
||||
Reference in New Issue
Block a user