From 0f58a556c241cf5be65ad270b75d7a6f2177629c Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Fri, 27 Oct 2023 14:33:01 -0700 Subject: [PATCH 1/7] Push Protobufs to Buf Schema Registry This registry generates us documentation. I believe it also allows us to avoid copying around protobuf files, which we currently need to do for each SDK (e.g. https://github.com/crossplane/function-sdk-go/tree/main/proto). Signed-off-by: Nic Cope --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ apis/buf.lock | 7 +++++++ apis/buf.yaml | 10 ++++++++++ 3 files changed, 49 insertions(+) create mode 100644 apis/buf.lock create mode 100644 apis/buf.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7e9aa86d..899b21a02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -451,3 +451,35 @@ jobs: with: name: artifacts path: ./out/artifacts + + + protobuf-schemas: + runs-on: ubuntu-22.04 + needs: detect-noop + if: needs.detect-noop.outputs.noop != 'true' + + steps: + + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + - name: Setup Buf + uses: bufbuild/buf-setup-action@v1 + + - name: Lint Protocol Buffers + uses: bufbuild/buf-lint-action@v1 + with: + input: apis + + - name: Detect Breaking Changes in Protocol Buffers + uses: bufbuild/buf-breaking-action@v1 + with: + input: apis + against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=master,subdir=apis" + + - name: Push Protocol Buffers to Buf Schema Registry + if: github.ref == 'refs/heads/master' + uses: bufbuild/buf-push-action@v1 + with: + input: apis + buf_token: ${{ secrets.BUF_TOKEN }} \ No newline at end of file diff --git a/apis/buf.lock b/apis/buf.lock new file mode 100644 index 000000000..7f8e75348 --- /dev/null +++ b/apis/buf.lock @@ -0,0 +1,7 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: protocolbuffers + repository: wellknowntypes + commit: 44e83bc050a4497fa7b36b34d95ca156 diff --git a/apis/buf.yaml b/apis/buf.yaml new file mode 100644 index 000000000..af88baa11 --- /dev/null +++ b/apis/buf.yaml @@ -0,0 +1,10 @@ +version: v1 +name: buf.build/crossplane/crossplane +deps: +- buf.build/protocolbuffers/wellknowntypes:v24.4 +breaking: + use: + - FILE +lint: + use: + - DEFAULT From 62f2f020b4e9c4353ff39f168fc92c58be26d9bb Mon Sep 17 00:00:00 2001 From: Philippe Scorsolini Date: Thu, 2 Nov 2023 14:37:19 +0100 Subject: [PATCH 2/7] ci: only push to buf registry on crossplane repo Signed-off-by: Philippe Scorsolini --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 899b21a02..aff65ae4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -478,7 +478,7 @@ jobs: against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=master,subdir=apis" - name: Push Protocol Buffers to Buf Schema Registry - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' && github.repository == 'crossplane/crossplane' uses: bufbuild/buf-push-action@v1 with: input: apis From 26b71cd2c02b3c8bee0fe04d37afafeed4bd0b53 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Thu, 2 Nov 2023 12:08:35 -0700 Subject: [PATCH 3/7] Support pushing to BSR from release branches I'm on the fence as to whether this should be done here or as part of the 'Promote' workflow, which I believe is how we usually 'ship' stuff. Signed-off-by: Nic Cope --- .github/workflows/ci.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aff65ae4b..8a324efd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -452,14 +452,14 @@ jobs: name: artifacts path: ./out/artifacts - + # TODO(negz): Refactor this job. Should the parts pertaining to release + # branches live in promote.yaml instead? protobuf-schemas: runs-on: ubuntu-22.04 needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' steps: - - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 @@ -471,15 +471,25 @@ jobs: with: input: apis - - name: Detect Breaking Changes in Protocol Buffers - uses: bufbuild/buf-breaking-action@v1 + - name: Detect Breaking Changes in Protocol Buffers (Master Branch) + uses: bufbuild/buf-breaking-action@a074e988ee34efcd4927079e79c611f428354c01 # v1 + # We want to run this for the master branch, and PRs. + if: ${{ ! startsWith(github.ref, 'refs/heads/release-') }} with: input: apis against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=master,subdir=apis" + + - name: Detect Breaking Changes in Protocol Buffers (Release Branch) + uses: bufbuild/buf-breaking-action@a074e988ee34efcd4927079e79c611f428354c01 # v1 + # We want to run this only on release branches. + if: ${{ startsWith(github.ref, 'refs/heads/release-') }} + with: + input: apis + against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${GITHUB_REF_NAME},subdir=apis" - name: Push Protocol Buffers to Buf Schema Registry - if: github.ref == 'refs/heads/master' && github.repository == 'crossplane/crossplane' + if: ${{ github.repository == 'crossplane/crossplane' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-')) }} uses: bufbuild/buf-push-action@v1 with: input: apis - buf_token: ${{ secrets.BUF_TOKEN }} \ No newline at end of file + buf_token: ${{ secrets.BUF_TOKEN }} From 8de82bfa164346ebade704254d03a1500b026efa Mon Sep 17 00:00:00 2001 From: Murph Date: Mon, 6 Nov 2023 16:07:43 -0600 Subject: [PATCH 4/7] Return after single arch push Signed-off-by: Murph (cherry picked from commit c4de68a8d8bbc0486920729ad76c8b8d17f434b9) --- cmd/crank/xpkg/push.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/crank/xpkg/push.go b/cmd/crank/xpkg/push.go index 4d17c89d6..cdd3ec976 100644 --- a/cmd/crank/xpkg/push.go +++ b/cmd/crank/xpkg/push.go @@ -132,6 +132,7 @@ func (c *pushCmd) Run(logger logging.Logger) error { //nolint:gocyclo // This fe return errors.Wrapf(err, errFmtPushPackage, c.PackageFiles[0]) } logger.Debug("Pushed package", "path", c.PackageFiles[0], "ref", tag.String()) + return nil } // If there's more than one package file we'll write (push) them all by From 58c06ead18d5d3a64b994330251d156103c11065 Mon Sep 17 00:00:00 2001 From: Murph Date: Mon, 6 Nov 2023 16:15:12 -0600 Subject: [PATCH 5/7] fix indentation Signed-off-by: Murph (cherry picked from commit d05720f9d47263f6e413e0d12ed218c5d3e931d1) --- cmd/crank/xpkg/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/crank/xpkg/push.go b/cmd/crank/xpkg/push.go index cdd3ec976..fb9a7516e 100644 --- a/cmd/crank/xpkg/push.go +++ b/cmd/crank/xpkg/push.go @@ -132,7 +132,7 @@ func (c *pushCmd) Run(logger logging.Logger) error { //nolint:gocyclo // This fe return errors.Wrapf(err, errFmtPushPackage, c.PackageFiles[0]) } logger.Debug("Pushed package", "path", c.PackageFiles[0], "ref", tag.String()) - return nil + return nil } // If there's more than one package file we'll write (push) them all by From 041c3528eb41773db6c75af1e38a0733875d70d6 Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Tue, 14 Nov 2023 07:40:05 +0300 Subject: [PATCH 6/7] Bump crossplane runtime to v1.14.2 Signed-off-by: Hasan Turken --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 52aafea84..7093e2819 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/Masterminds/semver v1.5.0 github.com/alecthomas/kong v0.8.1 github.com/bufbuild/buf v1.27.1 - github.com/crossplane/crossplane-runtime v1.14.0 + github.com/crossplane/crossplane-runtime v1.14.2 github.com/docker/docker v24.0.6+incompatible github.com/docker/go-connections v0.4.0 github.com/emicklei/dot v1.6.0 diff --git a/go.sum b/go.sum index c20841adc..af1601ecd 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0q github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= -github.com/crossplane/crossplane-runtime v1.14.0 h1:MFo93iOJLvYaMCaCoyH2vFWsHebdA1kv3QdOm7hcm5k= -github.com/crossplane/crossplane-runtime v1.14.0/go.mod h1:aOP+5W2wKpvthVs3pFNbVOe1jwrKYbJho0ThGNCVz9o= +github.com/crossplane/crossplane-runtime v1.14.2 h1:pV5JMzyzi/kcbeVBVPCat5MHH8zS94MBUapAyGx/Ry0= +github.com/crossplane/crossplane-runtime v1.14.2/go.mod h1:aOP+5W2wKpvthVs3pFNbVOe1jwrKYbJho0ThGNCVz9o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= From d18ef77a0e6e0b775942bb3550fc4206c0c115ef Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Tue, 14 Nov 2023 08:11:59 +0300 Subject: [PATCH 7/7] Fix unit tests for unstructured deepcopy Signed-off-by: Hasan Turken --- internal/controller/apiextensions/claim/reconciler_test.go | 4 ++-- .../controller/apiextensions/composite/reconciler_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/controller/apiextensions/claim/reconciler_test.go b/internal/controller/apiextensions/claim/reconciler_test.go index 42165c2f2..9b6ac76cc 100644 --- a/internal/controller/apiextensions/claim/reconciler_test.go +++ b/internal/controller/apiextensions/claim/reconciler_test.go @@ -757,7 +757,7 @@ func TestReconcile(t *testing.T) { var customStatusUpdate test.MockSubResourceUpdateFn mockGet := func(ctx context.Context, key client.ObjectKey, obj client.Object) error { if o, ok := obj.(*claim.Unstructured); ok { - tc.args.claim.DeepCopyInto(&o.Unstructured) + tc.args.claim.Unstructured.DeepCopyInto(&o.Unstructured) return nil } if customGet != nil { @@ -768,7 +768,7 @@ func TestReconcile(t *testing.T) { mockStatusUpdate := func(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error { if o, ok := obj.(*claim.Unstructured); ok { - o.DeepCopyInto(&tc.args.claim.Unstructured) + o.Unstructured.DeepCopyInto(&tc.args.claim.Unstructured) } if customStatusUpdate != nil { return customStatusUpdate(ctx, obj, opts...) diff --git a/internal/controller/apiextensions/composite/reconciler_test.go b/internal/controller/apiextensions/composite/reconciler_test.go index cbde151da..a364a79a4 100644 --- a/internal/controller/apiextensions/composite/reconciler_test.go +++ b/internal/controller/apiextensions/composite/reconciler_test.go @@ -1011,14 +1011,14 @@ func TestEnqueueForCompositionRevisionFunc(t *testing.T) { obj1.SetCompositionUpdatePolicy(&automatic) obj1.SetCompositionReference(&corev1.ObjectReference{Name: "dachshund"}) - obj2 := composite.Unstructured{Unstructured: *obj1.DeepCopy()} + obj2 := composite.Unstructured{Unstructured: *obj1.Unstructured.DeepCopy()} obj2.SetName("obj2") - obj3 := composite.Unstructured{Unstructured: *obj1.DeepCopy()} + obj3 := composite.Unstructured{Unstructured: *obj1.Unstructured.DeepCopy()} obj3.SetName("obj3") obj3.SetCompositionReference(&corev1.ObjectReference{Name: "bernese"}) - obj4 := composite.Unstructured{Unstructured: *obj1.DeepCopy()} + obj4 := composite.Unstructured{Unstructured: *obj1.Unstructured.DeepCopy()} obj4.SetName("obj4") manual := xpv1.UpdateManual obj4.SetCompositionUpdatePolicy(&manual)