Skip to content

Commit

Permalink
Add release tests for statically linked binaries
Browse files Browse the repository at this point in the history
For now, this only covers linux on the two architectures we have testing support for.  However, it serves as a good sanity check and can be expanded in the future.

PiperOrigin-RevId: 514449399
  • Loading branch information
mkruskal-google authored and deannagarcia committed Mar 6, 2023
1 parent 554bdb1 commit 8a07f45
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 11 deletions.
45 changes: 42 additions & 3 deletions .github/workflows/test_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
targets: "//src/..."
- config: { name: "aarch64" }
targets: "//src/... //src/google/protobuf/compiler:protoc_aarch64_test"
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-508417e5215994ade7585d28ba3aad681a25fa5d"
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733"
- config: { name: "Bazel4" }
targets: "//src/..."
image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:4.2.3-6361b3a6e5c97e9951d03a4de28542fc45f1adab"
Expand All @@ -51,6 +51,45 @@ jobs:
bazel-cache: cpp_linux/${{ matrix.config.name }}
bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }} --distinct_host_configuration=false

linux-release:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
arch: [x86_64, aarch64]
name: Linux Release ${{ matrix.arch}}
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: recursive
ref: ${{ inputs.safe-checkout }}
- name: Cross compile protoc for ${{ matrix.arch }}
id: cross-compile
uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
architecture: linux-${{ matrix.arch }}
- name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-release-${{ matrix.arch }}
- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:${{ matrix.arch }}-3af05275178e16af30961976af126eabbbb2c733
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
skip-staleness-check: true
entrypoint: bash
command: >
-c "set -ex;
ccache -z;
cmake . -DWITH_PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} -Dprotobuf_BUILD_CONFORMANCE=ON -DCMAKE_CXX_STANDARD=14 -Dprotobuf_WITH_ZLIB=OFF ${{ env.CCACHE_CMAKE_FLAGS }};
cmake --build . --parallel 20;
ctest --parallel 20;
ccache -s -v"
linux-cmake:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
Expand Down Expand Up @@ -91,7 +130,7 @@ jobs:
- name: Run tests
uses: ./.github/actions/docker
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e8282f42b1c1c0e6227d746e861954fd6fad0bd2e7424e6ceb23c249289a4016
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e0eb6c69b7551d89f0dbdbe11906077a1d501229c28db39623b945e0c5d7029a
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: ${{ matrix.command }} ${{ env.CCACHE_CMAKE_FLAGS }}

Expand All @@ -113,7 +152,7 @@ jobs:
- name: Run tests
uses: ./.github/actions/docker
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e8282f42b1c1c0e6227d746e861954fd6fad0bd2e7424e6ceb23c249289a4016
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e0eb6c69b7551d89f0dbdbe11906077a1d501229c28db39623b945e0c5d7029a
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >-
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} \&\&
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
targets: //java/... //java/internal:java_version
- name: aarch64
version: 'aarch64'
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-508417e5215994ade7585d28ba3aad681a25fa5d
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733
targets: //java/... //src/google/protobuf/compiler:protoc_aarch64_test

name: Linux ${{ matrix.name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
targets: //python/... //python:aarch64_test
# TODO(b/262628111) Enable this once conformance tests are fixed.
flags: --define=use_fast_cpp_protos=true --test_tag_filters=-conformance
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-508417e5215994ade7585d28ba3aad681a25fa5d
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733

name: Linux ${{ matrix.type }} ${{ matrix.version }}
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ cc_binary(
linkopts = LINK_OPTS,
features = select({
# This isn't possible on mac because there is no static library for lcrt0.o
"@platforms//os:osx": [],
"//build_defs:config_osx": [],
# When cross-compiling we need to statically link all C++ libraries.
"//conditions:default": ["fully_static_link"],
Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ endif()

# Options
option(protobuf_INSTALL "Install protobuf binaries and files" ON)
if(WITH_PROTOC)
set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
endif()
option(protobuf_BUILD_TESTS "Build tests" ON)
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
Expand All @@ -76,6 +73,14 @@ option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT
set(protobuf_DEBUG_POSTFIX "d"
CACHE STRING "Default debug postfix")
mark_as_advanced(protobuf_DEBUG_POSTFIX)

if(WITH_PROTOC)
set(protobuf_PROTOC_EXE protoc)
set(protobuf_BUILD_PROTOC_BINARIES OFF)
add_executable(protoc IMPORTED)
set_property(TARGET protoc PROPERTY IMPORTED_LOCATION ${WITH_PROTOC})
endif()

# User options
include(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake)

Expand Down
1 change: 0 additions & 1 deletion build_defs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ config_setting(
selects.config_setting_group(
name = "config_osx",
match_any = [
"@platforms//os:osx",
":config_osx_aarch64",
":config_osx_x86_64",
]
Expand Down
4 changes: 2 additions & 2 deletions cmake/protobuf-generate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ function(protobuf_generate)

add_custom_command(
OUTPUT ${_generated_srcs}
COMMAND protobuf::protoc
COMMAND ${protobuf_PROTOC_EXE}
ARGS ${protobuf_generate_PROTOC_OPTIONS} --${protobuf_generate_LANGUAGE}_out ${_plugin_options}:${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file}
DEPENDS ${_abs_file} protobuf::protoc ${protobuf_generate_DEPENDENCIES}
DEPENDS ${_abs_file} ${protobuf_PROTOC_EXE} ${protobuf_generate_DEPENDENCIES}
COMMENT ${_comment}
VERBATIM )
endforeach()
Expand Down

0 comments on commit 8a07f45

Please sign in to comment.