From 5d9c550aedc2b7b9e25a001d5afc8e2981510b99 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Fri, 17 Mar 2023 16:42:25 -0700 Subject: [PATCH 1/3] Bump versions in .github workflow Signed-off-by: Nic Cope --- .github/workflows/ci.yml | 34 +++++++++++++++++----------------- Makefile | 13 +++++++++++-- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66d45fbfb..552366904 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ on: env: # Common versions - GO_VERSION: '1.19.5' - GOLANGCI_VERSION: 'v1.50.1' + GO_VERSION: '1.20.1' + GOLANGCI_VERSION: 'v1.51.1' jobs: check-diff: @@ -30,17 +30,17 @@ jobs: - name: Find the Go Build Cache id: go - run: echo "::set-output name=cache::$(go env GOCACHE)" + run: echo "::set-output name=cache::$(make go.cachedir)" - name: Cache the Go Build Cache - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-check-diff- - name: Cache Go Dependencies - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -84,17 +84,17 @@ jobs: - name: Find the Go Build Cache id: go - run: echo "::set-output name=cache::$(go env GOCACHE)" + run: echo "::set-output name=cache::$(make go.cachedir)" - name: Cache the Go Build Cache - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-lint- - name: Cache Go Dependencies - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -107,7 +107,7 @@ jobs: # this action because it leaves 'annotations' (i.e. it comments on PRs to # point out linter violations). - name: Lint - uses: golangci/golangci-lint-action@07db5389c99593f11ad7b44463c2d4233066a9b1 # v3 + uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3 with: version: ${{ env.GOLANGCI_VERSION }} skip-cache: true # We do our own caching. @@ -130,17 +130,17 @@ jobs: - name: Find the Go Build Cache id: go - run: echo "::set-output name=cache::$(go env GOCACHE)" + run: echo "::set-output name=cache::$(make go.cachedir)" - name: Cache the Go Build Cache - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-check-diff- - name: Cache Go Dependencies - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -150,12 +150,12 @@ jobs: run: make vendor vendor.check - name: Initialize CodeQL - uses: github/codeql-action/init@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2 + uses: github/codeql-action/init@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2 with: languages: go - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2 + uses: github/codeql-action/analyze@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2 unit-tests: runs-on: ubuntu-20.04 @@ -178,17 +178,17 @@ jobs: - name: Find the Go Build Cache id: go - run: echo "::set-output name=cache::$(go env GOCACHE)" + run: echo "::set-output name=cache::$(make go.cachedir)" - name: Cache the Go Build Cache - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-unit-tests- - name: Cache Go Dependencies - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3 + uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} diff --git a/Makefile b/Makefile index 4d797ded1..b67f7f17e 100644 --- a/Makefile +++ b/Makefile @@ -31,11 +31,10 @@ NPROCS ?= 1 # to half the number of CPU cores. GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 ))) -GO_REQUIRED_VERSION = 1.19 GO_LDFLAGS += -X $(GO_PROJECT)/pkg/version.Version=$(VERSION) GO_SUBDIRS += pkg apis GO111MODULE = on -GOLANGCILINT_VERSION = 1.49.0 +GOLANGCILINT_VERSION = 1.51.2 -include build/makelib/golang.mk # ==================================================================================== @@ -52,6 +51,16 @@ fallthrough: submodules @echo Initial setup complete. Running make again . . . @make + +# NOTE(hasheddan): the build submodule currently overrides XDG_CACHE_HOME in +# order to force the Helm 3 to use the .work/helm directory. This causes Go on +# Linux machines to use that directory as the build cache as well. We should +# adjust this behavior in the build submodule because it is also causing Linux +# users to duplicate their build cache, but for now we just make it easier to +# identify its location in CI so that we cache between builds. +go.cachedir: + @go env GOCACHE + # Generate a coverage report for cobertura applying exclusions on # - generated file cobertura: From e8004abee16e3200964793b11f2dddfb10c3b9ef Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Fri, 17 Mar 2023 17:15:29 -0700 Subject: [PATCH 2/3] Bump build Signed-off-by: Nic Cope --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 559e1532c..7da2fdeb3 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 559e1532cd1ec6471c295b9dfce89c38f9a4638f +Subproject commit 7da2fdeb3dc1ebbce8210a58616debe34ef0fd97 From 112e9eda457244cb4afd408a5c7764836779fab8 Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Wed, 22 Mar 2023 12:52:48 +0300 Subject: [PATCH 3/3] Add nolint directive for musttag on types used in unit tests Signed-off-by: Hasan Turken --- pkg/connection/fake/mocks.go | 2 +- pkg/reconciler/providerconfig/reconciler_test.go | 2 +- pkg/resource/fake/mocks.go | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/connection/fake/mocks.go b/pkg/connection/fake/mocks.go index 2adad4ea0..80b3c738f 100644 --- a/pkg/connection/fake/mocks.go +++ b/pkg/connection/fake/mocks.go @@ -52,7 +52,7 @@ func (ss *SecretStore) DeleteKeyValues(ctx context.Context, s *store.Secret, do } // StoreConfig is a mock implementation of the StoreConfig interface. -type StoreConfig struct { +type StoreConfig struct { //nolint:musttag // This is a fake implementation to be used in unit tests only. metav1.ObjectMeta Config v1.SecretStoreConfig diff --git a/pkg/reconciler/providerconfig/reconciler_test.go b/pkg/reconciler/providerconfig/reconciler_test.go index ea6013850..ef4332ef7 100644 --- a/pkg/reconciler/providerconfig/reconciler_test.go +++ b/pkg/reconciler/providerconfig/reconciler_test.go @@ -39,7 +39,7 @@ import ( // This can't live in fake, because it would cause an import cycle due to // GetItems returning managed.ProviderConfigUsage. -type ProviderConfigUsageList struct { +type ProviderConfigUsageList struct { //nolint:musttag // This is a fake implementation to be used in unit tests only. client.ObjectList Items []resource.ProviderConfigUsage } diff --git a/pkg/resource/fake/mocks.go b/pkg/resource/fake/mocks.go index 745d25ef3..ee25dbe0e 100644 --- a/pkg/resource/fake/mocks.go +++ b/pkg/resource/fake/mocks.go @@ -63,7 +63,7 @@ func (m *ManagedResourceReferencer) SetResourceReference(r *corev1.ObjectReferen func (m *ManagedResourceReferencer) GetResourceReference() *corev1.ObjectReference { return m.Ref } // ProviderReferencer is a mock that implements ProviderReferencer interface. -type ProviderReferencer struct{ Ref *xpv1.Reference } +type ProviderReferencer struct{ Ref *xpv1.Reference } //nolint:musttag // This is a fake implementation to be used in unit tests only. // SetProviderReference sets the ProviderReference. func (m *ProviderReferencer) SetProviderReference(p *xpv1.Reference) { m.Ref = p } @@ -82,7 +82,7 @@ func (m *ProviderConfigReferencer) GetProviderConfigReference() *xpv1.Reference // RequiredProviderConfigReferencer is a mock that implements the // RequiredProviderConfigReferencer interface. -type RequiredProviderConfigReferencer struct{ Ref xpv1.Reference } +type RequiredProviderConfigReferencer struct{ Ref xpv1.Reference } //nolint:musttag // This is a fake implementation to be used in unit tests only. // SetProviderConfigReference sets the ProviderConfigReference. func (m *RequiredProviderConfigReferencer) SetProviderConfigReference(p xpv1.Reference) { @@ -124,7 +124,7 @@ func (m *LocalConnectionSecretWriterTo) GetWriteConnectionSecretToReference() *x } // ConnectionSecretWriterTo is a mock that implements ConnectionSecretWriterTo interface. -type ConnectionSecretWriterTo struct{ Ref *xpv1.SecretReference } +type ConnectionSecretWriterTo struct{ Ref *xpv1.SecretReference } //nolint:musttag // This is a fake implementation to be used in unit tests only. // SetWriteConnectionSecretToReference sets the WriteConnectionSecretToReference. func (m *ConnectionSecretWriterTo) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { @@ -170,7 +170,7 @@ func (m *CompositionReferencer) SetCompositionReference(r *corev1.ObjectReferenc func (m *CompositionReferencer) GetCompositionReference() *corev1.ObjectReference { return m.Ref } // CompositionSelector is a mock that implements CompositionSelector interface. -type CompositionSelector struct{ Sel *metav1.LabelSelector } +type CompositionSelector struct{ Sel *metav1.LabelSelector } //nolint:musttag // This is a fake implementation to be used in unit tests only. // SetCompositionSelector sets the CompositionSelector. func (m *CompositionSelector) SetCompositionSelector(s *metav1.LabelSelector) { m.Sel = s } @@ -284,7 +284,7 @@ func (c *ConnectionDetailsLastPublishedTimer) GetConnectionDetailsLastPublishedT // UserCounter is a mock that satisfies UserCounter // interface. -type UserCounter struct{ Users int64 } +type UserCounter struct{ Users int64 } //nolint:musttag // This is a fake implementation to be used in unit tests only. // SetUsers sets the count of users. func (m *UserCounter) SetUsers(i int64) { @@ -482,7 +482,7 @@ func SchemeWith(o ...runtime.Object) *runtime.Scheme { // MockConnectionSecretOwner is a mock object that satisfies ConnectionSecretOwner // interface. -type MockConnectionSecretOwner struct { +type MockConnectionSecretOwner struct { //nolint:musttag // This is a fake implementation to be used in unit tests only. runtime.Object metav1.ObjectMeta @@ -528,7 +528,7 @@ func (m *MockConnectionSecretOwner) DeepCopyObject() runtime.Object { // MockLocalConnectionSecretOwner is a mock object that satisfies LocalConnectionSecretOwner // interface. -type MockLocalConnectionSecretOwner struct { +type MockLocalConnectionSecretOwner struct { //nolint:musttag // This is a fake implementation to be used in unit tests only. runtime.Object metav1.ObjectMeta