mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Drive kustomize repo verification from make.
This commit is contained in:
@@ -35,7 +35,7 @@ install: true
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- ./travis/verify-deps.sh
|
- ./travis/verify-deps.sh
|
||||||
- ./travis/pre-commit.sh
|
- make verify-kustomize
|
||||||
- ./travis/kyaml-pre-commit.sh
|
- ./travis/kyaml-pre-commit.sh
|
||||||
|
|
||||||
# TBD. Suppressing for now.
|
# TBD. Suppressing for now.
|
||||||
|
|||||||
71
Makefile
71
Makefile
@@ -1,25 +1,21 @@
|
|||||||
# This Makefile is (and must be) used by
|
# Copyright 2019 The Kubernetes Authors.
|
||||||
# travis/pre-commit.sh to qualify pull requests.
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
# That script generates all the code that needs
|
# Makefile for the kustomize repo.
|
||||||
# to be generated, and runs all the tests.
|
|
||||||
#
|
|
||||||
# Functionality in that script is gradually moving here.
|
|
||||||
|
|
||||||
MYGOBIN := $(shell go env GOPATH)/bin
|
MYGOBIN := $(shell go env GOPATH)/bin
|
||||||
PATH := $(PATH):$(MYGOBIN)
|
PATH := $(PATH):$(MYGOBIN)
|
||||||
SHELL := env PATH=$(PATH) /bin/bash
|
SHELL := env PATH=$(PATH) /bin/bash
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: pre-commit
|
all: verify-kustomize
|
||||||
|
|
||||||
# The pre-commit.sh script generates, lints and tests.
|
.PHONY: verify-kustomize
|
||||||
# It uses this makefile. For more clarity, would like
|
verify-kustomize: \
|
||||||
# to stop that - any scripts invoked by targets here
|
lint-kustomize \
|
||||||
# shouldn't "call back" to the makefile.
|
test-unit-kustomize-all \
|
||||||
.PHONY: pre-commit
|
test-examples-kustomize-against-HEAD \
|
||||||
pre-commit:
|
test-examples-kustomize-against-latest
|
||||||
./travis/pre-commit.sh
|
|
||||||
|
|
||||||
# Version pinned by api/go.mod
|
# Version pinned by api/go.mod
|
||||||
$(MYGOBIN)/golangci-lint:
|
$(MYGOBIN)/golangci-lint:
|
||||||
@@ -46,6 +42,11 @@ $(MYGOBIN)/pluginator:
|
|||||||
cd api; \
|
cd api; \
|
||||||
go install sigs.k8s.io/kustomize/pluginator/v2
|
go install sigs.k8s.io/kustomize/pluginator/v2
|
||||||
|
|
||||||
|
# Install kustomize from whatever is checked out.
|
||||||
|
$(MYGOBIN)/kustomize:
|
||||||
|
cd kustomize; \
|
||||||
|
go install .
|
||||||
|
|
||||||
.PHONY: install-tools
|
.PHONY: install-tools
|
||||||
install-tools: \
|
install-tools: \
|
||||||
$(MYGOBIN)/goimports \
|
$(MYGOBIN)/goimports \
|
||||||
@@ -72,8 +73,8 @@ builtinplugins = \
|
|||||||
api/builtins/replicacounttransformer.go \
|
api/builtins/replicacounttransformer.go \
|
||||||
api/builtins/secretgenerator.go
|
api/builtins/secretgenerator.go
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint-kustomize
|
||||||
lint: install-tools $(builtinplugins)
|
lint-kustomize: install-tools $(builtinplugins)
|
||||||
cd api; $(MYGOBIN)/golangci-lint run ./...
|
cd api; $(MYGOBIN)/golangci-lint run ./...
|
||||||
cd kustomize; $(MYGOBIN)/golangci-lint run ./...
|
cd kustomize; $(MYGOBIN)/golangci-lint run ./...
|
||||||
cd pluginator; $(MYGOBIN)/golangci-lint run ./...
|
cd pluginator; $(MYGOBIN)/golangci-lint run ./...
|
||||||
@@ -85,23 +86,36 @@ api/builtins/%.go: $(MYGOBIN)/pluginator
|
|||||||
cd ../../../api/builtins; \
|
cd ../../../api/builtins; \
|
||||||
$(MYGOBIN)/goimports -w $*.go
|
$(MYGOBIN)/goimports -w $*.go
|
||||||
|
|
||||||
.PHONY: generate
|
.PHONY: test-unit-kustomize-api
|
||||||
generate: $(builtinplugins)
|
test-unit-kustomize-api: $(builtinplugins)
|
||||||
|
|
||||||
.PHONY: unit-test-api
|
|
||||||
unit-test-api: $(builtinplugins)
|
|
||||||
cd api; go test ./...
|
cd api; go test ./...
|
||||||
|
|
||||||
.PHONY: unit-test-plugins
|
.PHONY: test-unit-kustomize-plugins
|
||||||
unit-test-plugins:
|
test-unit-kustomize-plugins:
|
||||||
./hack/runPluginUnitTests.sh
|
./hack/testUnitKustomizePlugins.sh
|
||||||
|
|
||||||
.PHONY: unit-test-kustomize
|
.PHONY: test-unit-kustomize-cli
|
||||||
unit-test-kustomize:
|
test-unit-kustomize-cli:
|
||||||
cd kustomize; go test ./...
|
cd kustomize; go test ./...
|
||||||
|
|
||||||
.PHONY: unit-test-all
|
.PHONY: test-unit-kustomize-all
|
||||||
unit-test-all: unit-test-api unit-test-kustomize unit-test-plugins
|
test-unit-kustomize-all: \
|
||||||
|
test-unit-kustomize-api \
|
||||||
|
test-unit-kustomize-cli \
|
||||||
|
test-unit-kustomize-plugins
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip
|
||||||
|
./hack/testExamplesAgainstKustomize.sh HEAD
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
test-examples-kustomize-against-latest: $(MYGOBIN)/mdrip
|
||||||
|
/bin/rm -f $(MYGOBIN)/kustomize; \
|
||||||
|
echo "Installing kustomize from latest."; \
|
||||||
|
go install sigs.k8s.io/kustomize/kustomize/v3; \
|
||||||
|
./hack/testExamplesAgainstKustomize.sh latest; \
|
||||||
|
echo "Reinstalling kustomize from HEAD."; \
|
||||||
|
cd kustomize; go install .
|
||||||
|
|
||||||
# linux only.
|
# linux only.
|
||||||
# This is for testing an example plugin that
|
# This is for testing an example plugin that
|
||||||
@@ -133,6 +147,7 @@ $(MYGOBIN)/helm:
|
|||||||
clean:
|
clean:
|
||||||
rm -f $(builtinplugins)
|
rm -f $(builtinplugins)
|
||||||
rm -f $(MYGOBIN)/pluginator
|
rm -f $(MYGOBIN)/pluginator
|
||||||
|
rm -f $(MYGOBIN)/kustomize
|
||||||
|
|
||||||
.PHONY: nuke
|
.PHONY: nuke
|
||||||
nuke: clean
|
nuke: clean
|
||||||
|
|||||||
34
hack/testExamplesAgainstKustomize.sh
Executable file
34
hack/testExamplesAgainstKustomize.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright 2019 The Kubernetes Authors.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
set -o nounset
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
version=$1
|
||||||
|
|
||||||
|
function onLinuxAndNotOnTravis {
|
||||||
|
[[ ("linux" == "$(go env GOOS)") && (-z ${TRAVIS+x}) ]] && return
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: change the label?
|
||||||
|
# We test against the latest release, and HEAD, and presumably
|
||||||
|
# any branch using this label, so it should probably get
|
||||||
|
# a new value.
|
||||||
|
mdrip --mode test \
|
||||||
|
--label testAgainstLatestRelease examples
|
||||||
|
|
||||||
|
# TODO: make work for non-linux
|
||||||
|
if onLinuxAndNotOnTravis; then
|
||||||
|
echo "On linux, and not on travis, so running the notravis example tests."
|
||||||
|
|
||||||
|
# Requires helm.
|
||||||
|
make $(go env GOPATH)/bin/helm
|
||||||
|
mdrip --mode test \
|
||||||
|
--label helmtest examples/chart.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Example tests passed against ${version}."
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
# Copyright 2019 The Kubernetes Authors.
|
# Copyright 2019 The Kubernetes Authors.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
# TODO: get rid of this script, make individual targets
|
|
||||||
# in the makefile.
|
|
||||||
|
|
||||||
# Run this script with no arguments from the repo root
|
# Run this script with no arguments from the repo root
|
||||||
# to test all the plugins.
|
# to test all the plugins.
|
||||||
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Tracks success or failure of various operations.
|
|
||||||
# 0==success, any other value is a failure.
|
|
||||||
rcAccumulator=0
|
|
||||||
|
|
||||||
function removeBin {
|
|
||||||
local d=$(go env GOPATH)/bin/$1
|
|
||||||
echo "Removing binary $d"
|
|
||||||
/bin/rm -f $d
|
|
||||||
}
|
|
||||||
|
|
||||||
function installTools {
|
|
||||||
make install-tools
|
|
||||||
ls -C1 -g -G -h $(go env GOPATH)/bin
|
|
||||||
}
|
|
||||||
|
|
||||||
function runFunc {
|
|
||||||
local name=$1
|
|
||||||
local result="SUCCESS"
|
|
||||||
printf "============== begin %s\n" "$name"
|
|
||||||
$name
|
|
||||||
local code=$?
|
|
||||||
rcAccumulator=$((rcAccumulator || $code))
|
|
||||||
if [ $code -ne 0 ]; then
|
|
||||||
result="FAILURE"
|
|
||||||
fi
|
|
||||||
printf "============== end %s : %s; exit code=%d\n\n\n" "$name" "$result" $code
|
|
||||||
}
|
|
||||||
|
|
||||||
function runLint {
|
|
||||||
make lint
|
|
||||||
}
|
|
||||||
|
|
||||||
function runUnitTests {
|
|
||||||
make unit-test-all
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLinuxAndNotOnTravis {
|
|
||||||
[[ ("linux" == "$(go env GOOS)") && (-z ${TRAVIS+x}) ]] && return
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
function testExamplesAgainstLatestKustomizeRelease {
|
|
||||||
removeBin kustomize
|
|
||||||
|
|
||||||
local latest=sigs.k8s.io/kustomize/kustomize/v3
|
|
||||||
echo "Installing latest kustomize from $latest"
|
|
||||||
(cd ~; GO111MODULE=on go install $latest)
|
|
||||||
|
|
||||||
mdrip --mode test \
|
|
||||||
--label testAgainstLatestRelease examples
|
|
||||||
|
|
||||||
# TODO: make work for non-linux
|
|
||||||
if onLinuxAndNotOnTravis; then
|
|
||||||
echo "On linux, and not on travis, so running the notravis example tests."
|
|
||||||
|
|
||||||
# Requires helm.
|
|
||||||
make $(go env GOPATH)/bin/helm
|
|
||||||
mdrip --mode test \
|
|
||||||
--label helmtest examples/chart.md
|
|
||||||
fi
|
|
||||||
echo "Example tests passed against $latest"
|
|
||||||
}
|
|
||||||
|
|
||||||
function testExamplesAgainstLocalHead {
|
|
||||||
removeBin kustomize
|
|
||||||
|
|
||||||
echo "Installing kustomize from HEAD"
|
|
||||||
(cd kustomize; go install .)
|
|
||||||
|
|
||||||
# To test examples of unreleased features, add
|
|
||||||
# examples with code blocks annotated with some
|
|
||||||
# label _other than_ @testAgainstLatestRelease.
|
|
||||||
mdrip --mode test \
|
|
||||||
--label testAgainstLatestRelease examples
|
|
||||||
echo "Example tests passed against HEAD"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Don't override go's notion of where to
|
|
||||||
# install stuff.
|
|
||||||
unset GOPATH
|
|
||||||
|
|
||||||
# Ease running the tooling installed by 'go';
|
|
||||||
# mdrip, pluginator, stringer, etc.
|
|
||||||
PATH=$(go env GOPATH)/bin:$PATH
|
|
||||||
|
|
||||||
# Assure that this script runs from the repo
|
|
||||||
# root, since some tests might rely on it.
|
|
||||||
base_dir="$( cd "$(dirname "$0")/.." && pwd )"
|
|
||||||
cd "$base_dir" || {
|
|
||||||
echo "Cannot cd to '$base_dir'. Aborting." >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "HOME = $HOME"
|
|
||||||
echo "PATH = $PATH"
|
|
||||||
echo " PWD = $PWD"
|
|
||||||
echo " "
|
|
||||||
echo "Working..."
|
|
||||||
|
|
||||||
runFunc installTools
|
|
||||||
runFunc runLint
|
|
||||||
runFunc runUnitTests
|
|
||||||
runFunc testExamplesAgainstLatestKustomizeRelease
|
|
||||||
runFunc testExamplesAgainstLocalHead
|
|
||||||
|
|
||||||
if [ $rcAccumulator -eq 0 ]; then
|
|
||||||
echo "SUCCESS!"
|
|
||||||
else
|
|
||||||
echo "FAILURE; exit code $rcAccumulator"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $rcAccumulator
|
|
||||||
Reference in New Issue
Block a user