From 1223341793af41821a6805e0c5fb309e5f5fd6c8 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 23 Dec 2024 13:07:28 -0800 Subject: [PATCH] Set up golden tests for the files we install via cmake. This will help us avoid further bugs like #19735, where we're typically not very aware of how our files get installed as long as everything builds. With these tests in place, we will need to manually update the golden files whenever we add a new file to users' installations. PiperOrigin-RevId: 709134471 --- .github/workflows/test_cpp.yml | 73 +++++- cmake/installed_bin_golden.txt | 4 + cmake/installed_include_golden.txt | 328 ++++++++++++++++++++++++++ cmake/installed_lib_shared_golden.txt | 20 ++ cmake/installed_lib_static_golden.txt | 20 ++ 5 files changed, 441 insertions(+), 4 deletions(-) create mode 100644 cmake/installed_bin_golden.txt create mode 100644 cmake/installed_include_golden.txt create mode 100644 cmake/installed_lib_shared_golden.txt create mode 100644 cmake/installed_lib_static_golden.txt diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index c88eae04cd83..3d84826e9d88 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -184,15 +184,18 @@ jobs: strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: - type: [package, fetch] + type: [package, static, fetch] include: # Set defaults - type: package name: Install - flags: -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON + flags: -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON -Dprotobuf_BUILD_SHARED_LIBS=ON + - type: static + name: Install (static) + flags: -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF - type: fetch name: Install (Fetch) - flags: -Dprotobuf_FORCE_FETCH_DEPENDENCIES=ON + flags: -Dprotobuf_FORCE_FETCH_DEPENDENCIES=ON -Dprotobuf_BUILD_SHARED_LIBS=ON continuous-only: true name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }}Linux CMake ${{ matrix.name }} runs-on: ubuntu-latest @@ -219,7 +222,9 @@ jobs: command: >- /install.sh -DCMAKE_CXX_STANDARD=17 ${{ env.SCCACHE_CMAKE_FLAGS }} ${{ matrix.flags }} - -Dprotobuf_BUILD_SHARED_LIBS=ON \&\& + \&\& + cp build/install_manifest.txt . + \&\& /test.sh ${{ env.SCCACHE_CMAKE_FLAGS }} -Dprotobuf_REMOVE_INSTALLED_HEADERS=ON @@ -228,6 +233,66 @@ jobs: -DCMAKE_CXX_STANDARD=17 ${{ matrix.flags }} + - name: Clean up install manifest + if: ${{ !matrix.continuous-only || inputs.continuous-run }} + run: | + set -ex + mkdir manifest + cat install_manifest.txt | sort | sed 's:/usr/local/::g' > manifest/all.txt + cat manifest/all.txt | grep -E '^include/' | grep -vE 'internal' | sed 's:^include/::g' > manifest/include.txt + cat manifest/all.txt | grep -E '^bin/' | grep -vE '\-[0-9]+\.[0-9]+\.[0-9]+$' | sed 's:^bin/::g' > manifest/bin.txt + cat manifest/all.txt | grep -E '^lib/' | grep -vE '\.[0-9]+\.[0-9]+\.[0-9]+$' | sed 's:^lib/::g' > manifest/lib.txt + + - name: Upload install manifest + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + if: ${{ !matrix.continuous-only || inputs.continuous-run }} + with: + name: installed_files_${{ matrix.type }} + path: manifest/*.txt + + install-manifests: + strategy: + fail-fast: false # Don't cancel all jobs if one fails. + matrix: + type: [include, bin, lib] + build: [static, package] + include: + - type: lib + build: static + golden: 'lib_static' + - type: lib + build: package + golden: 'lib_shared' + name: Check Installed Files + needs: linux-cmake-install + runs-on: ubuntu-latest + steps: + - name: Checkout pending changes + uses: protocolbuffers/protobuf-ci/checkout@v3 + with: + ref: ${{ inputs.safe-checkout }} + + - name: Download manifest + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 #4.1.8 + with: + name: installed_files_${{ matrix.build }} + path: ${{ matrix.build }} + + - name: Compare against golden + run: | + set +e + GOLDEN_FILE=cmake/installed_${{ matrix.golden || matrix.type }}_golden.txt + DIFF="$(diff -u ${GOLDEN_FILE} ${{ matrix.build }}/${{ matrix.type }}.txt)" + if [ -n "$DIFF" ]; then + echo "Installed files do not match goldens!" + echo "If this is expected, please update the golden file: ${GOLDEN_FILE}" + echo "The following diffs were found:" + echo "$DIFF" + exit 1 + else + echo "Installed files match goldens." + fi + # This test should always be skipped on presubmit linux-cmake-examples: name: ${{ inputs.continuous-prefix }} Linux CMake Examples diff --git a/cmake/installed_bin_golden.txt b/cmake/installed_bin_golden.txt new file mode 100644 index 000000000000..a6e9d58cc66a --- /dev/null +++ b/cmake/installed_bin_golden.txt @@ -0,0 +1,4 @@ +protoc +protoc-gen-upb +protoc-gen-upb_minitable +protoc-gen-upbdefs diff --git a/cmake/installed_include_golden.txt b/cmake/installed_include_golden.txt new file mode 100644 index 000000000000..740b36b2f4a1 --- /dev/null +++ b/cmake/installed_include_golden.txt @@ -0,0 +1,328 @@ +google/protobuf/any.h +google/protobuf/any.pb.h +google/protobuf/any.proto +google/protobuf/api.pb.h +google/protobuf/api.proto +google/protobuf/arena.h +google/protobuf/arena_align.h +google/protobuf/arena_allocation_policy.h +google/protobuf/arena_cleanup.h +google/protobuf/arenastring.h +google/protobuf/arenaz_sampler.h +google/protobuf/compiler/code_generator.h +google/protobuf/compiler/code_generator_lite.h +google/protobuf/compiler/command_line_interface.h +google/protobuf/compiler/cpp/enum.h +google/protobuf/compiler/cpp/extension.h +google/protobuf/compiler/cpp/field.h +google/protobuf/compiler/cpp/field_generators/generators.h +google/protobuf/compiler/cpp/file.h +google/protobuf/compiler/cpp/generator.h +google/protobuf/compiler/cpp/helpers.h +google/protobuf/compiler/cpp/ifndef_guard.h +google/protobuf/compiler/cpp/message.h +google/protobuf/compiler/cpp/message_layout_helper.h +google/protobuf/compiler/cpp/names.h +google/protobuf/compiler/cpp/namespace_printer.h +google/protobuf/compiler/cpp/options.h +google/protobuf/compiler/cpp/padding_optimizer.h +google/protobuf/compiler/cpp/parse_function_generator.h +google/protobuf/compiler/cpp/service.h +google/protobuf/compiler/cpp/tracker.h +google/protobuf/compiler/csharp/csharp_doc_comment.h +google/protobuf/compiler/csharp/csharp_enum.h +google/protobuf/compiler/csharp/csharp_enum_field.h +google/protobuf/compiler/csharp/csharp_field_base.h +google/protobuf/compiler/csharp/csharp_generator.h +google/protobuf/compiler/csharp/csharp_helpers.h +google/protobuf/compiler/csharp/csharp_map_field.h +google/protobuf/compiler/csharp/csharp_message.h +google/protobuf/compiler/csharp/csharp_message_field.h +google/protobuf/compiler/csharp/csharp_options.h +google/protobuf/compiler/csharp/csharp_primitive_field.h +google/protobuf/compiler/csharp/csharp_reflection_class.h +google/protobuf/compiler/csharp/csharp_repeated_enum_field.h +google/protobuf/compiler/csharp/csharp_repeated_message_field.h +google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +google/protobuf/compiler/csharp/csharp_source_generator_base.h +google/protobuf/compiler/csharp/csharp_wrapper_field.h +google/protobuf/compiler/csharp/names.h +google/protobuf/compiler/importer.h +google/protobuf/compiler/java/context.h +google/protobuf/compiler/java/doc_comment.h +google/protobuf/compiler/java/field_common.h +google/protobuf/compiler/java/file.h +google/protobuf/compiler/java/full/enum.h +google/protobuf/compiler/java/full/enum_field.h +google/protobuf/compiler/java/full/extension.h +google/protobuf/compiler/java/full/field_generator.h +google/protobuf/compiler/java/full/generator_factory.h +google/protobuf/compiler/java/full/make_field_gens.h +google/protobuf/compiler/java/full/map_field.h +google/protobuf/compiler/java/full/message.h +google/protobuf/compiler/java/full/message_builder.h +google/protobuf/compiler/java/full/message_field.h +google/protobuf/compiler/java/full/primitive_field.h +google/protobuf/compiler/java/full/service.h +google/protobuf/compiler/java/full/string_field.h +google/protobuf/compiler/java/generator.h +google/protobuf/compiler/java/generator_common.h +google/protobuf/compiler/java/generator_factory.h +google/protobuf/compiler/java/helpers.h +google/protobuf/compiler/java/java_features.pb.h +google/protobuf/compiler/java/lite/enum.h +google/protobuf/compiler/java/lite/enum_field.h +google/protobuf/compiler/java/lite/extension.h +google/protobuf/compiler/java/lite/field_generator.h +google/protobuf/compiler/java/lite/generator_factory.h +google/protobuf/compiler/java/lite/make_field_gens.h +google/protobuf/compiler/java/lite/map_field.h +google/protobuf/compiler/java/lite/message.h +google/protobuf/compiler/java/lite/message_builder.h +google/protobuf/compiler/java/lite/message_field.h +google/protobuf/compiler/java/lite/primitive_field.h +google/protobuf/compiler/java/lite/string_field.h +google/protobuf/compiler/java/message_serialization.h +google/protobuf/compiler/java/name_resolver.h +google/protobuf/compiler/java/names.h +google/protobuf/compiler/java/options.h +google/protobuf/compiler/java/shared_code_generator.h +google/protobuf/compiler/kotlin/field.h +google/protobuf/compiler/kotlin/file.h +google/protobuf/compiler/kotlin/generator.h +google/protobuf/compiler/kotlin/message.h +google/protobuf/compiler/objectivec/enum.h +google/protobuf/compiler/objectivec/enum_field.h +google/protobuf/compiler/objectivec/extension.h +google/protobuf/compiler/objectivec/field.h +google/protobuf/compiler/objectivec/file.h +google/protobuf/compiler/objectivec/generator.h +google/protobuf/compiler/objectivec/helpers.h +google/protobuf/compiler/objectivec/import_writer.h +google/protobuf/compiler/objectivec/line_consumer.h +google/protobuf/compiler/objectivec/map_field.h +google/protobuf/compiler/objectivec/message.h +google/protobuf/compiler/objectivec/message_field.h +google/protobuf/compiler/objectivec/names.h +google/protobuf/compiler/objectivec/nsobject_methods.h +google/protobuf/compiler/objectivec/oneof.h +google/protobuf/compiler/objectivec/options.h +google/protobuf/compiler/objectivec/primitive_field.h +google/protobuf/compiler/objectivec/tf_decode_data.h +google/protobuf/compiler/parser.h +google/protobuf/compiler/php/names.h +google/protobuf/compiler/php/php_generator.h +google/protobuf/compiler/plugin.h +google/protobuf/compiler/plugin.pb.h +google/protobuf/compiler/plugin.proto +google/protobuf/compiler/python/generator.h +google/protobuf/compiler/python/helpers.h +google/protobuf/compiler/python/pyi_generator.h +google/protobuf/compiler/retention.h +google/protobuf/compiler/ruby/ruby_generator.h +google/protobuf/compiler/rust/accessors/accessor_case.h +google/protobuf/compiler/rust/accessors/accessors.h +google/protobuf/compiler/rust/accessors/default_value.h +google/protobuf/compiler/rust/accessors/generator.h +google/protobuf/compiler/rust/accessors/with_presence.h +google/protobuf/compiler/rust/context.h +google/protobuf/compiler/rust/crate_mapping.h +google/protobuf/compiler/rust/enum.h +google/protobuf/compiler/rust/generator.h +google/protobuf/compiler/rust/message.h +google/protobuf/compiler/rust/naming.h +google/protobuf/compiler/rust/oneof.h +google/protobuf/compiler/rust/relative_path.h +google/protobuf/compiler/rust/rust_field_type.h +google/protobuf/compiler/rust/rust_keywords.h +google/protobuf/compiler/rust/upb_helpers.h +google/protobuf/compiler/scc.h +google/protobuf/compiler/subprocess.h +google/protobuf/compiler/versions.h +google/protobuf/compiler/zip_writer.h +google/protobuf/cpp_edition_defaults.h +google/protobuf/cpp_features.pb.h +google/protobuf/cpp_features.proto +google/protobuf/descriptor.h +google/protobuf/descriptor.pb.h +google/protobuf/descriptor.proto +google/protobuf/descriptor.upb.h +google/protobuf/descriptor.upb_minitable.h +google/protobuf/descriptor_database.h +google/protobuf/descriptor_legacy.h +google/protobuf/descriptor_lite.h +google/protobuf/descriptor_visitor.h +google/protobuf/duration.pb.h +google/protobuf/duration.proto +google/protobuf/dynamic_message.h +google/protobuf/empty.pb.h +google/protobuf/empty.proto +google/protobuf/endian.h +google/protobuf/explicitly_constructed.h +google/protobuf/extension_set.h +google/protobuf/extension_set_inl.h +google/protobuf/feature_resolver.h +google/protobuf/field_access_listener.h +google/protobuf/field_mask.pb.h +google/protobuf/field_mask.proto +google/protobuf/generated_enum_reflection.h +google/protobuf/generated_enum_util.h +google/protobuf/generated_message_bases.h +google/protobuf/generated_message_reflection.h +google/protobuf/generated_message_tctable_decl.h +google/protobuf/generated_message_tctable_gen.h +google/protobuf/generated_message_tctable_impl.h +google/protobuf/generated_message_util.h +google/protobuf/go_features.proto +google/protobuf/has_bits.h +google/protobuf/implicit_weak_message.h +google/protobuf/inlined_string_field.h +google/protobuf/io/coded_stream.h +google/protobuf/io/gzip_stream.h +google/protobuf/io/io_win32.h +google/protobuf/io/printer.h +google/protobuf/io/strtod.h +google/protobuf/io/tokenizer.h +google/protobuf/io/zero_copy_sink.h +google/protobuf/io/zero_copy_stream.h +google/protobuf/io/zero_copy_stream_impl.h +google/protobuf/io/zero_copy_stream_impl_lite.h +google/protobuf/java_features.proto +google/protobuf/json/json.h +google/protobuf/map.h +google/protobuf/map_entry.h +google/protobuf/map_field.h +google/protobuf/map_field_inl.h +google/protobuf/map_field_lite.h +google/protobuf/map_type_handler.h +google/protobuf/message.h +google/protobuf/message_lite.h +google/protobuf/metadata.h +google/protobuf/metadata_lite.h +google/protobuf/parse_context.h +google/protobuf/port.h +google/protobuf/port_def.inc +google/protobuf/port_undef.inc +google/protobuf/raw_ptr.h +google/protobuf/reflection.h +google/protobuf/reflection_mode.h +google/protobuf/reflection_ops.h +google/protobuf/reflection_visit_field_info.h +google/protobuf/reflection_visit_fields.h +google/protobuf/repeated_field.h +google/protobuf/repeated_ptr_field.h +google/protobuf/runtime_version.h +google/protobuf/serial_arena.h +google/protobuf/service.h +google/protobuf/source_context.pb.h +google/protobuf/source_context.proto +google/protobuf/string_block.h +google/protobuf/struct.pb.h +google/protobuf/struct.proto +google/protobuf/stubs/callback.h +google/protobuf/stubs/common.h +google/protobuf/stubs/platform_macros.h +google/protobuf/stubs/port.h +google/protobuf/stubs/status_macros.h +google/protobuf/testing/file.h +google/protobuf/text_format.h +google/protobuf/thread_safe_arena.h +google/protobuf/timestamp.pb.h +google/protobuf/timestamp.proto +google/protobuf/type.pb.h +google/protobuf/type.proto +google/protobuf/unknown_field_set.h +google/protobuf/util/delimited_message_util.h +google/protobuf/util/field_comparator.h +google/protobuf/util/field_mask_util.h +google/protobuf/util/json_util.h +google/protobuf/util/message_differencer.h +google/protobuf/util/time_util.h +google/protobuf/util/type_resolver.h +google/protobuf/util/type_resolver_util.h +google/protobuf/varint_shuffle.h +google/protobuf/wire_format.h +google/protobuf/wire_format_lite.h +google/protobuf/wrappers.pb.h +google/protobuf/wrappers.proto +upb/base/descriptor_constants.h +upb/base/status.h +upb/base/status.hpp +upb/base/string_view.h +upb/base/upcast.h +upb/generated_code_support.h +upb/hash/common.h +upb/hash/int_table.h +upb/hash/str_table.h +upb/json/decode.h +upb/json/encode.h +upb/lex/atoi.h +upb/lex/round_trip.h +upb/lex/strtod.h +upb/lex/unicode.h +upb/mem/alloc.h +upb/mem/arena.h +upb/mem/arena.hpp +upb/message/accessors.h +upb/message/array.h +upb/message/compare.h +upb/message/compat.h +upb/message/copy.h +upb/message/map.h +upb/message/map_gencode_util.h +upb/message/merge.h +upb/message/message.h +upb/message/tagged_ptr.h +upb/message/value.h +upb/mini_descriptor/build_enum.h +upb/mini_descriptor/decode.h +upb/mini_descriptor/link.h +upb/mini_table/enum.h +upb/mini_table/extension.h +upb/mini_table/extension_registry.h +upb/mini_table/field.h +upb/mini_table/file.h +upb/mini_table/message.h +upb/mini_table/sub.h +upb/port/atomic.h +upb/port/atomic.h +upb/port/def.inc +upb/port/def.inc +upb/port/undef.inc +upb/port/undef.inc +upb/port/vsnprintf_compat.h +upb/port/vsnprintf_compat.h +upb/reflection/common.h +upb/reflection/def.h +upb/reflection/def.hpp +upb/reflection/def_pool.h +upb/reflection/def_type.h +upb/reflection/descriptor_bootstrap.h +upb/reflection/enum_def.h +upb/reflection/enum_reserved_range.h +upb/reflection/enum_value_def.h +upb/reflection/extension_range.h +upb/reflection/field_def.h +upb/reflection/file_def.h +upb/reflection/message.h +upb/reflection/message.hpp +upb/reflection/message_def.h +upb/reflection/message_reserved_range.h +upb/reflection/method_def.h +upb/reflection/oneof_def.h +upb/reflection/service_def.h +upb/text/debug_string.h +upb/text/encode.h +upb/text/options.h +upb/util/def_to_proto.h +upb/util/required_fields.h +upb/wire/byte_size.h +upb/wire/decode.h +upb/wire/encode.h +upb/wire/eps_copy_input_stream.h +upb/wire/reader.h +upb/wire/types.h +upb_generator/common/names.h +upb_generator/minitable/names.h +utf8_range.h +utf8_validity.h diff --git a/cmake/installed_lib_shared_golden.txt b/cmake/installed_lib_shared_golden.txt new file mode 100644 index 000000000000..e394f08f2c03 --- /dev/null +++ b/cmake/installed_lib_shared_golden.txt @@ -0,0 +1,20 @@ +cmake/protobuf/protobuf-config-version.cmake +cmake/protobuf/protobuf-config.cmake +cmake/protobuf/protobuf-generate.cmake +cmake/protobuf/protobuf-module.cmake +cmake/protobuf/protobuf-options.cmake +cmake/protobuf/protobuf-targets-noconfig.cmake +cmake/protobuf/protobuf-targets.cmake +cmake/utf8_range/utf8_range-config.cmake +cmake/utf8_range/utf8_range-targets-noconfig.cmake +cmake/utf8_range/utf8_range-targets.cmake +libprotobuf-lite.so +libprotobuf.so +libprotoc.so +libupb.a +libutf8_range.so +libutf8_validity.so +pkgconfig/protobuf-lite.pc +pkgconfig/protobuf.pc +pkgconfig/upb.pc +pkgconfig/utf8_range.pc diff --git a/cmake/installed_lib_static_golden.txt b/cmake/installed_lib_static_golden.txt new file mode 100644 index 000000000000..9057a16b3fba --- /dev/null +++ b/cmake/installed_lib_static_golden.txt @@ -0,0 +1,20 @@ +cmake/protobuf/protobuf-config-version.cmake +cmake/protobuf/protobuf-config.cmake +cmake/protobuf/protobuf-generate.cmake +cmake/protobuf/protobuf-module.cmake +cmake/protobuf/protobuf-options.cmake +cmake/protobuf/protobuf-targets-noconfig.cmake +cmake/protobuf/protobuf-targets.cmake +cmake/utf8_range/utf8_range-config.cmake +cmake/utf8_range/utf8_range-targets-noconfig.cmake +cmake/utf8_range/utf8_range-targets.cmake +libprotobuf-lite.a +libprotobuf.a +libprotoc.a +libupb.a +libutf8_range.a +libutf8_validity.a +pkgconfig/protobuf-lite.pc +pkgconfig/protobuf.pc +pkgconfig/upb.pc +pkgconfig/utf8_range.pc