From a6a9a0794524e155392cffae2b2c5c8c857af9b6 Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Fri, 3 Nov 2023 11:30:34 -0500 Subject: [PATCH 1/4] Update buf to version with protovalidate linter --- .github/workflows/buf.yaml | 26 ++++++++++++++++++-------- Makefile | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index e850a7c..ce2fc34 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -3,20 +3,30 @@ on: push: jobs: lint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1 - - uses: bufbuild/buf-lint-action@v1.0.3 + - uses: actions/checkout@v4 + - name: Install buf cli + run: | + go install github.com/bufbuild/buf/cmd/buf@21ba19590be4afe6fa3af0406e138c4fdc36fedf + #uses: bufbuild/buf-setup-action@v1 + #with: + # github_token: ${{ github.token }} + - uses: bufbuild/buf-lint-action@v1 push: environment: production - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' needs: - lint steps: - - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1 - - uses: bufbuild/buf-push-action@v1.1.1 + - uses: actions/checkout@v4 + - name: Install buf cli + run: | + go install github.com/bufbuild/buf/cmd/buf@21ba19590be4afe6fa3af0406e138c4fdc36fedf + #uses: bufbuild/buf-setup-action@v1 + #with: + # github_token: ${{ github.token }} + - uses: bufbuild/buf-push-action@v1 with: buf_token: ${{ secrets.BUF_TOKEN }} diff --git a/Makefile b/Makefile index fc73706..a536dbc 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ BIN := .tmp/bin export PATH := $(BIN):$(PATH) export GOBIN := $(abspath $(BIN)) -BUF_VERSION := v1.27.1 +BUF_VERSION := 21ba19590be4afe6fa3af0406e138c4fdc36fedf COPYRIGHT_YEARS := 2023 .PHONY: help From 667ef0e945e01b53fd84c9776eb12bf65a85cfdc Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Fri, 3 Nov 2023 11:33:56 -0500 Subject: [PATCH 2/4] fix workflow --- .github/workflows/buf.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index ce2fc34..4932dc0 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -6,13 +6,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install buf cli + - name: Lint run: | - go install github.com/bufbuild/buf/cmd/buf@21ba19590be4afe6fa3af0406e138c4fdc36fedf - #uses: bufbuild/buf-setup-action@v1 - #with: - # github_token: ${{ github.token }} - - uses: bufbuild/buf-lint-action@v1 + make lint push: environment: production runs-on: ubuntu-latest @@ -22,11 +18,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install buf cli - run: | - go install github.com/bufbuild/buf/cmd/buf@21ba19590be4afe6fa3af0406e138c4fdc36fedf - #uses: bufbuild/buf-setup-action@v1 - #with: - # github_token: ${{ github.token }} + uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ github.token }} - uses: bufbuild/buf-push-action@v1 with: buf_token: ${{ secrets.BUF_TOKEN }} From 145f982372a2f0336ae0797f900369184c186586 Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Fri, 3 Nov 2023 11:39:40 -0500 Subject: [PATCH 3/4] fix lint errors --- buf/registry/owner/v1beta1/organization.proto | 8 ++++---- buf/registry/owner/v1beta1/owner.proto | 8 ++++---- buf/registry/owner/v1beta1/user.proto | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/buf/registry/owner/v1beta1/organization.proto b/buf/registry/owner/v1beta1/organization.proto index ba8ee05..fd1e1c9 100644 --- a/buf/registry/owner/v1beta1/organization.proto +++ b/buf/registry/owner/v1beta1/organization.proto @@ -78,9 +78,9 @@ message OrganizationRef { // The id of the Organization. string id = 1 [(buf.validate.field).string.uuid = true]; // The name of the Organization. - string name = 2 [ - (buf.validate.field).required = true, - (buf.validate.field).string.max_len = 255 - ]; + string name = 2 [(buf.validate.field).string = { + min_len: 1; + max_len: 255; + }]; } } diff --git a/buf/registry/owner/v1beta1/owner.proto b/buf/registry/owner/v1beta1/owner.proto index f86fc13..0330f33 100644 --- a/buf/registry/owner/v1beta1/owner.proto +++ b/buf/registry/owner/v1beta1/owner.proto @@ -47,9 +47,9 @@ message OwnerRef { // The id of the User or Organization. string id = 1 [(buf.validate.field).string.uuid = true]; // The name of the User or Organization. - string name = 2 [ - (buf.validate.field).required = true, - (buf.validate.field).string.max_len = 255 - ]; + string name = 2 [(buf.validate.field).string = { + min_len: 1; + max_len: 255; + }]; } } diff --git a/buf/registry/owner/v1beta1/user.proto b/buf/registry/owner/v1beta1/user.proto index deb0f12..788ac58 100644 --- a/buf/registry/owner/v1beta1/user.proto +++ b/buf/registry/owner/v1beta1/user.proto @@ -116,9 +116,9 @@ message UserRef { // The id of the User. string id = 1 [(buf.validate.field).string.uuid = true]; // The name of the User. - string name = 2 [ - (buf.validate.field).required = true, - (buf.validate.field).string.max_len = 255 - ]; + string name = 2 [(buf.validate.field).string = { + min_len: 1; + max_len: 255; + }]; } } From 2a114e7919a4a09113a494cc4188b98c3e72e14b Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Fri, 3 Nov 2023 11:41:32 -0500 Subject: [PATCH 4/4] add caching to buf workflow --- .github/workflows/buf.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index 4932dc0..94ad9be 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -6,6 +6,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: install + uses: actions/setup-go@v4 + with: + go-version: 1.21.x + - name: cache + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-registry-proto-ci-${{ hashFiles('**/Makefile') }} + restore-keys: ${{ runner.os }}-registry-proto-ci- - name: Lint run: | make lint