From 35ee43d5382f1004c8217157a1fc5b063cc9059e Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 13 Jan 2025 13:40:55 -0500 Subject: [PATCH 1/6] remove build tags from cmd main files --- cmd/helm-locker/main.go | 2 -- cmd/helm-project-operator/main.go | 2 -- cmd/prometheus-federator/main.go | 2 -- 3 files changed, 6 deletions(-) diff --git a/cmd/helm-locker/main.go b/cmd/helm-locker/main.go index 3b05cf12..0117396d 100644 --- a/cmd/helm-locker/main.go +++ b/cmd/helm-locker/main.go @@ -1,5 +1,3 @@ -//go:build helm_locker - package main import ( diff --git a/cmd/helm-project-operator/main.go b/cmd/helm-project-operator/main.go index 24d02b8e..1d579f20 100644 --- a/cmd/helm-project-operator/main.go +++ b/cmd/helm-project-operator/main.go @@ -1,5 +1,3 @@ -//go:build helm_project_operator - package main import ( diff --git a/cmd/prometheus-federator/main.go b/cmd/prometheus-federator/main.go index 9941b45a..334a5d42 100644 --- a/cmd/prometheus-federator/main.go +++ b/cmd/prometheus-federator/main.go @@ -1,5 +1,3 @@ -//go:build prometheus_federator - package main import ( From 452e3fb197ed6826a3947ba333f48afc0f695b7a Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 13 Jan 2025 13:47:29 -0500 Subject: [PATCH 2/6] update script to build based on path --- scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build b/scripts/build index 66933d42..8e01d306 100755 --- a/scripts/build +++ b/scripts/build @@ -2,7 +2,7 @@ set -e source $(dirname $0)/version -BUILD_CMD_TARGET=${BUILD_CMD_TARGET:-"./cmd/${BUILD_TARGET}/main.go"} +BUILD_CMD_TARGET=${BUILD_CMD_TARGET:-"./cmd/${BUILD_TARGET}/"} cd $(dirname $0)/.. From 56ff122a64c5a0f42dbe595c9dde59272e5d1344 Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 13 Jan 2025 13:52:32 -0500 Subject: [PATCH 3/6] fix lint --- cmd/helm-project-operator/main.go | 2 +- cmd/prometheus-federator/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm-project-operator/main.go b/cmd/helm-project-operator/main.go index 1d579f20..a915a59c 100644 --- a/cmd/helm-project-operator/main.go +++ b/cmd/helm-project-operator/main.go @@ -34,7 +34,7 @@ var ( base64TgzChart string debugConfig command.DebugConfig - updateCRDs bool = false + updateCRDs = false ) type DummyOperator struct { diff --git a/cmd/prometheus-federator/main.go b/cmd/prometheus-federator/main.go index 334a5d42..c6740879 100644 --- a/cmd/prometheus-federator/main.go +++ b/cmd/prometheus-federator/main.go @@ -35,7 +35,7 @@ var ( base64TgzChart string debugConfig command.DebugConfig - updateCRDs bool = false + updateCRDs = false ) type PrometheusFederator struct { From 08cd96a182b0a1076e9936817904540f5ad0cc5e Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 13 Jan 2025 14:13:01 -0500 Subject: [PATCH 4/6] Scope tests and validate w/o build tags Per title, this scopes the test and validate scripts to the current build target. The current behaviour with the tags actually fully excludes these which is why the errors (this commit fixes) don't exist with the tags in place. --- scripts/test | 9 ++++++--- scripts/validate | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/test b/scripts/test index 08b188af..c3609303 100755 --- a/scripts/test +++ b/scripts/test @@ -6,7 +6,10 @@ cd $(dirname $0)/.. echo "Starating tests" -TARGET_TEST_TAG="${BUILD_TARGET/-/_}" +echo "Running tests for ${BUILD_TARGET}" -echo "Running tests for ${TARGET_TEST_TAG}" -go test -cover -tags="test,${TARGET_TEST_TAG}" ./... +PKG_LIST=$(go list "./cmd/${BUILD_TARGET}/...") +ALL_PKG_LIST=$(go list ./pkg/...) +COMBINED_LIST="$PKG_LIST $ALL_PKG_LIST" + +go test -cover $COMBINED_LIST diff --git a/scripts/validate b/scripts/validate index c6f98c57..3b0a50a6 100755 --- a/scripts/validate +++ b/scripts/validate @@ -4,7 +4,11 @@ set -e cd $(dirname $0)/.. echo "Running validation" -PACKAGES="$(go list ./...)" + +PKG_LIST=$(go list "./cmd/${BUILD_TARGET}/...") +ALL_PKG_LIST=$(go list ./pkg/...) +COMBINED_LIST="$PKG_LIST $ALL_PKG_LIST" + echo Running: go fmt -test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)" +test -z "$(go fmt ${COMBINED_LIST} | tee /dev/stderr)" echo "Validate passed" \ No newline at end of file From 99b78f5ed7737bd7db97df514b0a9c2b78aaedf3 Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 13 Jan 2025 14:21:05 -0500 Subject: [PATCH 5/6] Update lint workflow to build both necessary charts --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 537a518a..7a673446 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -30,7 +30,7 @@ jobs: helm version rm get_helm.sh - name: Package helm chart - run : ./scripts/build-chart + run : ./scripts/build-chart && BUILD_TARGET=helm-project-operator ./scripts/build-chart - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: From 523834d413dbd909d9101feb242655670f877bca Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 13 Jan 2025 14:26:30 -0500 Subject: [PATCH 6/6] fix validate & make more verbose --- scripts/validate | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/validate b/scripts/validate index 3b0a50a6..1fe13659 100755 --- a/scripts/validate +++ b/scripts/validate @@ -1,14 +1,16 @@ #!/usr/bin/env bash set -e +source $(dirname $0)/version cd $(dirname $0)/.. echo "Running validation" +echo "Collecting packages to validate for target: ${BUILD_TARGET}" PKG_LIST=$(go list "./cmd/${BUILD_TARGET}/...") ALL_PKG_LIST=$(go list ./pkg/...) COMBINED_LIST="$PKG_LIST $ALL_PKG_LIST" -echo Running: go fmt +echo "Running: go fmt" test -z "$(go fmt ${COMBINED_LIST} | tee /dev/stderr)" echo "Validate passed" \ No newline at end of file