Skip to content

Commit d9c5a6d

Browse files
authored
Bump cel-spec + googleapi submodules (#476)
Build: maintenance + convenience changes: * add `compileAll` task * add IntelliJ-sync-task * bump jandex version to make it work with Java 21 * CI: Bump bazel version from 3.5.1 to 6.4.0 Bump cel-spec + googleapi submodules: Bump cel-spec submodule to [v0.13.0](https://github.com/google/cel-spec/releases/tag/v0.13.0), googleapi submodule to [f2d78630d2c1d5e20041dfff963e093de9298e4d](googleapis/googleapis@f2d7863). This was necessary due to recent build errors caused by missing (old) artifacts for the conformance bazel build. The submodule bumps bring a bunch of new conformance tests as well, which unveiled that some functionality that was not present in CEL-Go when CEL-Java was created, is required by the CEl-Spec. Summary of changes: * Bugfix in `o.p.c.checker.Standard` that fixes a type resolution error for equals and not-equals functions, when both parameters need to be up-casted. * Changes in many types (in `o.p.c.common.types.*T` classes) to automatically convert between numeric and null types. * equal and compare with a null and a non-null type no longer fail, but return `False` * equal and compare between different numeric types no longer fail, but return "the right" result * this includes that numeric CEL map keys can be heterogenous, e.g. an `int` can be retrieved using an `uint` or `double` key * Fix retrieval of milliseconds from `Duration` - must only return the milliseconds within the second * Un-ignore a bunch of conformance tests that pass fine now A few conformance tests have been added to `InterpreterTest`, but the majority of tests is left in the conformance tests.
1 parent d219b98 commit d9c5a6d

42 files changed

Lines changed: 903 additions & 237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
if: ${{ matrix.java-version == '11' }}
9999
uses: jwlawson/actions-setup-bazel@v1.10.1
100100
with:
101-
bazel-version: '3.5.1'
101+
bazel-version: '6.4.0'
102102

103103
- name: Conformance tests
104104
if: ${{ matrix.java-version == '11' }}

build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,21 @@ publishingHelper {
8484
nessieRepoName.set("cel-java")
8585
inceptionYear.set("2021")
8686
}
87+
88+
idea.project.settings {
89+
taskTriggers {
90+
afterSync(
91+
":cel-generated-pb:jar",
92+
":cel-generated-pb:testJar",
93+
":cel-generated-antlr:shadowJar"
94+
)
95+
}
96+
}
97+
98+
subprojects.forEach {
99+
it.tasks.register("compileAll").configure {
100+
group = "build"
101+
description = "Runs all compilation and jar tasks"
102+
dependsOn(tasks.withType<AbstractCompile>(), tasks.withType<ProcessResources>())
103+
}
104+
}

conformance/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ The CEL-spec conformance test suite is written in Go and uses the bazel build to
1111

1212
Required tools:
1313
* [Bazel build tool](https://bazel.build/)
14-
15-
On Ubuntu run `apt-get install bazel-bootstrap`
14+
15+
See [Bazel web site](https://bazel.build/install) for installation instructions.
16+
Do **not** use the `bazel-bootstrap` package on Ubuntu, because it comes with
17+
pre-compiled classes that are built with Java 17 or newer, preventing it from
18+
running bazel using older Java versions.
1619
* gcc
1720

1821
On Ubuntu run `apt-get install gcc`

conformance/build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ plugins {
2828

2929
apply<ProtobufPlugin>()
3030

31-
sourceSets.main { java.srcDir(layout.buildDirectory.dir("generated/source/proto/main/java")) }
31+
sourceSets.main {
32+
java.srcDir(layout.buildDirectory.dir("generated/source/proto/main/java"))
33+
java.srcDir(layout.buildDirectory.dir("generated/source/proto/main/grpc"))
34+
}
3235

3336
dependencies {
3437
implementation(project(":cel-core"))
@@ -58,6 +61,10 @@ configure<ProtobufExtension> {
5861
// Download from repositories
5962
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
6063
}
64+
plugins {
65+
this.create("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.grpc.get()}" }
66+
}
67+
generateProtoTasks { all().configureEach { this.plugins.create("grpc") {} } }
6168
}
6269

6370
// The protobuf-plugin should ideally do this

conformance/run-conformance-tests.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,33 @@ cel_java_skips=(
4646
# nested protobuf-object-structure, which gets rejected during gRPC/protobuf request
4747
# deserialization. Just skip those tests.
4848
"--skip_test=parse/nest/message_literal"
49-
"--skip_test=parse/repeat/index"
49+
# Proto equality specialties don't seem to be in effect for Java
50+
"--skip_test=comparisons/eq_wrapper/eq_proto_nan_equal"
51+
"--skip_test=comparisons/ne_literal/ne_proto_nan_not_equal"
5052

51-
# TODO Actual known issux to fix, a protobuf Any returned via this test is wrapped twice (Any in Any).
53+
# TODO Actual known issue to fix, a protobuf Any returned via this test is wrapped twice (Any in Any).
5254
"--skip_test=dynamic/any/var"
5355
)
5456

5557
cel_go_skips=(
56-
"--skip_test=comparisons/eq_literal/not_eq_list_false_vs_types,not_eq_map_false_vs_types"
57-
"--skip_test=comparisons/in_map_literal/key_in_mixed_key_type_map_error"
58-
"--skip_test=comparisons/eq_literal/not_eq_list_false_vs_types,not_eq_map_false_vs_types"
59-
"--skip_test=comparisons/in_map_literal/key_in_mixed_key_type_map_error"
6058
"--skip_test=dynamic/int32/field_assign_proto2_range,field_assign_proto3_range"
6159
"--skip_test=dynamic/uint32/field_assign_proto2_range,field_assign_proto3_range"
6260
"--skip_test=dynamic/float/field_assign_proto2_range,field_assign_proto3_range"
63-
"--skip_test=dynamic/value_null/literal_unset,field_read_proto2_unset,field_read_proto3_unset"
6461
"--skip_test=enums/legacy_proto2/assign_standalone_int_too_big,assign_standalone_int_too_neg"
6562
"--skip_test=enums/legacy_proto3/assign_standalone_int_too_big,assign_standalone_int_too_neg"
6663
"--skip_test=enums/strong_proto2"
6764
"--skip_test=enums/strong_proto3"
68-
"--skip_test=fields/qualified_identifier_resolution/map_key_float,map_key_null,map_value_repeat_key"
65+
# This conformance test is invalid nowadays
66+
"--skip_test=fields/qualified_identifier_resolution/map_key_float"
67+
# Unclear why the 'to_json_string' is expected to return a string, unlike the preceding to_json_number test.
68+
"--skip_test=wrappers/uint64/to_json_string"
69+
# TODO implement proper "toJson" at some point
70+
"--skip_test=wrappers/field_mask/to_json"
71+
"--skip_test=wrappers/timestamp/to_json"
72+
"--skip_test=wrappers/empty/to_json"
6973
)
7074

7175
test_files=(
72-
"tests/simple/testdata/plumbing.textproto"
7376
"tests/simple/testdata/basic.textproto"
7477
"tests/simple/testdata/comparisons.textproto"
7578
"tests/simple/testdata/conversions.textproto"
@@ -83,11 +86,14 @@ test_files=(
8386
"tests/simple/testdata/macros.textproto"
8487
"tests/simple/testdata/namespace.textproto"
8588
"tests/simple/testdata/parse.textproto"
89+
"tests/simple/testdata/plumbing.textproto"
8690
"tests/simple/testdata/proto2.textproto"
8791
"tests/simple/testdata/proto3.textproto"
8892
"tests/simple/testdata/string.textproto"
93+
# TODO add when implemnting the string-extensions "tests/simple/testdata/string_ext.textproto"
8994
"tests/simple/testdata/timestamps.textproto"
9095
"tests/simple/testdata/unknowns.textproto"
96+
"tests/simple/testdata/wrappers.textproto"
9197
)
9298

9399
bazel-bin/tests/simple/simple_test_/simple_test \

conformance/src/main/java/org/projectnessie/cel/server/ConformanceServiceImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@
3939
import static org.projectnessie.cel.common.types.UnknownT.isUnknown;
4040
import static org.projectnessie.cel.common.types.UnknownT.unknownOf;
4141

42-
import com.google.api.expr.v1alpha1.CheckRequest;
43-
import com.google.api.expr.v1alpha1.CheckResponse;
44-
import com.google.api.expr.v1alpha1.ConformanceServiceGrpc.ConformanceServiceImplBase;
42+
import com.google.api.expr.conformance.v1alpha1.CheckRequest;
43+
import com.google.api.expr.conformance.v1alpha1.CheckResponse;
44+
import com.google.api.expr.conformance.v1alpha1.ConformanceServiceGrpc.ConformanceServiceImplBase;
45+
import com.google.api.expr.conformance.v1alpha1.EvalRequest;
46+
import com.google.api.expr.conformance.v1alpha1.EvalResponse;
47+
import com.google.api.expr.conformance.v1alpha1.IssueDetails;
48+
import com.google.api.expr.conformance.v1alpha1.ParseRequest;
49+
import com.google.api.expr.conformance.v1alpha1.ParseResponse;
50+
import com.google.api.expr.conformance.v1alpha1.SourcePosition;
4551
import com.google.api.expr.v1alpha1.ErrorSet;
46-
import com.google.api.expr.v1alpha1.EvalRequest;
47-
import com.google.api.expr.v1alpha1.EvalResponse;
4852
import com.google.api.expr.v1alpha1.ExprValue;
49-
import com.google.api.expr.v1alpha1.IssueDetails;
5053
import com.google.api.expr.v1alpha1.ListValue;
5154
import com.google.api.expr.v1alpha1.MapValue;
5255
import com.google.api.expr.v1alpha1.MapValue.Entry;
53-
import com.google.api.expr.v1alpha1.ParseRequest;
54-
import com.google.api.expr.v1alpha1.ParseResponse;
55-
import com.google.api.expr.v1alpha1.SourcePosition;
5656
import com.google.api.expr.v1alpha1.UnknownSet;
5757
import com.google.api.expr.v1alpha1.Value;
5858
import com.google.protobuf.Any;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../../../submodules/googleapis/google/api/expr/conformance

conformance/src/test/java/org/projectnessie/cel/server/ConformanceServerTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
import static org.projectnessie.cel.TestExpr.ExprLiteral;
2121
import static org.projectnessie.cel.Util.mapOf;
2222

23-
import com.google.api.expr.v1alpha1.CheckRequest;
24-
import com.google.api.expr.v1alpha1.CheckResponse;
23+
import com.google.api.expr.conformance.v1alpha1.CheckRequest;
24+
import com.google.api.expr.conformance.v1alpha1.CheckResponse;
25+
import com.google.api.expr.conformance.v1alpha1.ConformanceServiceGrpc;
26+
import com.google.api.expr.conformance.v1alpha1.ConformanceServiceGrpc.ConformanceServiceBlockingStub;
27+
import com.google.api.expr.conformance.v1alpha1.EvalRequest;
28+
import com.google.api.expr.conformance.v1alpha1.EvalResponse;
29+
import com.google.api.expr.conformance.v1alpha1.ParseRequest;
30+
import com.google.api.expr.conformance.v1alpha1.ParseResponse;
2531
import com.google.api.expr.v1alpha1.CheckedExpr;
26-
import com.google.api.expr.v1alpha1.ConformanceServiceGrpc;
27-
import com.google.api.expr.v1alpha1.ConformanceServiceGrpc.ConformanceServiceBlockingStub;
2832
import com.google.api.expr.v1alpha1.Constant;
2933
import com.google.api.expr.v1alpha1.Constant.ConstantKindCase;
30-
import com.google.api.expr.v1alpha1.EvalRequest;
31-
import com.google.api.expr.v1alpha1.EvalResponse;
3234
import com.google.api.expr.v1alpha1.Expr;
3335
import com.google.api.expr.v1alpha1.Expr.Call;
3436
import com.google.api.expr.v1alpha1.Expr.ExprKindCase;
3537
import com.google.api.expr.v1alpha1.ExprValue;
3638
import com.google.api.expr.v1alpha1.ExprValue.KindCase;
37-
import com.google.api.expr.v1alpha1.ParseRequest;
38-
import com.google.api.expr.v1alpha1.ParseResponse;
3939
import com.google.api.expr.v1alpha1.ParsedExpr;
4040
import com.google.api.expr.v1alpha1.SourceInfo;
4141
import com.google.api.expr.v1alpha1.Type;

core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ dependencies {
3737

3838
testImplementation(platform(libs.junit.bom))
3939
testImplementation(libs.bundles.junit.testing)
40+
testImplementation(libs.protobuf.java)
41+
testImplementation(libs.guava)
4042
testRuntimeOnly(libs.junit.jupiter.engine)
4143

4244
jmhImplementation(libs.jmh.core)

core/src/main/java/org/projectnessie/cel/checker/Standard.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ Overloads.GreaterEqualsBytes, asList(Decls.Bytes, Decls.Bytes), Decls.Bool),
162162
Decls.newFunction(
163163
Operator.Equals.id,
164164
Decls.newParameterizedOverload(
165-
Overloads.Equals, asList(paramA, paramA), Decls.Bool, typeParamAList)));
165+
Overloads.Equals, asList(paramA, paramB), Decls.Bool, typeParamABList)));
166166

167167
idents.add(
168168
Decls.newFunction(
169169
Operator.NotEquals.id,
170170
Decls.newParameterizedOverload(
171-
Overloads.NotEquals, asList(paramA, paramA), Decls.Bool, typeParamAList)));
171+
Overloads.NotEquals, asList(paramA, paramB), Decls.Bool, typeParamABList)));
172172

173173
// Algebra.
174174

0 commit comments

Comments
 (0)