Skip to content

Commit e44ccea

Browse files
committed
Add e2e test
1 parent 95353e8 commit e44ccea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2797
-19
lines changed

Makefile

Lines changed: 107 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,120 @@
1-
BINDIR ?= $(CURDIR)/bin
2-
ARCH ?= amd64
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
314

4-
help: ## display this help
5-
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
15+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
16+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/Makefile instead.
617

7-
.PHONY: help build image all clean
18+
# NOTE FOR DEVELOPERS: "How do the Makefiles work and how can I extend them?"
19+
#
20+
# Shared Makefile logic lives in the make/_shared/ directory. The source of truth for these files
21+
# lies outside of this repository, eg. in the cert-manager/makefile-modules repository.
22+
#
23+
# Logic specific to this repository must be defined in the make/00_mod.mk and make/02_mod.mk files:
24+
# - The make/00_mod.mk file is included first and contains variable definitions needed by
25+
# the shared Makefile logic.
26+
# - The make/02_mod.mk file is included later, it can make use of most of the shared targets
27+
# defined in the make/_shared/ directory (all targets defined in 00_mod.mk and 01_mod.mk).
28+
# This file should be used to define targets specific to this repository.
829

9-
deps: ## Download all Dependencies
10-
go mod download
30+
##################################
1131

12-
test: deps ## test version-checker
13-
go test ./... -coverprofile=coverage.out
32+
# Some modules build their dependencies from variables, we want these to be
33+
# evalutated at the last possible moment. For this we use second expansion to
34+
# re-evaluate the generate and verify targets a second time.
35+
#
36+
# See https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
37+
.SECONDEXPANSION:
1438

15-
$(BINDIR):
16-
mkdir -p $(BINDIR)
39+
# For details on some of these "prelude" settings, see:
40+
# https://clarkgrubb.com/makefile-style-guide
41+
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules
42+
SHELL := /usr/bin/env bash
43+
.SHELLFLAGS := -uo pipefail -c
44+
.DEFAULT_GOAL := help
45+
.DELETE_ON_ERROR:
46+
.SUFFIXES:
47+
FORCE:
1748

18-
build: deps $(BINDIR) ## build version-checker
19-
CGO_ENABLED=0 go build -o ./bin/version-checker ./cmd/.
49+
noop: # do nothing
2050

21-
verify: test build ## tests and builds version-checker
51+
# Set empty value for MAKECMDGOALS to prevent the "warning: undefined variable 'MAKECMDGOALS'"
52+
# warning from happening when running make without arguments
53+
MAKECMDGOALS ?=
2254

2355
image: ## build docker image
2456
GOARCH=$(ARCH) GOOS=linux CGO_ENABLED=0 go build -o ./bin/version-checker-linux ./cmd/.
2557
docker build -t quay.io/jetstack/version-checker:v0.9.0 .
2658

27-
clean: ## clean up created files
28-
rm -rf \
29-
$(BINDIR)
59+
##################################
60+
# Host OS and architecture setup #
61+
##################################
3062

