-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tools.go has been replaced with Makefile.tools in line with agent v3 approach * Lint tool naming * Fix vendoring of deps target * Lint Makefile * Fix format target * Pin docker dep versions * Fix sdk codegen Makefile. Add tool debug msg * Pin all versions. Remove protobuf sub command * Pin golang-ci lint version * Pin swagger version
- Loading branch information
1 parent
81f141a
commit 30313d9
Showing
5,657 changed files
with
8,181 additions
and
1,032,712 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
include Makefile.containers | ||
include Makefile.tools | ||
include Makefile.packaging | ||
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# Variable Definitions # | ||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
|
@@ -8,6 +12,16 @@ endif | |
COMMIT = $(shell git rev-parse --short HEAD) | ||
DATE = $(shell date +%F_%H-%M-%S) | ||
|
||
GOCMD = go | ||
GOBUILD = $(GOCMD) build | ||
GOTEST = $(GOCMD) test | ||
GOTOOL = $(GOCMD) tool | ||
GORUN = ${GOCMD} run | ||
GOINST = ${GOCMD} install | ||
GOGET = ${GOCMD} get | ||
GOGEN = ${GOCMD} generate | ||
GOVET = ${GOCMD} vet | ||
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# https://docs.nginx.com/nginx/releases/ # | ||
# These images are based on https://github.com/nginxinc/docker-nginx and are NOT recommended for production # | ||
|
@@ -68,7 +82,6 @@ CERT_SERVER_INT_CN := server-int.local | |
CERT_SERVER_EE_CN := server-ee.local | ||
CERT_SERVER_DNS := tls.example.com | ||
|
||
include Makefile.containers | ||
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# Developer Targets # | ||
|
@@ -98,12 +111,12 @@ run-debug: ## Run code | |
./build/nginx-agent | ||
|
||
build: ## Build agent executable | ||
GOWORK=off CGO_ENABLED=0 GOARCH=${OSARCH} go build -pgo=auto -ldflags=${LDFLAGS} -o ./build/nginx-agent | ||
GOWORK=off CGO_ENABLED=0 GOARCH=${OSARCH} ${GOBUILD} -pgo=auto -ldflags=${LDFLAGS} -o ./build/nginx-agent | ||
|
||
deps: ## Update dependencies in vendor folders | ||
cd sdk && make generate | ||
for dir in ${VENDOR_LOCATIONS}; do \ | ||
(cd "$$dir" && echo "Running vendor commands on $$dir" && go mod tidy && go mod vendor && cd "$$OLDPWD" || exit) \ | ||
(cd "$$dir" && echo "Running vendor commands on $$dir" && go mod tidy && GOWORK=off go mod vendor && cd "$$OLDPWD" || exit) \ | ||
done | ||
go mod download | ||
go work sync | ||
|
@@ -113,38 +126,33 @@ no-local-changes: | |
|
||
lint: ## Run linter | ||
GOWORK=off go vet ./... | ||
GOWORK=off go run github.com/golangci/golangci-lint/cmd/[email protected] run -c ./scripts/.golangci.yml | ||
GOWORK=off $(GORUN) $(GOLANGCI_LINT) run -c ./scripts/.golangci.yml | ||
cd sdk && make lint | ||
|
||
format: ## Format code | ||
go run mvdan.cc/gofumpt -l -w . | ||
$(GORUN) ${GOFUMPT} -l -w . | ||
buf format -w ./sdk/proto/ | ||
|
||
install-tools: ## Install dependencies in tools.go using vendored version see https://www.jvt.me/posts/2023/06/19/go-install-from-mod/ | ||
@echo "Installing Tools" | ||
@grep _ ./scripts/tools.go | awk '{print $$2}' | xargs -tI % env GOBIN=$$(git rev-parse --show-toplevel)/bin GOWORK=off go install -mod=vendor % | ||
@go run github.com/evilmartians/lefthook install pre-push | ||
|
||
generate-swagger: ## Generates swagger.json from source code | ||
go run github.com/go-swagger/go-swagger/cmd/swagger generate spec -o ./docs/swagger.json --scan-models | ||
$(GORUN) $(GO_SWAGGER) generate spec -o ./docs/swagger.json --scan-models | ||
|
||
launch-swagger-ui: generate-swagger ## Launch Swagger UI | ||
go run github.com/go-swagger/go-swagger/cmd/swagger serve ./docs/swagger.json -F=swagger --port=8082 --no-open | ||
$(GORUN) $(GO_SWAGGER) serve ./docs/swagger.json -F=swagger --port=8082 --no-open | ||
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# Local Packaging # | ||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
local-apk-package: ## Create local apk package | ||
GOWORK=off CGO_ENABLED=0 GOARCH=${OSARCH} GOOS=linux go build -pgo=auto -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent | ||
ARCH=${OSARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') go run github.com/goreleaser/nfpm/v2/cmd/nfpm pkg --config ./scripts/.local-nfpm.yaml --packager apk --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.apk; | ||
ARCH=${OSARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') $(GORUN) ${NFPM} pkg --config ./scripts/.local-nfpm.yaml --packager apk --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.apk; | ||
|
||
local-deb-package: ## Create local deb package | ||
GOWORK=off CGO_ENABLED=0 GOARCH=${OSARCH} GOOS=linux go build -pgo=auto -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent | ||
ARCH=${OSARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') go run github.com/goreleaser/nfpm/v2/cmd/nfpm pkg --config ./scripts/.local-nfpm.yaml --packager deb --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.deb; | ||
ARCH=${OSARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') $(GORUN) ${NFPM} pkg --config ./scripts/.local-nfpm.yaml --packager deb --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.deb; | ||
|
||
local-rpm-package: ## Create local rpm package | ||
GOWORK=off CGO_ENABLED=0 GOARCH=${OSARCH} GOOS=linux go build -pgo=auto -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent | ||
ARCH=${OSARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') go run github.com/goreleaser/nfpm/v2/cmd/nfpm pkg --config ./scripts/.local-nfpm.yaml --packager rpm --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.rpm; | ||
ARCH=${OSARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') $(GORUN) ${NFPM} pkg --config ./scripts/.local-nfpm.yaml --packager rpm --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.rpm; | ||
|
||
local-txz-package: ## Create local txz package | ||
GOWORK=off CGO_ENABLED=0 GOARCH=${OSARCH} GOOS=freebsd go build -pgo=auto -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent | ||
|
@@ -154,8 +162,6 @@ txz-packager-image: ## Builds txz packager container image | |
@echo Building Local Packager; \ | ||
$(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) build -t build-local-packager:1.0.0 --build-arg package_type=local-package . --no-cache -f ./scripts/packages/packager/Dockerfile | ||
|
||
include Makefile.packaging | ||
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# Testing # | ||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
|
@@ -190,7 +196,7 @@ test-sdk: $(TEST_BUILD_DIR) ## Run sdk unit tests from root directory | |
component-test: test-component-build test-component-run ## Run component tests | ||
|
||
test-component-build: ## Compile component tests | ||
GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go test ./test/component -c -o component.test | ||
GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ${GOTEST} ./test/component -c -o component.test | ||
|
||
test-container-component: ## Run integration tests in container | ||
for container in ${$(CONTAINER_CLITOOL) ps -aqf "name=^nginx-agent_"}; do echo && $(CONTAINER_CLITOOL) ps -f "id=$$container" --format "{{.Image}}" && $(CONTAINER_CLITOOL) exec $$container ./tmp/component.test -test.v; done | ||
|
@@ -205,22 +211,22 @@ performance-test: ## Run performance tests | |
integration-test: | ||
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \ | ||
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \ | ||
go test -v ./test/integration/install | ||
${GOTEST} -v ./test/integration/install | ||
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \ | ||
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \ | ||
go test -v ./test/integration/api | ||
${GOTEST} -v ./test/integration/api | ||
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \ | ||
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \ | ||
go test -v ./test/integration/features | ||
${GOTEST} -v ./test/integration/features | ||
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \ | ||
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \ | ||
go test -v ./test/integration/grpc | ||
${GOTEST} -v ./test/integration/grpc | ||
|
||
test-bench: ## Run benchmark tests | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 1 -bench=. -benchmem user_workflow_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem plugins_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem environment_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 ${GOTEST} -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 ${GOTEST} -mod=vendor -count 1 -bench=. -benchmem user_workflow_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 ${GOTEST} -mod=vendor -count 5 -timeout 2m -bench=. -benchmem plugins_test.go | ||
cd test/performance && GOWORK=off CGO_ENABLED=0 ${GOTEST} -mod=vendor -count 5 -timeout 2m -bench=. -benchmem environment_test.go | ||
|
||
benchmark-image: ## Build benchmark test container image for NGINX Plus, need nginx-repo.crt and nginx-repo.key in build directory | ||
$(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) build --no-cache -t nginx-agent-benchmark:1.0.0 \ | ||
|
@@ -276,14 +282,14 @@ image: ## Build agent container image for NGINX Plus, need nginx-repo.crt and ng | |
oss-image: ## Build agent container image for NGINX OSS | ||
@echo Building image with $(CONTAINER_CLITOOL); \ | ||
$(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) build -t ${IMAGE_TAG} . \ | ||
--no-cache -f ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile \ | ||
--target install-agent-local \ | ||
--build-arg PACKAGE_NAME=${PACKAGE_NAME} \ | ||
--build-arg PACKAGES_REPO=${OSS_PACKAGES_REPO} \ | ||
--build-arg BASE_IMAGE=${BASE_IMAGE} \ | ||
--build-arg OS_RELEASE=${OS_RELEASE} \ | ||
--build-arg OS_VERSION=${OS_VERSION} \ | ||
--build-arg ENTRY_POINT=./scripts/docker/entrypoint.sh | ||
--no-cache -f ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile \ | ||
--target install-agent-local \ | ||
--build-arg PACKAGE_NAME=${PACKAGE_NAME} \ | ||
--build-arg PACKAGES_REPO=${OSS_PACKAGES_REPO} \ | ||
--build-arg BASE_IMAGE=${BASE_IMAGE} \ | ||
--build-arg OS_RELEASE=${OS_RELEASE} \ | ||
--build-arg OS_VERSION=${OS_VERSION} \ | ||
--build-arg ENTRY_POINT=./scripts/docker/entrypoint.sh | ||
|
||
run-container: ## Run container from specified IMAGE_TAG | ||
@echo Running ${IMAGE_TAG} with $(CONTAINER_CLITOOL); \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/make -f | ||
|
||
BUF = "github.com/bufbuild/buf/cmd/[email protected]" | ||
OAPI_CODEGEN = "github.com/deepmap/oapi-codegen/v2/cmd/[email protected]" | ||
LEFTHOOK = "github.com/evilmartians/[email protected]" | ||
GO_SWAGGER = "github.com/go-swagger/go-swagger/cmd/swagger@abb53530bfcf49c470e5f4c7071ee43f37ec7437" # v0.30.5 currently broken. Update expected shortly. Ref: https://github.com/go-swagger/go-swagger/issues/3070 | ||
PROTOBUF = "github.com/gogo/protobuf/[email protected]" | ||
GOLANGCI_LINT = "github.com/golangci/golangci-lint/cmd/[email protected]" | ||
PROTOC_GENGO = "google.golang.org/protobuf/cmd/[email protected]" | ||
PROTOC_VALIDATORS = "github.com/mwitkow/go-proto-validators/[email protected]" | ||
PROTOC_GEN_DOC = "github.com/pseudomuto/protoc-gen-doc/cmd/[email protected]" | ||
PROTOC_GEN_GO_GRPC = "google.golang.org/grpc/cmd/[email protected]" | ||
NFPM = "github.com/goreleaser/nfpm/v2/cmd/[email protected]" | ||
MOCKGEN = "go.uber.org/mock/[email protected]" | ||
GOFUMPT = "mvdan.cc/[email protected]" | ||
COUNTERFEITER = "github.com/maxbrunsfeld/counterfeiter/[email protected]" | ||
|
||
install-tools: ## Install tool dependencies | ||
@echo "Installing Tools" | ||
@$(GOGET) $(BUF) | ||
@$(GOGET) $(OAPI_CODEGEN) | ||
@$(GOGET) $(LEFTHOOK) | ||
@$(GOGET) $(GO_SWAGGER) | ||
@$(GOGET) $(PROTOBUF) | ||
@$(GOGET) $(GOLANGCI_LINT) | ||
@$(GOGET) $(PROTOC_GENGO) | ||
@$(GOGET) $(PROTOC_VALIDATORS) | ||
@$(GOGET) $(PROTOC_GEN_DOC) | ||
@$(GOGET) $(PROTOC_GEN_GO_GRPC) | ||
@$(GOGET) $(NFPM) | ||
@$(GOGET) $(MOCKGEN) | ||
@$(GOINST) $(GOFUMPT) | ||
@$(GOGET) $(COUNTERFEITER) | ||
@echo "Setting up git hooks" | ||
@$(GORUN) $(LEFTHOOK) install pre-push |
Oops, something went wrong.