Update PHP and Ruby amalgamations in regenerate_stale_files.sh

This removes the need for us to manually rebuild these amalgamation files. I
added the "manual" tag to the corresponding staleness tests so that we won't
get presubmit errors if the amalgamation files are out of date. I also had to
tweak the Ruby BUILD.bazel file to make sure it uses Bazel-generated
amalgamations instead of relying on the checked-in files.

I added deliberate errors to the Ruby and PHP amalgamation files to test that
everything is working. We should not see any CI errors, and the files should
quickly be auto-updated after the change lands on main.

PiperOrigin-RevId: 561187352
pull/13778/head
Adam Cozzette 2 years ago committed by Copybara-Service
parent ee817d1ad1
commit 0937be16c0
  1. 3
      .github/workflows/test_php.yml
  2. 1
      .github/workflows/test_php_ext.yml
  3. 3
      .github/workflows/test_ruby.yml
  4. 1
      php/BUILD.bazel
  5. 2
      php/ext/google/protobuf/php-upb.c
  6. 2
      regenerate_stale_files.sh
  7. 39
      ruby/ext/google/protobuf_c/BUILD.bazel
  8. 2
      ruby/ext/google/protobuf_c/ruby-upb.c

@ -101,7 +101,6 @@ jobs:
uses: protocolbuffers/protobuf-ci/docker@v2 uses: protocolbuffers/protobuf-ci/docker@v2
with: with:
image: ${{ env.image }} image: ${{ env.image }}
skip-staleness-check: true
platform: linux/386 platform: linux/386
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }}
@ -140,7 +139,6 @@ jobs:
with: with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php-aarch64@sha256:77ff9fdec867bbfb290ee0b10d8b7a3e5e434155daa5ec93de7341c7592b858d image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php-aarch64@sha256:77ff9fdec867bbfb290ee0b10d8b7a3e5e434155daa5ec93de7341c7592b858d
platform: linux/arm64 platform: linux/arm64
skip-staleness-check: true
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }}
command: >- command: >-
@ -191,6 +189,7 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: php_macos/${{ matrix.version }} bazel-cache: php_macos/${{ matrix.version }}
bash: | bash: |
./regenerate_stale_files.sh
pushd php pushd php
php -v php -v
php -m php -m

@ -27,6 +27,7 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: php_ext/${{ matrix.version }} bazel-cache: php_ext/${{ matrix.version }}
bash: > bash: >
./regenerate_stale_files.sh;
bazel build //php:release $BAZEL_FLAGS; bazel build //php:release $BAZEL_FLAGS;
cp bazel-bin/php/protobuf-*.tgz . cp bazel-bin/php/protobuf-*.tgz .

@ -67,7 +67,6 @@ jobs:
uses: protocolbuffers/protobuf-ci/docker@v2 uses: protocolbuffers/protobuf-ci/docker@v2
with: with:
image: i386/ruby:2.7.3-buster image: i386/ruby:2.7.3-buster
skip-staleness-check: true
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/bin/bash -cex ' /bin/bash -cex '
@ -99,7 +98,6 @@ jobs:
uses: protocolbuffers/protobuf-ci/docker@v2 uses: protocolbuffers/protobuf-ci/docker@v2
with: with:
image: arm64v8/ruby:2.7.3-buster image: arm64v8/ruby:2.7.3-buster
skip-staleness-check: true
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/bin/bash -cex ' /bin/bash -cex '
@ -181,6 +179,7 @@ jobs:
bash: > bash: >
bazel --version; bazel --version;
ruby --version; ruby --version;
./regenerate_stale_files.sh;
bazel build //ruby:release //:protoc ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled' || '' }} $BAZEL_FLAGS; bazel build //ruby:release //:protoc ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled' || '' }} $BAZEL_FLAGS;
gem install bazel-bin/ruby/google-protobuf-*; gem install bazel-bin/ruby/google-protobuf-*;
bazel-bin/protoc --proto_path=src --proto_path=ruby/tests --proto_path=ruby --ruby_out=ruby tests/test_import_proto2.proto; bazel-bin/protoc --proto_path=src --proto_path=ruby/tests --proto_path=ruby --ruby_out=ruby tests/test_import_proto2.proto;

@ -104,6 +104,7 @@ staleness_test(
"ext/google/protobuf/php-upb.c", "ext/google/protobuf/php-upb.c",
], ],
generated_pattern = "generated-in/%s", generated_pattern = "generated-in/%s",
tags = ["manual"],
) )
################################################################################ ################################################################################

