Base makefile and root makefile target for functions/examples

This commit is contained in:
Katrina Verey
2022-04-05 14:37:18 -04:00
parent c071cdaedd
commit 03c94eabb7
8 changed files with 65 additions and 207 deletions

View File

@@ -149,8 +149,19 @@ test-unit-kustomize-plugins:
test-unit-kustomize-cli:
cd kustomize; $(MAKE) test
test-unit-kyaml-all:
./hack/kyaml-pre-commit.sh
.PHONY: kyaml-precommit
kyaml-precommit:
cd kyaml; $(MAKE) all
cd cmd/config; $(MAKE) all
make functions-examples-all
.PHONY: functions-examples-all
functions-examples-all:
for dir in $(abspath $(wildcard functions/examples/*/.)); do \
echo -e "\n---Running make tasks for function $$dir---"; \
set -e; \
cd $$dir; $(MAKE) all; \
done
test-go-mod:
./hack/for-each-module.sh "go list -m -json all > /dev/null && go mod tidy -v"

View File

@@ -0,0 +1,42 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
MYGOBIN = $(shell go env GOBIN)
ifeq ($(MYGOBIN),)
MYGOBIN = $(shell go env GOPATH)/bin
endif
export PATH := $(MYGOBIN):$(PATH)
.PHONY: generate fix vet fmt test build tidy
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(MYGOBIN)/config-function .)
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
fmt:
(cd image && go fmt ./...)
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)
vet:
(cd image && go vet ./...)

View File

@@ -1,40 +1,9 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate fix vet fmt test build tidy image
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
fmt:
(cd image && go fmt ./...)
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)
vet:
(cd image && go vet ./...)
include ../Makefile-examples-base.mk
.PHONY: image
image:
docker build image -t gcr.io/kustomize-functions/create-application:v0.1.0
docker push gcr.io/kustomize-functions/create-application:v0.1.0

View File

@@ -1,40 +1,9 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate fix vet fmt test build tidy image
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(MYGOBIN)/config-function .)
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
fmt:
(cd image && go fmt ./...)
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)
vet:
(cd image && go vet ./...)
include ../Makefile-examples-base.mk
.PHONY: image
image:
docker build image -t gcr.io/kustomize-functions/example-tshirt:v0.2.0
docker push gcr.io/kustomize-functions/example-tshirt:v0.2.0

View File

@@ -1,40 +1,9 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate fix vet fmt test build tidy image
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
fmt:
(cd image && go fmt ./...)
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)
vet:
(cd image && go vet ./...)
include ../Makefile-examples-base.mk
.PHONY: image
image:
docker build image -t gcr.io/kustomize-functions/example-nginx:v0.2.0
docker push gcr.io/kustomize-functions/example-nginx:v0.2.0

View File

@@ -1,40 +1,9 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate fix vet fmt test build tidy image
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
fmt:
(cd image && go fmt ./...)
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)
vet:
(cd image && go vet ./...)
include ../Makefile-examples-base.mk
.PHONY: image
image:
docker build image -t gcr.io/kustomize-functions/example-validator-kubeval:v0.1.0
docker push gcr.io/kustomize-functions/example-validator-kubeval:v0.1.0

View File

@@ -1,40 +1,9 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate fix vet fmt test build tidy image
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
fmt:
(cd image && go fmt ./...)
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)
vet:
(cd image && go vet ./...)
include ../Makefile-examples-base.mk
.PHONY: image
image:
docker build image -t gcr.io/kustomize-functions/example-validator:v0.1.0
docker push gcr.io/kustomize-functions/example-validator:v0.1.0

View File

@@ -1,40 +0,0 @@
#!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
set -e
# run all tests for kyaml and related commands
targets="
kyaml
cmd/config
functions/examples/injection-tshirt-sizes
functions/examples/template-go-nginx
functions/examples/template-heredoc-cockroachdb
functions/examples/validator-kubeval
functions/examples/validator-resource-requests
functions/examples/application-cr
"
# don't run e2e tests in CI by default
export KUSTOMIZE_DOCKER_E2E=${KUSTOMIZE_DOCKER_E2E:-"false"}
for target in $targets; do
echo " "
echo " "
echo "----- Making $target -----"
pushd .
cd $target
make all
popd
done
# Need better check. This is repeated git diff check
# more pain than benefit for most people 25Apr2020
## make sure no files were generated or changed by make
## ignore changes to go.mod and go.sum -- they are too flaky
# find . -name go.mod | xargs git checkout --
# find . -name go.sum | xargs git checkout --
# git add .
# git diff-index HEAD --exit-code