mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
Fixup using devel tools in CI
Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
genrule(
|
||||
name = "_ginkgo",
|
||||
srcs = ["@com_github_onsi_ginkgo//ginkgo"],
|
||||
outs = ["ginkgo"],
|
||||
cmd = "cp $(SRCS) $@",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2020 The Jetstack cert-manager contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
if ! command -v bazel &>/dev/null; then
|
||||
echo "Install bazel at https://bazel.build" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${GINKGO:-}" ]; then
|
||||
bazel build //devel/bin:ginkgo
|
||||
export GINKGO="$(bazel info bazel-genfiles)/devel/bin/ginkgo"
|
||||
fi
|
||||
|
||||
"${GINKGO}" "$@"
|
||||
+6
-1
@@ -23,4 +23,9 @@ if ! command -v bazel &>/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bazel run //hack/bin:helm -- "$@"
|
||||
if [ -z "${HELM:-}" ]; then
|
||||
bazel build //hack/bin:helm
|
||||
export HELM="$(bazel info bazel-genfiles)/hack/bin/helm"
|
||||
fi
|
||||
|
||||
"${HELM}" "$@"
|
||||
|
||||
+6
-1
@@ -23,4 +23,9 @@ if ! command -v bazel &>/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bazel run //hack/bin:kind -- "$@"
|
||||
if [ -z "${KIND:-}" ]; then
|
||||
bazel build //hack/bin:kind
|
||||
export KIND="$(bazel info bazel-genfiles)/hack/bin/kind"
|
||||
fi
|
||||
|
||||
"${KIND}" "$@"
|
||||
|
||||
+6
-1
@@ -23,4 +23,9 @@ if ! command -v bazel &>/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bazel run //hack/bin:kubectl -- "$@"
|
||||
if [ -z "${KUBECTL:-}" ]; then
|
||||
bazel build //hack/bin:kubectl
|
||||
export KUBECTL="$(bazel info bazel-genfiles)/hack/bin/kubectl"
|
||||
fi
|
||||
|
||||
"${KUBECTL}" "$@"
|
||||
|
||||
+3
-1
@@ -24,8 +24,10 @@ set -o pipefail
|
||||
|
||||
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
||||
export REPO_ROOT="${SCRIPT_ROOT}/.."
|
||||
source "${SCRIPT_ROOT}/lib/lib.sh"
|
||||
|
||||
# Configure PATH to use bazel provided e2e tools
|
||||
export PATH="${SCRIPT_ROOT}/bin:$PATH"
|
||||
setup_tools
|
||||
|
||||
echo "Ensuring a kind cluster exists..."
|
||||
"${SCRIPT_ROOT}/cluster/create.sh"
|
||||
|
||||
+16
-2
@@ -18,12 +18,26 @@ set -o nounset
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
|
||||
export REPO_ROOT="$SCRIPT_ROOT/../.."
|
||||
LIB_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
||||
export REPO_ROOT="$LIB_ROOT/../.."
|
||||
|
||||
export SKIP_BUILD_ADDON_IMAGES="${SKIP_BUILD_ADDON_IMAGES:-}"
|
||||
export KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}"
|
||||
|
||||
# setup_tools will build and set up the environment to use bazel-provided
|
||||
# versions of the tools required for development
|
||||
setup_tools() {
|
||||
check_bazel
|
||||
bazel build //hack/bin:helm //hack/bin:kind //hack/bin:kubectl //devel/bin:ginkgo
|
||||
local bindir="$(bazel info bazel-genfiles)"
|
||||
export HELM="${bindir}/hack/bin/helm"
|
||||
export KIND="${bindir}/hack/bin/kind"
|
||||
export KUBECTL="${bindir}/hack/bin/kubectl"
|
||||
export GINKGO="${bindir}/devel/bin/ginkgo"
|
||||
# Configure PATH to use bazel provided e2e tools
|
||||
export PATH="${SCRIPT_ROOT}/bin:$PATH"
|
||||
}
|
||||
|
||||
# check_tool ensures that the tool with the given name is available, or advises
|
||||
# users to setup their PATH for the test/e3e/bin directory if not.
|
||||
check_tool() {
|
||||
|
||||
+12
-7
@@ -22,19 +22,24 @@ set -o pipefail
|
||||
# kind cluster.
|
||||
# If a cluster does not already exist, create one with 'cluster/create.sh'.
|
||||
|
||||
export SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
|
||||
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
||||
export REPO_ROOT="${SCRIPT_ROOT}/.."
|
||||
source "${SCRIPT_ROOT}/lib/lib.sh"
|
||||
|
||||
# Configure PATH to use bazel provided e2e tools
|
||||
setup_tools
|
||||
|
||||
# Ensure bazel is installed
|
||||
check_bazel
|
||||
|
||||
# Create output directory for JUnit output
|
||||
mkdir -p "${REPO_ROOT}/_artifacts"
|
||||
bazel build //hack/bin:helm //test/e2e:e2e.test
|
||||
# Set KUBECONFIG environment variable if not already set
|
||||
export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"
|
||||
|
||||
# Build the e2e test binary
|
||||
bazel build //test/e2e:e2e.test
|
||||
|
||||
# Run e2e tests
|
||||
bazel run @com_github_onsi_ginkgo//ginkgo -- \
|
||||
-nodes 10 \
|
||||
-flakeAttempts ${FLAKE_ATTEMPTS:-1} \
|
||||
ginkgo -nodes 10 -flakeAttempts ${FLAKE_ATTEMPTS:-1} \
|
||||
$(bazel info bazel-genfiles)/test/e2e/e2e.test \
|
||||
-- \
|
||||
--repo-root="${REPO_ROOT}" \
|
||||
|
||||
@@ -24,8 +24,12 @@ set -o pipefail
|
||||
# If you are running the *full* test suite, you should be sure to run this
|
||||
# script beforehand.
|
||||
|
||||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")
|
||||
export REPO_ROOT="${REPO_ROOT:-$SCRIPT_ROOT/..}"
|
||||
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
||||
export REPO_ROOT="${SCRIPT_ROOT}/.."
|
||||
source "${SCRIPT_ROOT}/lib/lib.sh"
|
||||
|
||||
# Configure PATH to use bazel provided e2e tools
|
||||
setup_tools
|
||||
|
||||
echo "Installing cert-manager into the kind cluster..."
|
||||
"${SCRIPT_ROOT}/addon/certmanager/install.sh"
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
@@ -62,8 +63,16 @@ func (c *Config) Validate() error {
|
||||
|
||||
// Register flags common to all e2e test suites.
|
||||
func (c *Config) AddFlags(fs *flag.FlagSet) {
|
||||
kubeConfigFile := os.Getenv(clientcmd.RecommendedConfigPathEnvVar)
|
||||
if kubeConfigFile == "" {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic("Failed to get user home directory: " + err.Error())
|
||||
}
|
||||
kubeConfigFile = filepath.Join(homeDir, clientcmd.RecommendedHomeDir, clientcmd.RecommendedFileName)
|
||||
}
|
||||
// Kubernetes API server config
|
||||
fs.StringVar(&c.KubeConfig, "kubernetes-config", os.Getenv(clientcmd.RecommendedConfigPathEnvVar), "Path to config containing embedded authinfo for kubernetes. Default value is from environment variable "+clientcmd.RecommendedConfigPathEnvVar)
|
||||
fs.StringVar(&c.KubeConfig, "kubernetes-config", kubeConfigFile, "Path to config containing embedded authinfo for kubernetes. Default value is from environment variable "+clientcmd.RecommendedConfigPathEnvVar)
|
||||
fs.StringVar(&c.KubeContext, "kubernetes-context", "", "config context to use for kuberentes. If unset, will use value from 'current-context'")
|
||||
fs.StringVar(&c.Kubectl, "kubectl-path", "kubectl", "path to the kubectl binary to use during e2e tests.")
|
||||
fs.BoolVar(&c.Cleanup, "cleanup", true, "If true, addons will be cleaned up both before and after provisioning")
|
||||
|
||||
Reference in New Issue
Block a user