31-
all: test build image ## runs test, build and image
63+
# The reason we don't use "go env GOOS" or "go env GOARCH" is that the "go"
64+
# binary may not be available in the PATH yet when the Makefiles are
65+
# evaluated. HOST_OS and HOST_ARCH only support Linux, *BSD and macOS (M1
66+
# and Intel).
67+
host_os := $(shell uname -s | tr A-Z a-z)
68+
host_arch := $(shell uname -m)
69+
HOST_OS ?= $(host_os)
70+
HOST_ARCH ?= $(host_arch)
71+
72+
ifeq (x86_64, $(HOST_ARCH))
73+
HOST_ARCH = amd64
74+
else ifeq (aarch64, $(HOST_ARCH))
75+
# linux reports the arm64 arch as aarch64
76+
HOST_ARCH = arm64
77+
endif
78+
79+
##################################
80+
# Git and versioning information #
81+
##################################
82+
83+
git_version := $(shell git describe --tags --always --match='v*' --abbrev=14 --dirty)
84+
VERSION ?= $(git_version)
85+
IS_PRERELEASE := $(shell git describe --tags --always --match='v*' --abbrev=0 | grep -q '-' && echo true || echo false)
86+
GITCOMMIT := $(shell git rev-parse HEAD)
87+
GITEPOCH := $(shell git show -s --format=%ct HEAD)
88+
89+
##################################
90+
# Global variables and dirs #
91+
##################################
92+
93+
bin_dir := _bin
94+
95+
# The ARTIFACTS environment variable is set by the CI system to a directory
96+
# where artifacts should be placed. These artifacts are then uploaded to a
97+
# storage bucket by the CI system (https://docs.prow.k8s.io/docs/components/pod-utilities/).
98+
# An example of such an artifact is a jUnit XML file containing test results.
99+
# If the ARTIFACTS environment variable is not set, we default to a local
100+
# directory in the _bin directory.
101+
ARTIFACTS ?= $(bin_dir)/artifacts
102+
103+
$(bin_dir) $(ARTIFACTS) $(bin_dir)/scratch:
104+
mkdir -p $@
105+
106+
.PHONY: clean
107+
## Clean all temporary files
108+
## @category [shared] Tools
109+
clean:
110+
rm -rf $(bin_dir)
111+
112+
##################################
113+
# Include all the Makefiles #
114+
##################################
115+
116+
-include make/00_mod.mk
117+
-include make/_shared/*/00_mod.mk
118+
-include make/_shared/*/01_mod.mk
119+
-include make/02_mod.mk
120+
-include make/_shared/*/02_mod.mk

deploy/charts/version-checker/templates/deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ spec:
4242
ports:
4343
- name: metrics
4444
containerPort: 8080
45-
command: ["version-checker"]
4645
args:
4746
{{- include "version-checker.pod.args" . | nindent 8 }}
4847
resources:

make/00_mod.mk

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
repo_name := github.com/jetstack/version-checker
16+
17+
kind_cluster_name := version-checker
18+
kind_cluster_config := $(bin_dir)/scratch/kind_cluster.yaml
19+
20+
build_names := manager
21+
22+
go_manager_main_dir := ./cmd
23+
go_manager_mod_dir := .
24+
go_manager_ldflags := -X $(repo_name)/internal/version.AppVersion=$(VERSION) -X $(repo_name)/internal/version.GitCommit=$(GITCOMMIT)
25+
oci_manager_base_image_flavor := static
26+
oci_manager_image_name := quay.io/jetstack/version-checker
27+
oci_manager_image_tag := $(VERSION)
28+
oci_manager_image_name_development := version-checker.local/version-checker
29+
oci_platforms := linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
30+
31+
deploy_name := version-checker
32+
deploy_namespace := version-checker
33+
34+
helm_chart_source_dir := deploy/charts/version-checker
35+
helm_chart_name := version-checker
36+
helm_chart_version := $(VERSION)
37+
helm_labels_template_name := version-checker.labels
38+
helm_docs_use_helm_tool := 1
39+
helm_generate_schema := 1
40+
helm_verify_values := 1
41+
42+
golangci_lint_config := .golangci.yaml
43+
44+
define helm_values_mutation_function
45+
$(YQ) \
46+
'( .image.repository = "$(oci_manager_image_name)" ) | \
47+
( .image.tag = "$(oci_manager_image_tag)" )' \
48+
$1 --inplace
49+
endef
50+
51+
images_amd64 ?=
52+
images_arm64 ?=
53+
54+
images_amd64 += docker.io/kong/httpbin:0.1.0@sha256:9d65a5b1955d2466762f53ea50eebae76be9dc7e277217cd8fb9a24b004154f4
55+
images_arm64 += docker.io/kong/httpbin:0.1.0@sha256:c546c8b06c542b615f053b577707cb72ddc875a0731d56d0ffaf840f767322ad
56+
57+
images_amd64 += quay.io/curl/curl:8.5.0@sha256:e40a76dcfa9405678336774130411ca35beba85db426d5755b3cdd7b99d09a7a
58+
images_arm64 += quay.io/curl/curl:8.5.0@sha256:038b0290c9e4a371aed4f9d6993e3548fcfa32b96e9a170bfc73f5da4ec2354d

make/02_mod.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
$(kind_cluster_config): make/config/kind/cluster.yaml | $(bin_dir)/scratch
16+
cat $< | \
17+
sed -e 's|{{KIND_IMAGES}}|$(CURDIR)/$(images_tar_dir)|g' \
18+
> $@
19+
20+
include make/test-e2e.mk
21+
include make/test-unit.mk

make/_shared/helm/01_mod.mk

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
include $(dir $(lastword $(MAKEFILE_LIST)))/helm.mk
16+
include $(dir $(lastword $(MAKEFILE_LIST)))/deploy.mk

make/_shared/helm/deploy.mk

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ifndef deploy_name
16+
$(error deploy_name is not set)
17+
endif
18+
19+
ifndef deploy_namespace
20+
$(error deploy_namespace is not set)
21+
endif
22+
23+
# Install options allows the user configuration of extra flags
24+
INSTALL_OPTIONS ?=
25+
26+
##########################################
27+
28+
.PHONY: install
29+
## Install controller helm chart on the current active K8S cluster.
30+
## @category [shared] Deployment
31+
install: $(helm_chart_archive) | $(NEEDS_HELM)
32+
$(HELM) upgrade $(deploy_name) $(helm_chart_archive) \
33+
--wait \
34+
--install \
35+
--create-namespace \
36+
$(INSTALL_OPTIONS) \
37+
--namespace $(deploy_namespace)
38+
39+
.PHONY: uninstall
40+
## Uninstall controller helm chart from the current active K8S cluster.
41+
## @category [shared] Deployment
42+
uninstall: | $(NEEDS_HELM)
43+
$(HELM) uninstall $(deploy_name) \
44+
--wait \
45+
--namespace $(deploy_namespace)
46+
47+
.PHONY: template
48+
## Template the helm chart.
49+
## @category [shared] Deployment
50+
template: $(helm_chart_archive) | $(NEEDS_HELM)
51+
@$(HELM) template $(deploy_name) $(helm_chart_archive) \
52+
--create-namespace \
53+
$(INSTALL_OPTIONS) \
54+
--namespace $(deploy_namespace)

0 commit comments

Comments
 (0)