Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to support Go 1.23 #139

Merged
merged 6 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions .github/workflows/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Buf
on:
pull_request:
paths:
- 'proto/**'
push:
paths:
- 'proto/**'
delete:
paths:
- 'proto/**'
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
workflow_dispatch: { } # support manual runs

env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
permissions:
contents: read
pull-requests: write

jobs:
validate-protos:
Expand All @@ -22,17 +20,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install buf
uses: bufbuild/buf-setup-action@v1
fetch-depth: 2
- name: Buf CI
uses: bufbuild/buf-action@v1
with:
github_token: ${{ github.token }}
- name: Buf format
run: buf format -d --exit-code
- name: Buf lint
uses: bufbuild/buf-lint-action@v1
- name: Buf generate
run: |
mkdir -p .tmp/bin
cp $(which buf) .tmp/bin/buf
make checkgenerate
token: ${{ secrets.BUF_TOKEN }}
format: true
lint: true
breaking: true
push: false
archive: false
- name: Check Generate
run: make checkgenerate
13 changes: 7 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 1.20.x, 1.21.x, 1.22.x ]
go-version:
- 1.20.x
rodaine marked this conversation as resolved.
Show resolved Hide resolved
- 1.21.x
- 1.22.x
- 1.23.x
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -33,8 +37,5 @@ jobs:
- name: Lint
# Often, lint guidelines depend on the Go version. To prevent
# conflicting guidance, run only on the most recent supported version.
if: matrix.go-version == '1.22.x'
run: make lint
- name: Check Generate
if: matrix.go-version == '1.22.x'
run: make checkgenerate
rodaine marked this conversation as resolved.
Show resolved Hide resolved
if: matrix.go-version == '1.23.x'
run: make lint-go
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LICENSE_IGNORE := -e internal/testdata/
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
GO ?= go
ARGS ?= --strict --strict_message --strict_error
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.60.1
# Set to use a different version of protovalidate-conformance.
# Should be kept in sync with the version referenced in proto/buf.lock and
# 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go' in go.mod.
Expand Down
8 changes: 4 additions & 4 deletions proto/tests/example/v1/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ message Person {
string email = 2 [(buf.validate.field).string.email = true];

string name = 3 [(buf.validate.field).string = {
pattern: "^[[:alpha:]]+( [[:alpha:]]+)*$",
max_bytes: 256,
pattern: "^[[:alpha:]]+( [[:alpha:]]+)*$"
max_bytes: 256
}];

Coordinates home = 4;
}

message Coordinates {
double lat = 1 [(buf.validate.field).double = {
gte: -90,
gte: -90
lte: 90
}];
double lng = 2 [(buf.validate.field).double = {
gte: -180,
gte: -180
lte: 180
}];
}
2 changes: 1 addition & 1 deletion proto/tests/example/v1/legacy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ message LegacyMixedFields {

message LegacyIgnoreEmpty {
int32 x = 1 [(validate.rules).int32 = {
gt: 123,
gt: 123
ignore_empty: true
}];
}
68 changes: 34 additions & 34 deletions proto/tests/example/v1/validations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,46 @@ import "google/protobuf/field_mask.proto";

message HasMsgExprs {
option (buf.validate.message).cel = {
id: "x_lt_y",
message: "x must be less than y",
expression: "this.x < this.y",
id: "x_lt_y"
message: "x must be less than y"
expression: "this.x < this.y"
};

option (buf.validate.message).cel = {
id: "y_gt_42",
id: "y_gt_42"
expression:
"this.y > 42 ? ''"
": 'y must be greater than 42'",
": 'y must be greater than 42'"
};

int32 x = 1 [
(buf.validate.field).cel = {
id: "x_even",
message: "x must be even",
id: "x_even"
message: "x must be even"
expression: "this % 2 == 0"
},
(buf.validate.field).cel = {
id: "x_coprime_3",
id: "x_coprime_3"
expression:
"this % 3 != 0 ? ''"
": 'x must not be divisible by 3'",
": 'x must not be divisible by 3'"
}
];
int32 y = 2;
}

message SelfRecursive {
option (buf.validate.message).cel = {
id: "unique_turtles",
message: "adjacent turtles must be unique",
expression: "this.x != this.turtle.x",
id: "unique_turtles"
message: "adjacent turtles must be unique"
expression: "this.x != this.turtle.x"
};

int32 x = 1;
SelfRecursive turtle = 2 [(buf.validate.field).cel = {
id: "non_zero_baby_turtle",
message: "embedded turtle's x value must not be zero",
expression: "this.x > 0",
id: "non_zero_baby_turtle"
message: "embedded turtle's x value must not be zero"
expression: "this.x > 0"
}];
}

Expand All @@ -76,15 +76,15 @@ message LoopRecursiveB {

message MsgHasOneof {
option (buf.validate.message).cel = {
id: "test x",
id: "test x"
expression:
"this.x == '' ? '' : \n"
"!this.x.startsWith('foo') ? 'does not have prefix `foo`' : ''",
"!this.x.startsWith('foo') ? 'does not have prefix `foo`' : ''"
};

option (buf.validate.message).cel = {
id: "text y",
expression: "this.y >= 0",
id: "text y"
expression: "this.y >= 0"
};

oneof o {
Expand All @@ -97,27 +97,27 @@ message MsgHasOneof {

message MsgHasRepeated {
repeated float x = 1 [(buf.validate.field).repeated = {
max_items: 3,
min_items: 1,
max_items: 3
min_items: 1
items: {
cel: {
expression: "true",
expression: "true"
message: "intentional false"
}
float: {gt: 0}
}
unique: true,
unique: true
}];
repeated string y = 2 [(buf.validate.field).repeated.unique = true];
repeated HasMsgExprs z = 3 [(buf.validate.field).repeated = {max_items: 2}];
}

message MsgHasMap {
map<int32, int32> int32map = 1 [(buf.validate.field).map = {
min_pairs: 3,
min_pairs: 3
keys: {
int32: {gt: 0}
},
}
values: {
int32: {lt: 0}
}
Expand All @@ -128,16 +128,16 @@ message MsgHasMap {

message TransitiveFieldConstraint {
google.protobuf.FieldMask mask = 1 [(buf.validate.field).cel = {
id: "mask.paths",
message: "mask.paths must not be empty",
expression: "has(this.paths)",
id: "mask.paths"
message: "mask.paths must not be empty"
expression: "has(this.paths)"
}];
}

message MultipleStepsTransitiveFieldConstraints {
google.protobuf.Api api = 1 [(buf.validate.field).cel = {
id: "api.source_context.file_name",
message: "api's source context file name must not be empty",
id: "api.source_context.file_name"
message: "api's source context file name must not be empty"
expression: "has(this.source_context.file_name)"
}];
}
Expand All @@ -148,16 +148,16 @@ message Simple {

message FieldOfTypeAny {
google.protobuf.Any any = 1 [(buf.validate.field).cel = {
id: "any_type",
message: "this should never fail",
id: "any_type"
message: "this should never fail"
expression: "this == this"
}];
}

// https://github.com/bufbuild/protovalidate/issues/92
message CelMapOnARepeated {
repeated Value values = 1 [(buf.validate.field).cel = {
id: "env.vars.unique",
id: "env.vars.unique"
expression: "this.map(v, v.name).unique() ? '' : 'value names must be unique'"
}];

Expand All @@ -168,7 +168,7 @@ message CelMapOnARepeated {

message RepeatedItemCel {
repeated string paths = 1 [(buf.validate.field).repeated.items.cel = {
id: "paths.no_space",
id: "paths.no_space"
expression: "!this.startsWith(' ')"
}];
}
Loading