diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..b805a1c6d --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,25 @@ +name: Test and coverage + +on: + push: + branches: + - main + - "releases/**" + paths: + - "**.go" + - "**go.mod" + - "**go.sum" +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - uses: ./.github/actions/setup-go + - name: Run coverage + run: make test-cover + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: out/coverage.txt diff --git a/Makefile b/Makefile index f80841fba..f8bc2bea9 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ CI_KIND ?= true # # Binaries. # -MINIMUM_CLUSTERCTL_VERSION=1.2.2 # https://github.com/kubernetes-sigs/cluster-api/releases +MINIMUM_CLUSTERCTL_VERSION=1.2.3 # https://github.com/kubernetes-sigs/cluster-api/releases MINIMUM_CTLPTL_VERSION=0.8.8 # https://github.com/tilt-dev/ctlptl/releases MINIMUM_GO_VERSION=go$(GO_VERSION) # Check current project go version MINIMUM_HCLOUD_VERSION=1.30.3 # https://github.com/hetznercloud/cli/releases @@ -490,9 +490,7 @@ test-verbose: ## Run tests with verbose settings .PHONY: test-cover test-cover: $(RELEASE_DIR) ## Run tests with code coverage and code generate reports - $(MAKE) test TEST_ARGS="$(TEST_ARGS) -coverprofile=out/coverage.out -covermode=atomic" - go tool cover -func=out/coverage.out -o $(RELEASE_DIR)/coverage.txt - go tool cover -html=out/coverage.out -o $(RELEASE_DIR)/coverage.html + $(MAKE) test TEST_ARGS="$(TEST_ARGS) -coverprofile=out/coverage.txt -covermode=atomic" .PHONY: test-junit test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run tests with verbose setting and generate a junit report diff --git a/Tiltfile b/Tiltfile index 315fd621d..27deb373b 100644 --- a/Tiltfile +++ b/Tiltfile @@ -20,7 +20,7 @@ settings = { "deploy_observability": False, "preload_images_for_kind": True, "kind_cluster_name": "caph", - "capi_version": "v1.2.2", + "capi_version": "v1.2.3", "cabpt_version": "v0.5.4", "cacppt_version": "v0.4.6", "cert_manager_version": "v1.9.1", diff --git a/docs/developers/tilt.md b/docs/developers/tilt.md index f14c11d13..474f47735 100644 --- a/docs/developers/tilt.md +++ b/docs/developers/tilt.md @@ -7,7 +7,7 @@ "deploy_observability": False, "preload_images_for_kind": True, "kind_cluster_name": "caph", - "capi_version": "v1.2.2", + "capi_version": "v1.2.3", "cabpt_version": "v0.5.2", "cacppt_version": "v0.4.5", "cert_manager_version": "v1.9.1", @@ -34,7 +34,7 @@ | deploy_observability | bool | false | no | If true, installs grafana, loki and promtail in the dev cluster. Grafana UI will be accessible via a link in the tilt console. Important! This feature requires the `helm` command to be available in the user's path | | preload_images_for_kind | bool | true | no | If set to true, uses `kind load docker-image` to preload images into a kind cluster | | kind_cluster_name | []object | "caph" | no | The name of the kind cluster to use when preloading images | -| capi_version | string | "v1.2.2" | no | Version of CAPI | +| capi_version | string | "v1.2.3" | no | Version of CAPI | | cabpt_version | string | "v0.5.4" | no | Version of Cluster API Bootstrap Provider Talos | | cacppt_version | string | "v0.4.6" | no | Version of Cluster API Control Plane Provider Talos | | cert_manager_version | string | "v1.9.1" | no | Version of cert manager | diff --git a/go.mod b/go.mod index 6db391a1c..96f80264d 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/syself/cluster-api-provider-hetzner go 1.19 -replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.2.2 +replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.2.3 require ( github.com/blang/semver v3.5.1+incompatible @@ -24,8 +24,8 @@ require ( k8s.io/klog/v2 v2.80.1 k8s.io/kubectl v0.25.2 k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed - sigs.k8s.io/cluster-api v1.2.2 - sigs.k8s.io/cluster-api/test v1.2.2 + sigs.k8s.io/cluster-api v1.2.3 + sigs.k8s.io/cluster-api/test v1.2.3 sigs.k8s.io/controller-runtime v0.12.3 sigs.k8s.io/kind v0.16.0 ) diff --git a/go.sum b/go.sum index 002e44430..69e2955a1 100644 --- a/go.sum +++ b/go.sum @@ -1141,10 +1141,10 @@ k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/cluster-api v1.2.2 h1:acx31Eyv5s4xeublsbxWpRFjcQ5h4BmDPI0glm3sEoE= -sigs.k8s.io/cluster-api v1.2.2/go.mod h1:oiuV+mlCV1QxDnuI+PfElFlAfuXHo9ZGVBojoihVtHY= -sigs.k8s.io/cluster-api/test v1.2.2 h1:DUVmlCVQ0H7zY1doxzS1JuooUjXxTN80i9swc16tZd0= -sigs.k8s.io/cluster-api/test v1.2.2/go.mod h1:JdMqpv9rEOFWQVQ8danpBduqxoQkZMiOvpIGJ7v8qjw= +sigs.k8s.io/cluster-api v1.2.3 h1:NWtaadQHhl/H1hWp6Z6jXJwZU8o6SDRgN5stkVqk5L8= +sigs.k8s.io/cluster-api v1.2.3/go.mod h1:YaLJOC9mSsIOpdbh7BpthGmC8uxIJADzrMMIGpgahfM= +sigs.k8s.io/cluster-api/test v1.2.3 h1:B8UKXBwLrEl0GTlzZrHtpQDiZXWXHRKbSHsHI3gYrmI= +sigs.k8s.io/cluster-api/test v1.2.3/go.mod h1:C+UT2CXWNu3eAoeI0HHI19ex90pAdzAqR6YjhxRNHyM= sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio= sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0= sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= diff --git a/hack/ensure-boilerplate.sh b/hack/ensure-boilerplate.sh deleted file mode 120000 index b76cd1ee3..000000000 --- a/hack/ensure-boilerplate.sh +++ /dev/null @@ -1 +0,0 @@ -../hack/verify-boilerplate.sh \ No newline at end of file diff --git a/hack/ensure-boilerplate.sh b/hack/ensure-boilerplate.sh new file mode 100755 index 000000000..a9e362018 --- /dev/null +++ b/hack/ensure-boilerplate.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Copyright 2014 The Kubernetes Authors. +# +# 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 errexit +set -o nounset +set -o pipefail + +if [ "$(uname)" = 'Darwin' ]; then + readlinkf(){ perl -MCwd -e 'print Cwd::abs_path shift' "$1";} +else + readlinkf(){ readlink -f "$1"; } +fi + +# shellcheck disable=SC2128 +SCRIPT_DIR="$(cd "$(dirname "$(readlinkf "$BASH_SOURCE")")" ; pwd)" + +# We assume the link to the script ( {ensure,verify}-boilerplate.sh ) to be +# in a directory 2 levels down from the repo root, e.g. in +# /repo-infra/verify/verify-boilerplate.sh +# Alternatively, you can set the project root by setting the variable +# `REPO_ROOT`. +# +# shellcheck disable=SC2128 +: "${REPO_ROOT:="$(cd "${SCRIPT_DIR}/.." ; pwd)"}" + +boilerDir="${SCRIPT_DIR}/boilerplate/" +boiler="${boilerDir}/boilerplate.py" + +verify() { + # shellcheck disable=SC2207 + files_need_boilerplate=( + $( "$boiler" --rootdir="$REPO_ROOT" --boilerplate-dir="$boilerDir" "$@") + ) + + # Run boilerplate check + if [[ ${#files_need_boilerplate[@]} -gt 0 ]]; then + for file in "${files_need_boilerplate[@]}"; do + echo "Boilerplate header is wrong for: ${file}" >&2 + done + + return 1 + fi +} + +ensure() { + "$boiler" --rootdir="$REPO_ROOT" --boilerplate-dir="$boilerDir" --ensure "$@" +} + +case "$0" in + */ensure-boilerplate.sh) + ensure "$@" + ;; + */verify-boilerplate.sh) + verify "$@" + ;; + *) + { + echo "unknown command '$0'" + echo "" + echo "Call the script as either 'verify-boilerplate.sh' or 'ensure-boilerplate.sh'" + } >&2 + + exit 1 + ;; +esac diff --git a/test/e2e/config/hetzner-ci.yaml b/test/e2e/config/hetzner-ci.yaml index 0fc81e4f5..523e872df 100644 --- a/test/e2e/config/hetzner-ci.yaml +++ b/test/e2e/config/hetzner-ci.yaml @@ -13,8 +13,8 @@ providers: - name: cluster-api type: CoreProvider versions: - - name: v1.2.2 # latest published release in the v1beta1 series; this is used for v1beta1 - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/core-components.yaml" + - name: v1.2.3 # latest published release in the v1beta1 series; this is used for v1beta1 + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/core-components.yaml" type: "url" contract: v1beta1 files: @@ -30,8 +30,8 @@ providers: - name: kubeadm type: BootstrapProvider versions: - - name: v1.2.2 # latest published release in the v1beta1 series; this is used for v1beta1 - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/bootstrap-components.yaml" + - name: v1.2.3 # latest published release in the v1beta1 series; this is used for v1beta1 + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/bootstrap-components.yaml" type: "url" contract: "v1beta1" files: @@ -47,8 +47,8 @@ providers: - name: kubeadm type: ControlPlaneProvider versions: - - name: v1.2.2 # latest published release in the v1beta1 series; this is used for v1beta1 - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/control-plane-components.yaml" + - name: v1.2.3 # latest published release in the v1beta1 series; this is used for v1beta1 + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/control-plane-components.yaml" type: "url" files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" @@ -158,7 +158,7 @@ variables: intervals: default/wait-cluster: ["20m", "10s"] - default/wait-control-plane: ["20m", "10s"] + default/wait-control-plane: ["25m", "10s"] default/wait-worker-nodes: ["15m", "10s"] default/wait-controllers: ["5m", "10s"] default/wait-delete-cluster: ["20m", "10s"] diff --git a/test/e2e/config/hetzner.yaml b/test/e2e/config/hetzner.yaml index b194defff..a78b004e5 100644 --- a/test/e2e/config/hetzner.yaml +++ b/test/e2e/config/hetzner.yaml @@ -13,8 +13,8 @@ providers: - name: cluster-api type: CoreProvider versions: - - name: v1.2.2 # latest published release in the v1beta1 series; this is used for v1beta1 - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/core-components.yaml" + - name: v1.2.3 # latest published release in the v1beta1 series; this is used for v1beta1 + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/core-components.yaml" type: "url" contract: v1beta1 files: @@ -30,8 +30,8 @@ providers: - name: kubeadm type: BootstrapProvider versions: - - name: v1.2.2 # latest published release in the v1beta1 series; this is used for v1beta1 - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/bootstrap-components.yaml" + - name: v1.2.3 # latest published release in the v1beta1 series; this is used for v1beta1 + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/bootstrap-components.yaml" type: "url" contract: "v1beta1" files: @@ -47,8 +47,8 @@ providers: - name: kubeadm type: ControlPlaneProvider versions: - - name: v1.2.2 # latest published release in the v1beta1 series; this is used for v1beta1 - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/control-plane-components.yaml" + - name: v1.2.3 # latest published release in the v1beta1 series; this is used for v1beta1 + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/control-plane-components.yaml" type: "url" files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" @@ -164,7 +164,7 @@ variables: intervals: default/wait-cluster: ["20m", "10s"] - default/wait-control-plane: ["20m", "10s"] + default/wait-control-plane: ["25m", "10s"] default/wait-worker-nodes: ["15m", "10s"] default/wait-controllers: ["5m", "10s"] default/wait-delete-cluster: ["20m", "10s"]