From 7ae0405537dfae353800bb46cf11cc84d39a749d Mon Sep 17 00:00:00 2001 From: Ivan Ka <5395690+ivankatliarchuk@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:37:06 +0100 Subject: [PATCH] chore(dependencies): update toools versions (#5252) * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk * chore(dependencies): update toools versions Signed-off-by: ivan katliarchuk --------- Signed-off-by: ivan katliarchuk --- .github/renovate-config.js | 10 +++- .github/workflows/ci.yaml | 1 + Makefile | 24 +++++----- scripts/install-tools.sh | 95 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 14 deletions(-) create mode 100755 scripts/install-tools.sh diff --git a/.github/renovate-config.js b/.github/renovate-config.js index d21caf1c5..9d3803f41 100644 --- a/.github/renovate-config.js +++ b/.github/renovate-config.js @@ -52,6 +52,14 @@ module.exports = { "depNameTemplate": "kubernetes-sigs/external-dns", "datasourceTemplate": "github-releases", "versioningTemplate": "semver" - } + }, + { + "customType": "regex", + "fileMatch": [".*"], + "matchStrings": [ + "datasource=(?.*?) depName=(?.*?)( versioning=(?.*?))?\\s.*?_VERSION=(?.*)\\s" + ], + "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}", + }, ] }; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 030ad5887..777270ffe 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,3 +47,4 @@ jobs: with: path-to-profile: profile.cov if: github.actor != 'nektos/act' + continue-on-error: true diff --git a/Makefile b/Makefile index 8b0bd52fe..8cff3cba3 100644 --- a/Makefile +++ b/Makefile @@ -24,28 +24,26 @@ cover-html: cover @go tool cover -html=cover.out #? controller-gen: download controller-gen if necessary -controller-gen: +controller-gen-install: + @scripts/install-tools.sh --generator ifeq (, $(shell which controller-gen)) - @{ \ - set -e ;\ - go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 ;\ - } CONTROLLER_GEN=$(GOBIN)/controller-gen else CONTROLLER_GEN=$(shell which controller-gen) endif -#? golangci-lint: Install golangci-lint tool -golangci-lint: - @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2 +#? controller-gen-install: download controller-gen if necessary +controller-gen-install: + @scripts/install-tools.sh --generator -#? golangci-lint-verify: Verify golangci-lint configuration -golangci-lint-verify: golangci-lint - @golangci-lint config verify +#? golangci-lint-install: Install golangci-lint tool +golangci-lint-install: + @scripts/install-tools.sh --golangci #? go-lint: Run the golangci-lint tool .PHONY: go-lint -go-lint: golangci-lint +go-lint: golangci-lint-install + golangci-lint config verify gofmt -l -s -w . golangci-lint run --timeout=30m --fix ./... @@ -71,7 +69,7 @@ lint: licensecheck go-lint oas-lint #? crd: Generates CRD using controller-gen .PHONY: crd -crd: controller-gen +crd: controller-gen-install ${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." output:crd:stdout > docs/contributing/crd-source/crd-manifest.yaml #? test: The verify target runs tasks similar to the CI tasks, but without code coverage diff --git a/scripts/install-tools.sh b/scripts/install-tools.sh new file mode 100755 index 000000000..56b440778 --- /dev/null +++ b/scripts/install-tools.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +# Copyright 2025 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. + +# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools +CONTROLLER_TOOLS_GENERATOR_VERSION=v0.15.0 +# renovate: datasource=github-releases depName=golangci/golangci-lint +GOLANG_CI_LINTER_VERSION=v2.0.2 + +# Execute +# scripts/install-tools.sh +# scripts/install-tools.sh -h +# scripts/install-tools.sh --generator +# scripts/install-tools.sh --golangci + +show_help() { +cat << EOF +'external-dns' helm linter helper commands + +Usage: $(basename "$0") + -h, --help Display help + --generator Install generator + --golangci Install golangci linter +EOF +} + +install_generator() { + # https://github.com/kubernetes-sigs/controller-tools/blob/main/cmd/controller-gen/main.go + local install=false + if [[ -x $(which controller-gen) ]]; then + local version=$(controller-gen --version | sed 's/Version: //') + if [[ "${version}" == "${CONTROLLER_TOOLS_GENERATOR_VERSION}" ]]; then + install=false + else + install=true + fi + else + install=true + fi + if [[ "$install" == true ]]; then + set -ex ;\ + go install sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_TOOLS_GENERATOR_VERSION} ; + fi +} + +install_golangci() { + local install=false + if [[ -x $(which golangci-lint) ]]; then + local version=$(golangci-lint version --short) + if [[ "${version}" == "${GOLANG_CI_LINTER_VERSION#v}" ]]; then + install=false + else + install=true + fi + else + install=true + fi + if [[ "$install" == true ]]; then + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/cc3567e3127d8530afb69be1b7bd20ba9ebcc7c1/install.sh \ + | sh -s -- -b $(go env GOPATH)/bin "${GOLANG_CI_LINTER_VERSION}" + fi +} + +function main() { + case $1 in + --generator) + install_generator + ;; + --golangci) + install_golangci + ;; + -h|--help) + show_help + ;; + *) + echo "unknown sub-command" >&2 + show_help + exit 1 + ;; + esac +} + +main "$@"