diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index a901bfe3e..7913edc53 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -115,7 +115,6 @@ tasks: - "//c/..." - "//cpp/..." - "//csharp/..." - - "//d/..." - "//doc/..." - "//fsharp/..." - "//go/..." diff --git a/.github/workflows/publish-release-assets.yml b/.github/workflows/publish-release-assets.yml new file mode 100644 index 000000000..293a64356 --- /dev/null +++ b/.github/workflows/publish-release-assets.yml @@ -0,0 +1,35 @@ +name: Publish Release Assets + +on: + release: + types: [published] + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup Env + run: | + REPO_NAME=$(echo ${GITHUB_REPOSITORY?missing} | cut -d "/" -f 2) + FILE_STEM=${REPO_NAME?mising}-${GITHUB_REF_NAME?missing} + UPLOAD_URL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${GITHUB_REPOSITORY?missing}/releases/tags/${GITHUB_REF_NAME?missing} | jq -r '.upload_url') + echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV + echo "FILE_STEM=${FILE_STEM}" >> $GITHUB_ENV + echo "FILE_NAME=${FILE_STEM}.tar.gz" >> $GITHUB_ENV + echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV + - name: Build Assets + run: | + git archive --format=tar --prefix="${FILE_STEM?missing}/" "${GITHUB_REF_NAME?missing}" | gzip --best > "${FILE_NAME?missing}" + echo "Asset SHA256: $(sha256sum ${FILE_NAME?missing})" >> $GITHUB_STEP_SUMMARY + - name: Upload Assets to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.UPLOAD_URL }} + asset_path: ./${{ env.FILE_NAME }} + asset_name: ${{ env.FILE_NAME }} + asset_content_type: application/gzip diff --git a/BUILD.bazel b/BUILD.bazel index e69de29bb..3d71d8a53 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -0,0 +1,10 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "defs", + srcs = ["defs.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//internal", + ], +) diff --git a/README.md b/README.md index 4097c87d1..2c76c59b7 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ ## Announcements 📣 +#### 2023/05/03 - Version 4.4.0 + +[Version 4.4.0 has been released](https://github.com/rules-proto-grpc/rules_proto_grpc/releases/tag/4.4.0), +which mainly contains fixes for build edge-cases and wider compatibility + #### 2022/12/04 - Version 4.3.0 [Version 4.3.0 has been released](https://github.com/rules-proto-grpc/rules_proto_grpc/releases/tag/4.3.0), diff --git a/WORKSPACE b/WORKSPACE index 9779a8a97..328759456 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -177,7 +177,7 @@ load("//grpc-gateway:repositories.bzl", "gateway_repos") gateway_repos() -load("@grpc_ecosystem_grpc_gateway//:repositories.bzl", "go_repositories") +load("@com_github_grpc_ecosystem_grpc_gateway_v2//:repositories.bzl", "go_repositories") go_repositories() @@ -235,7 +235,7 @@ load("@rules_python//python:pip.bzl", "pip_parse") pip_parse( name = "rules_proto_grpc_py3_deps", python_interpreter = "python3", - requirements = "@rules_proto_grpc//python:requirements.txt", + requirements_lock = "@rules_proto_grpc//python:requirements.txt", ) load("@rules_proto_grpc_py3_deps//:requirements.bzl", "install_deps") diff --git a/defs.bzl b/defs.bzl index 795756de3..76050f405 100644 --- a/defs.bzl +++ b/defs.bzl @@ -1,7 +1,7 @@ """Top level definition exports for rules_proto_grpc.""" load("//internal:common.bzl", _bazel_build_rule_common_attrs = "bazel_build_rule_common_attrs") -load("//internal:compile.bzl", _proto_compile_attrs = "proto_compile_attrs", _proto_compile_impl = "proto_compile_impl") +load("//internal:compile.bzl", _proto_compile = "proto_compile", _proto_compile_attrs = "proto_compile_attrs", _proto_compile_impl = "proto_compile_impl") load("//internal:filter_files.bzl", _filter_files = "filter_files") load("//internal:plugin.bzl", _proto_plugin = "proto_plugin") load("//internal:providers.bzl", _ProtoCompileInfo = "ProtoCompileInfo", _ProtoPluginInfo = "ProtoPluginInfo") @@ -17,6 +17,11 @@ proto_plugin = _proto_plugin proto_compile_attrs = _proto_compile_attrs proto_compile_impl = _proto_compile_impl +# Export compilation function, which can be wrapped by external rules that need more +# pre-configuration than proto_compile_impl alone allows. e.g third party versions of +# doc_template_compile_impl-like rules +proto_compile = _proto_compile + # Export utils bazel_build_rule_common_attrs = _bazel_build_rule_common_attrs filter_files = _filter_files diff --git a/docs/changelog.rst b/docs/changelog.rst index 2bddbfa26..7b2f0265c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,40 @@ Changelog ========= +4.4.0 +----- + +General +******* + +- Increased minimum supported Bazel version from 5.0.0 to 5.3.0. + `#230 `__ +- Added support for param file for excess arguments, which allows for longer commands lines without + failure +- Fixed Windows incompatibility due to test workspace containing quote character in path +- The `proto_compile` function is now exported in the public `defs.bzl` for use in external rules +- Added static release assets generation, which will change the format of the download URL to use in + your WORKSPACE. See the sample installation docs for the new URL + +Go +** + +- Updated ``github.com/envoyproxy/protoc-gen-validate`` to 1.0.0 + +grpc-gateway +************ + +- **WORKSPACE update needed**: Renamed ``grpc-gateway`` repository name from + ``grpc_ecosystem_grpc_gateway`` to ``com_github_grpc_ecosystem_grpc_gateway_v2``, to match the + naming used by Gazelle. You may need to update your WORKSPACE file to use the new name + +Objective-C +*********** + +- Fixed expected naming of output files for proto files containing numbers in file name. + `#253 `__ + + 4.3.0 ----- diff --git a/docs/lang/grpc-gateway.rst b/docs/lang/grpc-gateway.rst index 1b08d1096..b12d9c174 100644 --- a/docs/lang/grpc-gateway.rst +++ b/docs/lang/grpc-gateway.rst @@ -54,7 +54,7 @@ Full example project can be found `here PascalCase - Objective C uses pascal case, but there are e exceptions that it uppercases - the entire segment: url, http, and https. + Objective C uses pascal case, but there are exceptions that it uppercases. + For example, it will uppercase the words "url", "http", and "https". https://github.com/protocolbuffers/protobuf/blob/54176b26a9be6c9903b375596b778f51f5947921/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc#L91 @@ -78,14 +78,50 @@ def pascal_objc(s): s = s.replace("-", "_") segments = [] - for segment in s.split("_"): + current = "" + last_char_was_number = False + last_char_was_lower = False + last_char_was_upper = False + for char in s.elems(): + if char.isdigit(): + if last_char_was_number: + segments.append(current) + current = "" + current += char + last_char_was_number = True + last_char_was_lower = False + last_char_was_upper = False + elif char.islower(): + if not last_char_was_lower and not last_char_was_upper: + segments.append(current) + current = "" + current += char + last_char_was_number = False + last_char_was_lower = True + last_char_was_upper = False + elif char.isupper(): + if not last_char_was_upper: + segments.append(current) + current = "" + current += char.lower() + last_char_was_number = False + last_char_was_lower = False + last_char_was_upper = True + else: + last_char_was_number = False + last_char_was_lower = False + last_char_was_upper = False + segments.append(current) + + new_segments = [] + for segment in segments: repl = _objc_upper_segments.get(segment) if repl: segment = repl else: segment = capitalize(segment) - segments.append(segment) - return "".join(segments) + new_segments.append(segment) + return "".join(new_segments) def pascal_case(s): """ diff --git a/internal/compile.bzl b/internal/compile.bzl index 56144d114..401a16671 100644 --- a/internal/compile.bzl +++ b/internal/compile.bzl @@ -291,6 +291,8 @@ def proto_compile(ctx, options, extra_protoc_args, extra_protoc_files): extra_protoc_args = extra_protoc_args, ) args = ctx.actions.args() + args.set_param_file_format("multiline") + args.use_param_file("@%s", use_always = False) args.add_all(args_list) # Add import roots and files if required by plugin diff --git a/repositories.bzl b/repositories.bzl index e036a183b..3cedc6e14 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -4,7 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file" load("//internal:common.bzl", "check_bazel_minimum_version") # Versions -MINIMUM_BAZEL_VERSION = "5.0.0" +MINIMUM_BAZEL_VERSION = "5.3.0" ENABLE_VERSION_NAGS = False PROTOBUF_VERSION = "21.10" # When updating, also update protobuf-javascript, JS requirements, JS rulegen in js.go, Ruby requirements and C#/F# requirements GRPC_VERSION = "1.51.0" # When updating, also update grpc hash, grpc-java hash, Go repositories.bzl, Ruby requirements and C#/F# requirements @@ -180,7 +180,7 @@ VERSIONS = { }, # grpc-gateway - "grpc_ecosystem_grpc_gateway": { + "com_github_grpc_ecosystem_grpc_gateway_v2": { "type": "github", "org": "grpc-ecosystem", "repo": "grpc-gateway", @@ -573,8 +573,8 @@ def bazel_gazelle(**kwargs): # # gRPC gateway # -def grpc_ecosystem_grpc_gateway(**kwargs): - _generic_dependency("grpc_ecosystem_grpc_gateway", **kwargs) +def com_github_grpc_ecosystem_grpc_gateway_v2(**kwargs): + _generic_dependency("com_github_grpc_ecosystem_grpc_gateway_v2", **kwargs) # # Java diff --git a/test_workspaces/go_fixer/WORKSPACE b/test_workspaces/go_fixer/WORKSPACE index e494d34ef..dec7bd18f 100644 --- a/test_workspaces/go_fixer/WORKSPACE +++ b/test_workspaces/go_fixer/WORKSPACE @@ -37,7 +37,7 @@ load("@rules_proto_grpc//grpc-gateway:repositories.bzl", rules_proto_grpc_gatewa rules_proto_grpc_gateway_repos() -load("@grpc_ecosystem_grpc_gateway//:repositories.bzl", "go_repositories") +load("@com_github_grpc_ecosystem_grpc_gateway_v2//:repositories.bzl", "go_repositories") go_repositories() diff --git a/test_workspaces/objc_capitalisation/BUILD.bazel b/test_workspaces/objc_capitalisation/BUILD.bazel index 21be60aab..b5a36804a 100644 --- a/test_workspaces/objc_capitalisation/BUILD.bazel +++ b/test_workspaces/objc_capitalisation/BUILD.bazel @@ -12,6 +12,7 @@ proto_library( "demo.proto", "folder/dashes-demo.proto", "folder/nested_demo.proto", + "folder/vector3f.proto", ], ) diff --git a/test_workspaces/objc_capitalisation/folder/vector3f.proto b/test_workspaces/objc_capitalisation/folder/vector3f.proto new file mode 100644 index 000000000..a2b3c7d09 --- /dev/null +++ b/test_workspaces/objc_capitalisation/folder/vector3f.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +message vector3f_demo { + bool field = 1; +} diff --git a/test_workspaces/objc_capitalisation/main.py b/test_workspaces/objc_capitalisation/main.py index b68610b2a..c1972b1fe 100644 --- a/test_workspaces/objc_capitalisation/main.py +++ b/test_workspaces/objc_capitalisation/main.py @@ -10,6 +10,8 @@ 'objc_lib/folder/DashesDemo.pbobjc.h', 'objc_lib/folder/NestedDemo.pbobjc.m', 'objc_lib/folder/NestedDemo.pbobjc.h', + 'objc_lib/folder/Vector3F.pbobjc.m', + 'objc_lib/folder/Vector3F.pbobjc.h', } if os.name == 'nt': diff --git a/test_workspaces/readme_http_archive/WORKSPACE b/test_workspaces/readme_http_archive/WORKSPACE index 9690fbf0a..8509d6e96 100644 --- a/test_workspaces/readme_http_archive/WORKSPACE +++ b/test_workspaces/readme_http_archive/WORKSPACE @@ -4,7 +4,7 @@ http_archive( name = "rules_proto_grpc", sha256 = "fb7fc7a3c19a92b2f15ed7c4ffb2983e956625c1436f57a3430b897ba9864059", strip_prefix = "rules_proto_grpc-4.3.0", - urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.3.0.tar.gz"], + urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/releases/download/4.3.0/rules_proto_grpc-4.3.0.tar.gz"], ) load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") diff --git a/test_workspaces/special_characters/BUILD.bazel b/test_workspaces/special_characters/BUILD.bazel index 91be80af3..c4442740c 100644 --- a/test_workspaces/special_characters/BUILD.bazel +++ b/test_workspaces/special_characters/BUILD.bazel @@ -8,9 +8,9 @@ package(default_visibility = ["//visibility:private"]) proto_library( name = "proto_lib", - srcs = ["path-with-special-chars/a b\"!/demo.proto"], + srcs = ["path-with-special-chars/a b!/demo.proto"], import_prefix = "c d^*", - strip_import_prefix = "path-with-special-chars/a b\"!", + strip_import_prefix = "path-with-special-chars/a b!", ) cpp_proto_library( diff --git "a/test_workspaces/special_characters/path-with-special-chars/a b\"!/demo.proto" b/test_workspaces/special_characters/path-with-special-chars/a b!/demo.proto similarity index 100% rename from "test_workspaces/special_characters/path-with-special-chars/a b\"!/demo.proto" rename to test_workspaces/special_characters/path-with-special-chars/a b!/demo.proto diff --git a/tools/rulegen/README.header.md b/tools/rulegen/README.header.md index 2a9d5e25d..e6c6494d4 100644 --- a/tools/rulegen/README.header.md +++ b/tools/rulegen/README.header.md @@ -14,6 +14,11 @@ ## Announcements 📣 +#### 2023/05/03 - Version 4.4.0 + +[Version 4.4.0 has been released](https://github.com/rules-proto-grpc/rules_proto_grpc/releases/tag/4.4.0), +which mainly contains fixes for build edge-cases and wider compatibility + #### 2022/12/04 - Version 4.3.0 [Version 4.3.0 has been released](https://github.com/rules-proto-grpc/rules_proto_grpc/releases/tag/4.3.0), diff --git a/tools/rulegen/d.go b/tools/rulegen/d.go index 8038eb171..ea8ff7a39 100644 --- a/tools/rulegen/d.go +++ b/tools/rulegen/d.go @@ -42,6 +42,7 @@ func makeD() *Language { .. note:: These rules use the protoc-gen-d plugin, which only supports proto3 .proto files.`), Flags: commonLangFlags, + SkipTestPlatforms: []string{"windows", "macos"}, Rules: []*Rule{ &Rule{ Name: "d_proto_compile", @@ -52,7 +53,6 @@ func makeD() *Language { BuildExample: protoCompileExampleTemplate, Doc: "Generates D protobuf ``.d`` files", Attrs: compileRuleAttrs, - SkipTestPlatforms: []string{"windows", "macos"}, }, // &Rule{ // Name: "d_grpc_compile", @@ -63,7 +63,6 @@ func makeD() *Language { // BuildExample: grpcCompileExampleTemplate, // Doc: "Generates D protobuf and gRPC ``.d`` files", // Attrs: libraryRuleAttrs, -// SkipTestPlatforms: []string{"windows", "macos"}, // }, &Rule{ Name: "d_proto_library", @@ -73,7 +72,6 @@ func makeD() *Language { BuildExample: protoLibraryExampleTemplate, Doc: "Generates a D protobuf library using ``d_library`` from ``rules_d``", Attrs: compileRuleAttrs, - SkipTestPlatforms: []string{"windows", "macos"}, }, // &Rule{ // Name: "d_grpc_library", @@ -83,7 +81,6 @@ func makeD() *Language { // BuildExample: grpcLibraryExampleTemplate, // Doc: "Generates a D protobuf and gRPC library using ``d_library`` from ``rules_d``", // Attrs: libraryRuleAttrs, -// SkipTestPlatforms: []string{"windows", "macos"}, // }, }, } diff --git a/tools/rulegen/grpc_gateway.go b/tools/rulegen/grpc_gateway.go index 6c8cb79c7..030be7fc2 100644 --- a/tools/rulegen/grpc_gateway.go +++ b/tools/rulegen/grpc_gateway.go @@ -18,7 +18,7 @@ go_register_toolchains( version = "1.17.1", ) -load("@grpc_ecosystem_grpc_gateway//:repositories.bzl", "go_repositories") +load("@com_github_grpc_ecosystem_grpc_gateway_v2//:repositories.bzl", "go_repositories") go_repositories() @@ -58,8 +58,8 @@ GATEWAY_DEPS = [ "@org_golang_google_protobuf//proto:go_default_library", "@org_golang_google_grpc//grpclog:go_default_library", "@org_golang_google_grpc//metadata:go_default_library", - "@grpc_ecosystem_grpc_gateway//runtime:go_default_library", - "@grpc_ecosystem_grpc_gateway//utilities:go_default_library", + "@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library", + "@com_github_grpc_ecosystem_grpc_gateway_v2//utilities:go_default_library", "@go_googleapis//google/api:annotations_go_proto", ]`) diff --git a/tools/rulegen/main.go b/tools/rulegen/main.go index d1b7d2467..68448331c 100644 --- a/tools/rulegen/main.go +++ b/tools/rulegen/main.go @@ -679,7 +679,7 @@ http_archive( name = "rules_proto_grpc", sha256 = "%s", strip_prefix = "rules_proto_grpc-%s", - urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/%s.tar.gz"], + urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/releases/download/%s/rules_proto_grpc-%s.tar.gz"], ) load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") @@ -693,7 +693,7 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_ rules_proto_dependencies() rules_proto_toolchains() -`, sha256, ref, ref) +`, sha256, ref, ref, ref) out.MustWrite(filepath.Join(dir, "test_workspaces", "readme_http_archive", "WORKSPACE")) } diff --git a/tools/rulegen/python.go b/tools/rulegen/python.go index e8c35dcc9..533ffd96f 100644 --- a/tools/rulegen/python.go +++ b/tools/rulegen/python.go @@ -29,7 +29,7 @@ load("@rules_python//python:pip.bzl", "pip_parse") pip_parse( name = "rules_proto_grpc_py3_deps", python_interpreter = "python3", - requirements = "@rules_proto_grpc//python:requirements.txt", + requirements_lock = "@rules_proto_grpc//python:requirements.txt", ) load("@rules_proto_grpc_py3_deps//:requirements.bzl", "install_deps")