Adding Github Action to keep CMake generated file lists up to date (#10243)

pull/10245/head
Mike Kruskal 3 years ago committed by GitHub
parent 2c7b0470ba
commit 445a49480c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      .github/workflows/generated_cmake.yml
  2. 22
      BUILD.bazel
  3. 3
      Makefile.am
  4. 62
      build_files_updated_unittest.sh
  5. 2
      cmake/update_file_lists.sh
  6. 1
      pkg/BUILD.bazel
  7. 2
      src/google/protobuf/util/BUILD.bazel

@ -0,0 +1,24 @@
name: Generated CMake File Lists
on:
- push
- pull_request
jobs:
cmake:
runs-on: ubuntu-latest
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
steps:
- uses: actions/checkout@v2
- name: Set up Bazel read-only caching
run: echo "BAZEL_CACHE_AUTH=--remote_upload_local_results=false" >> $GITHUB_ENV
- name: Generate CMake files
run: cd ${{ github.workspace }} && bazel build //pkg:gen_src_file_lists --test_output=errors $BAZEL_CACHE $BAZEL_CACHE_AUTH
- name: Compare to Golden file
run: diff -du bazel-bin/pkg/src_file_lists.cmake src/file_lists.cmake
- name: Report
run: echo "::error file=cmake/update_file_lists.sh::CMake files are stale, please run cmake/update_file_lists.sh"
if: failure()

@ -386,25 +386,6 @@ alias(
visibility = ["//visibility:public"],
)
# TODO: re-enable this test if appropriate, or replace with something that
# uses the new setup.
# sh_test(
# name = "build_files_updated_unittest",
# srcs = [
# "build_files_updated_unittest.sh",
# ],
# data = [
# "BUILD",
# "cmake/extract_includes.bat.in",
# "cmake/libprotobuf.cmake",
# "cmake/libprotobuf-lite.cmake",
# "cmake/libprotoc.cmake",
# "cmake/tests.cmake",
# "src/Makefile.am",
# "update_file_lists.sh",
# ],
# )
java_proto_library(
name = "test_messages_proto2_java_proto",
visibility = [
@ -488,12 +469,11 @@ pkg_files(
"README.md",
"WORKSPACE",
"autogen.sh",
"build_files_updated_unittest.sh",
"cmake/CMakeLists.txt",
"cmake/README.md",
"cmake/update_file_lists.sh",
"generate_descriptor_proto.sh",
"maven_install.json",
"update_file_lists.sh",
"//third_party:BUILD.bazel",
"//third_party:zlib.BUILD",
"//util/python:BUILD.bazel",

@ -1201,7 +1201,6 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
LICENSE \
CONTRIBUTORS.txt \
CHANGES.txt \
update_file_lists.sh \
BUILD.bazel \
WORKSPACE \
CMakeLists.txt \
@ -1209,7 +1208,6 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
build_defs/cc_proto_blacklist_test.bzl \
build_defs/compiler_config_setting.bzl \
build_defs/cpp_opts.bzl \
build_files_updated_unittest.sh \
cmake/CMakeLists.txt \
cmake/README.md \
cmake/conformance.cmake \
@ -1226,6 +1224,7 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
cmake/protobuf-options.cmake \
cmake/protobuf.pc.cmake \
cmake/protoc.cmake \
cmake/update_file_lists.sh \
cmake/tests.cmake \
cmake/version.rc.in \
csharp/BUILD.bazel \

@ -1,62 +0,0 @@
#!/bin/bash
# This script verifies that BUILD files and cmake files are in sync with src/Makefile.am
set -eo pipefail
if [ "$(uname)" != "Linux" ]; then
echo "build_files_updated_unittest only supported on Linux. Skipping..."
exit 0
fi
# Keep in sync with files needed by update_file_lists.sh
generated_files=(
"BUILD"
"cmake/extract_includes.bat.in"
"cmake/libprotobuf-lite.cmake"
"cmake/libprotobuf.cmake"
"cmake/libprotoc.cmake"
"cmake/tests.cmake"
"src/Makefile.am"
)
# If we're running in Bazel, use the Bazel-provided temp-dir.
if [ -n "${TEST_TMPDIR}" ]; then
# Env-var TEST_TMPDIR is set, assume that this is Bazel.
# Bazel may have opinions whether we are allowed to delete TEST_TMPDIR.
test_root="${TEST_TMPDIR}/build_files_updated_unittest"
mkdir "${test_root}"
else
# Seems like we're not executed by Bazel.
test_root=$(mktemp -d)
fi
# From now on, fail if there are any unbound variables.
set -u
# Remove artifacts after test is finished.
function cleanup {
rm -rf "${test_root}"
}
trap cleanup EXIT
# Create golden dir and add snapshot of current state.
golden_dir="${test_root}/golden"
mkdir -p "${golden_dir}/cmake" "${golden_dir}/src"
for file in ${generated_files[@]}; do
cp "${file}" "${golden_dir}/${file}"
done
# Create test dir, copy current state into it, and execute update script.
test_dir="${test_root}/test"
cp -R "${golden_dir}" "${test_dir}"
cp "update_file_lists.sh" "${test_dir}/update_file_lists.sh"
chmod +x "${test_dir}/update_file_lists.sh"
cd "${test_root}/test"
bash "${test_dir}/update_file_lists.sh"
# Test whether there are any differences
for file in ${generated_files[@]}; do
diff -du "${golden_dir}/${file}" "${test_dir}/${file}"
done

@ -1,6 +1,6 @@
#!/bin/bash -u
# This script generates file lists from Bazel, e.g., for cmake.
# This script generates file lists from Bazel for CMake.
set -e

@ -400,6 +400,7 @@ cc_dist_library(
"//src/google/protobuf/util:differencer",
"//src/google/protobuf/util:field_mask_util",
"//src/google/protobuf/util:json_util",
"//src/google/protobuf/util:zero_copy_sink",
"//src/google/protobuf/util:time_util",
"//src/google/protobuf/util:type_resolver_util",
"//src/google/protobuf/util/internal:datapiece",

@ -118,7 +118,7 @@ cc_library(
hdrs = ["zero_copy_sink.h"],
copts = COPTS,
strip_include_prefix = "/src",
visibility = ["//visibility:private"],
visibility = ["//pkg:__pkg__"],
deps = [
"//src/google/protobuf",
"//src/google/protobuf/io",

Loading…
Cancel
Save