@ -1,6 +1,8 @@
/* Amalgamated source file */ /* Amalgamated source file */
#include "php-upb.h" #include "php-upb.h"
test-xyz
/* /*
* This is where we define internal portability macros used across upb. * This is where we define internal portability macros used across upb.
* *

@ -16,6 +16,8 @@ readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}"
${BazelBin} test src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix ${BazelBin} test src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix
${BazelBin} test src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix ${BazelBin} test src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
${BazelBin} test objectivec:well_known_types_staleness_test "$@" || ./bazel-bin/objectivec/well_known_types_staleness_test --fix ${BazelBin} test objectivec:well_known_types_staleness_test "$@" || ./bazel-bin/objectivec/well_known_types_staleness_test --fix
${BazelBin} test php:test_amalgamation_staleness "$@" || ./bazel-bin/php/test_amalgamation_staleness --fix
${BazelBin} test ruby/ext/google/protobuf_c:test_amalgamation_staleness "$@" || ./bazel-bin/ruby/ext/google/protobuf_c/test_amalgamation_staleness --fix
(cd upb; ${BazelBin} test cmake:test_generated_files "$@" || ./bazel-bin/cmake/test_generated_files --fix) (cd upb; ${BazelBin} test cmake:test_generated_files "$@" || ./bazel-bin/cmake/test_generated_files --fix)
# Generate C# code. # Generate C# code.

@ -4,9 +4,7 @@ load("@upb//cmake:build_defs.bzl", "staleness_test")
package(default_visibility = ["//ruby:__subpackages__"]) package(default_visibility = ["//ruby:__subpackages__"])
cc_library( PROTOBUF_C_SOURCES = [
name = "protobuf_c",
srcs = [
"convert.c", "convert.c",
"convert.h", "convert.h",
"defs.c", "defs.c",
@ -19,13 +17,35 @@ cc_library(
"protobuf.h", "protobuf.h",
"repeated_field.c", "repeated_field.c",
"repeated_field.h", "repeated_field.h",
"ruby-upb.c",
"ruby-upb.h",
"shared_convert.c", "shared_convert.c",
"shared_convert.h", "shared_convert.h",
"shared_message.c", "shared_message.c",
"shared_message.h", "shared_message.h",
"wrap_memcpy.c", "wrap_memcpy.c",
]
# We copy everything into a copy/ subdirectory so that we can use the
# up-to-date Bazel-generated amalgamation files without conflicting with the
# possibly stale checked-in amalgamations.
genrule(
name = "copy_sources",
srcs = PROTOBUF_C_SOURCES + [
"glue.c",
"@upb//:gen_ruby_amalgamation",
],
outs = ["copy/%s" % src for src in PROTOBUF_C_SOURCES] + [
"copy/glue.c",
"copy/ruby-upb.h",
"copy/ruby-upb.c",
],
cmd = "cp $(SRCS) $(RULEDIR)/copy",
)
cc_library(
name = "protobuf_c",
srcs = ["copy/%s" % src for src in PROTOBUF_C_SOURCES] + [
"copy/ruby-upb.c",
"copy/ruby-upb.h",
], ],
linkstatic = True, linkstatic = True,
target_compatible_with = select({ target_compatible_with = select({
@ -44,10 +64,10 @@ cc_library(
cc_library( cc_library(
name = "upb_api", name = "upb_api",
srcs = [ srcs = [
"ruby-upb.c", "copy/ruby-upb.c",
], ],
hdrs = [ hdrs = [
"ruby-upb.h", "copy/ruby-upb.h",
], ],
copts = ["-fvisibility=hidden"], copts = ["-fvisibility=hidden"],
linkstatic = False, linkstatic = False,
@ -65,13 +85,13 @@ cc_library(
cc_library( cc_library(
name = "protobuf_c_ffi", name = "protobuf_c_ffi",
srcs = [ srcs = ["copy/%s" % src for src in [
"glue.c", "glue.c",
"shared_convert.c", "shared_convert.c",
"shared_convert.h", "shared_convert.h",
"shared_message.c", "shared_message.c",
"shared_message.h", "shared_message.h",
], ]],
copts = [ copts = [
"-std=gnu99", "-std=gnu99",
"-O3", "-O3",
@ -154,4 +174,5 @@ staleness_test(
"ruby-upb.h", "ruby-upb.h",
], ],
generated_pattern = "generated-in/%s", generated_pattern = "generated-in/%s",
tags = ["manual"],
) )

@ -1,6 +1,8 @@
/* Amalgamated source file */ /* Amalgamated source file */
#include "ruby-upb.h" #include "ruby-upb.h"
test-xyz
/* /*
* This is where we define internal portability macros used across upb. * This is where we define internal portability macros used across upb.
* *

Loading…
Cancel
Save