Skip to content

Commit

Permalink
Define a new set of cmake tests.
Browse files Browse the repository at this point in the history
These more closely follow the standard practices of our users, where dependencies are pre-installed instead of using our provided sub-modules.  This will prevent issues such as #12201 from reoccuring.

PiperOrigin-RevId: 529211944
  • Loading branch information
mkruskal-google authored and copybara-github committed May 4, 2023
1 parent 23e2e6f commit b1da98c
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 8 deletions.
112 changes: 107 additions & 5 deletions .github/workflows/test_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,108 @@ jobs:
ccache -s -v"
linux-cmake:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
include:
- flags: -Dprotobuf_BUILD_EXAMPLES=ON
- name: Ninja
flags: -G Ninja
- name: Shared
flags: -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_EXAMPLES=ON

name: Linux CMake ${{ matrix.name}}
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}

- name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-cmake2-${{ matrix.name }}

- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:9836c8e6f3890cf5dd845c114c0e13b6e91ff7458290267a6f99c46d4ebd6952
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: |
cmake . \
-DCMAKE_CXX_STANDARD=14 \
-Dprotobuf_BUILD_TESTS=ON \
-Dprotobuf_USE_EXTERNAL_GTEST=ON \
-Dprotobuf_ABSL_PROVIDER=package \
${{ matrix.flags}} ${{ env.CCACHE_CMAKE_FLAGS }}
cmake --build . --parallel 20
ctest --verbose --parallel 20
ccache -s -v
linux-cmake-install:
name: Linux CMake Install
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}

- name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-cmake-install2

- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:9836c8e6f3890cf5dd845c114c0e13b6e91ff7458290267a6f99c46d4ebd6952
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: |
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} -Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
/test.sh \
${{ env.CCACHE_CMAKE_FLAGS }} \
-Dprotobuf_REMOVE_INSTALLED_HEADERS=ON \
-Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF \
-Dprotobuf_BUILD_CONFORMANCE=ON \
-DCMAKE_CXX_STANDARD=14 \
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
linux-cmake-examples:
name: Linux CMake Examples
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
submodules: recursive

- name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-cmake-examples

- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:9836c8e6f3890cf5dd845c114c0e13b6e91ff7458290267a6f99c46d4ebd6952
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: |
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} -Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
cd examples
mkdir build
cmake -S . -B build \
${{ env.CCACHE_CMAKE_FLAGS }} \
-Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF \
-DCMAKE_CXX_STANDARD=14 \
-Dprotobuf_USE_EXTERNAL_GTEST=ON \
-Dprotobuf_ABSL_PROVIDER=package
cmake --build build
linux-cmake-submodules:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
Expand All @@ -112,7 +214,7 @@ jobs:
-Dprotobuf_BUILD_SHARED_LIBS=ON
-DCMAKE_CXX_STANDARD=14
name: Linux CMake ${{ matrix.name}}
name: Linux CMake (Submodules) ${{ matrix.name}}
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
Expand All @@ -137,8 +239,8 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: ${{ matrix.command }} ${{ env.CCACHE_CMAKE_FLAGS }}

linux-cmake-install:
name: Linux CMake Install
linux-cmake-install-submodules:
name: Linux CMake Install (Submodules)
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
Expand Down Expand Up @@ -200,8 +302,8 @@ jobs:
ctest --verbose --parallel 20;
ccache -s'
linux-cmake-examples:
name: Linux CMake Examples
linux-cmake-examples-submodules:
name: Linux CMake Examples (Submodules)
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
Expand Down
2 changes: 1 addition & 1 deletion cmake/gtest.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF)

if (protobuf_USE_EXTERNAL_GTEST)
find_package(GTest REQUIRED)
find_package(GTest REQUIRED CONFIG)
else()
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt")
message(FATAL_ERROR
Expand Down
4 changes: 2 additions & 2 deletions protobuf_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def protobuf_deps():
_github_archive(
name = "com_google_absl",
repo = "https://github.com/abseil/abseil-cpp",
commit = "b971ac5250ea8de900eae9f95e06548d14cd95fe", # Abseil LTS 20230125.2
sha256 = "f7c2cb2c5accdcbbbd5c0c59f241a988c0b1da2a3b7134b823c0bd613b1a6880",
commit = "c2435f8342c2d0ed8101cb43adfd605fdc52dca2", # Abseil LTS 20230125.3
sha256 = "ea1d31db00eb37e607bfda17ffac09064670ddf05da067944c4766f517876390",
)

if not native.existing_rule("zlib"):
Expand Down

0 comments on commit b1da98c

Please sign in to comment.