Add a non-bazel docker action and use it for CMake/PHP tests
diff --git a/.github/actions/internal/docker-run/action.yml b/.github/actions/internal/docker-run/action.yml
index b08d836..8ee96ef 100644
--- a/.github/actions/internal/docker-run/action.yml
+++ b/.github/actions/internal/docker-run/action.yml
@@ -18,8 +18,6 @@
docker-cache:
required: false
description: "Enabled caching of pulled docker images."
- default: false
- type: boolean
runs:
using: 'composite'
diff --git a/.github/actions/non-bazel-docker/action.yml b/.github/actions/non-bazel-docker/action.yml
new file mode 100644
index 0000000..23e502a
--- /dev/null
+++ b/.github/actions/non-bazel-docker/action.yml
@@ -0,0 +1,32 @@
+name: 'Docker Non-Bazel Run'
+description: 'Run a docker image for Protobuf CI testing with a non-Bazel build system'
+inputs:
+ credentials:
+ required: true
+ description: "The GCP credentials to use for reading the docker image"
+ type: string
+ command:
+ required: true
+ description: A command to run in the docker image
+ image:
+ required: false
+ default: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-aec4d74f2eb6938fc53ef7d9a79a4bf2da24abc1
+ description: "The docker image to use"
+ type: string
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Update stale files using Bazel
+ uses: ./.github/actions/bazel-docker
+ with:
+ image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-aec4d74f2eb6938fc53ef7d9a79a4bf2da24abc1
+ credentials: ${{ inputs.credentials }}
+ bazel-cache: regenerate-stale-files
+ bash: ./regenerate_stale_files.sh $BAZEL_FLAGS
+
+ - name: Run Docker
+ uses: ./.github/actions/internal/docker-run
+ with:
+ image: ${{ inputs.image }}
+ command: ${{ inputs.command }}
diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml
index 54ebc9d..a82fc36 100644
--- a/.github/workflows/test_cpp.yml
+++ b/.github/workflows/test_cpp.yml
@@ -51,3 +51,47 @@
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: cpp_bazel/${{ matrix.config.name }}
bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }} --distinct_host_configuration=false
+
+ cmake:
+ strategy:
+ fail-fast: false # Don't cancel all jobs if one fails.
+ matrix:
+ include:
+ - command: >
+ /test.sh
+ -Dprotobuf_BUILD_CONFORMANCE=ON
+ -Dprotobuf_BUILD_EXAMPLES=ON
+ -DCMAKE_CXX_STANDARD=14
+ - name: Ninja
+ command: >
+ /test.sh
+ -G Ninja
+ -Dprotobuf_BUILD_CONFORMANCE=ON
+ -DCMAKE_CXX_STANDARD=14
+ - name: Shared
+ command: >
+ /test.sh
+ -Dprotobuf_BUILD_CONFORMANCE=ON
+ -Dprotobuf_BUILD_SHARED_LIBS=ON
+ -DCMAKE_CXX_STANDARD=14
+ - name: Install
+ command: >
+ /install.sh -DCMAKE_CXX_STANDARD=14 \&\& /test.sh
+ -Dprotobuf_REMOVE_INSTALLED_HEADERS=ON
+ -Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF
+ -Dprotobuf_BUILD_CONFORMANCE=ON
+ -DCMAKE_CXX_STANDARD=14
+ name: Linux CMake ${{ matrix.name}}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout pending changes
+ uses: actions/checkout@v3
+ with:
+ submodules: recursive
+ ref: ${{ inputs.safe-checkout }}
+ - name: Run tests
+ uses: ./.github/actions/non-bazel-docker
+ with:
+ image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:cc23dbe065668158ca2732aa305a07bd0913a175b2079d27d9c16925d23f2335
+ credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
+ command: ${{ matrix.command }}
diff --git a/.github/workflows/test_php.yml b/.github/workflows/test_php.yml
new file mode 100644
index 0000000..ffad7db
--- /dev/null
+++ b/.github/workflows/test_php.yml
@@ -0,0 +1,50 @@
+name: PHP Tests
+
+on:
+ workflow_call:
+ inputs:
+ safe-checkout:
+ required: true
+ description: "The SHA key for the commit we want to run over"
+ type: string
+
+jobs:
+ linux:
+ strategy:
+ fail-fast: false # Don't cancel all jobs if one fails.
+ matrix:
+ include:
+ - name: 7.3 Debug
+ version: 7.3.28-dbg
+ command: composer test \&\& composer test_c
+ - name: 7.4 Debug
+ version: 7.4.18-dbg
+ command: composer test \&\& composer test_c
+ - name: 8.0 Optimized
+ version: 8.0.5
+ command: composer test \&\& composer test_c
+ - name: 8.0 Debug
+ version: 8.0.5-dbg
+ command: composer test \&\& composer test_c
+ - name: 8.0 Memory Leak
+ version: 8.0.5-dbg
+ # Run specialized memory leak & multirequest tests.
+ command: composer test_c \&\& tests/multirequest.sh \&\& tests/memory_leak_test.sh
+ - name: 8.0 Valgrind
+ version: 8.0.5-dbg
+ command: composer test_valgrind
+
+ name: Linux PHP ${{ matrix.name}}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout pending changes
+ uses: actions/checkout@v3
+ with:
+ submodules: recursive
+ ref: ${{ inputs.safe-checkout }}
+ - name: Run tests
+ uses: ./.github/actions/non-bazel-docker
+ with:
+ image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:${{ matrix.version }}-6e95c0e221e4bd52e3b4dc1398c6336985196931
+ credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
+ command: ${{ matrix.command }}
diff --git a/.github/workflows/test_runner.yml b/.github/workflows/test_runner.yml
index 1dd6411..357acb7 100644
--- a/.github/workflows/test_runner.yml
+++ b/.github/workflows/test_runner.yml
@@ -105,6 +105,14 @@
safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }}
secrets: inherit
+ php:
+ name: PHP
+ needs: [check-tag]
+ uses: ./.github/workflows/test_php.yml
+ with:
+ safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }}
+ secrets: inherit
+
php-ext:
name: PHP Extension
needs: [check-tag]
diff --git a/cmake/gtest.cmake b/cmake/gtest.cmake
index 7e246fb..5562380 100644
--- a/cmake/gtest.cmake
+++ b/cmake/gtest.cmake
@@ -31,10 +31,10 @@
COMPILE_DEFINITIONS
"GTEST_CREATE_SHARED_LIBRARY=1"
)
- install(TARGETS gmock EXPORT protobuf-targets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+ if (protobuf_INSTALL)
+ set(protobuf_INSTALL_TESTS ON)
+ endif()
endif()
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 90230c5..f7a0d9e 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -113,3 +113,10 @@
DESTINATION "${CMAKE_INSTALL_EXAMPLEDIR}"
COMPONENT protobuf-examples)
endif()
+
+if (protobuf_INSTALL_TESTS)
+ install(TARGETS gmock EXPORT protobuf-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif()
diff --git a/regenerate_stale_files.sh b/regenerate_stale_files.sh
index 8c57c90..bca9c0e 100755
--- a/regenerate_stale_files.sh
+++ b/regenerate_stale_files.sh
@@ -10,13 +10,13 @@
# Run and fix all staleness tests.
# LINT.IfChange(staleness_tests)
-bazel test //src:cmake_lists_staleness_test || ./bazel-bin/src/cmake_lists_staleness_test --fix
-bazel test //src/google/protobuf:well_known_types_staleness_test || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
+bazel test //src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix
+bazel test //src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
# LINT.ThenChange(//depot/google3/third_party/protobuf/github/kokoro/windows/prepare_build_win64.bat:staleness_tests)
# Generate C# code.
# This doesn't currently have Bazel staleness tests, but there's an existing
# shell script that generates everything required. The output files are stable,
# so just regenerating in place should be harmless.
-bazel build src/google/protobuf/compiler:protoc
+bazel build src/google/protobuf/compiler:protoc "$@"
(export PROTOC=$PWD/bazel-bin/protoc && cd csharp && ./generate_protos.sh)