Skip to content

Commit

Permalink
Some more updates to PHP testing infrastructure (#8576)
Browse files Browse the repository at this point in the history
* WIP.

* Added build config for all of the tests.

* Use ../src/protoc if it is available, for cases where Bazel isn't available.

* Added test_php.sh.

* Fix for the broken macOS tests.

* Move all jobs to use php80 instead of lots of separate jobs.

* Only pass -t flag if we are running in a terminal.

* Updated php_all job to use new Docker stuff.
  • Loading branch information
haberman authored May 12, 2021
1 parent a84686c commit 45e9707
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 48 deletions.
27 changes: 13 additions & 14 deletions kokoro/linux/php80/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/bin/bash
#
# This is the top-level script we give to Kokoro as the entry point for
# running the "pull request" project:
#
# This script selects a specific Dockerfile (for building a Docker image) and
# a script to run inside that image. Then we delegate to the general
# build_and_run_docker.sh script.
# This is the entry point for kicking off a Kokoro job. This path is referenced
# from the .cfg files in this directory.

set -ex

cd $(dirname $0)

# Change to repo root
cd $(dirname $0)/../../..
# Most of our tests use a debug build of PHP, but we do one build against an opt
# php just in case that surfaces anything unexpected.
../test_php.sh gcr.io/protobuf-build/php/linux:8.0.5-14a06550010c0649bf69b6c9b803c1ca609bbb6d

export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php80
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput
export TEST_SET="php8.0_all"
./kokoro/linux/build_and_run_docker.sh
../test_php.sh gcr.io/protobuf-build/php/linux:7.0.33-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
../test_php.sh gcr.io/protobuf-build/php/linux:7.3.28-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
../test_php.sh gcr.io/protobuf-build/php/linux:7.4.18-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
../test_php.sh gcr.io/protobuf-build/php/linux:8.0.5-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
8 changes: 1 addition & 7 deletions kokoro/linux/php80/continuous.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@

# Location of the build script in repository
build_file: "protobuf/kokoro/linux/php80/build.sh"
timeout_mins: 120

action {
define_artifacts {
regex: "**/sponge_log.xml"
}
}
timeout_mins: 20
8 changes: 1 addition & 7 deletions kokoro/linux/php80/presubmit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@

# Location of the build script in repository
build_file: "protobuf/kokoro/linux/php80/build.sh"
timeout_mins: 120

action {
define_artifacts {
regex: "**/sponge_log.xml"
}
}
timeout_mins: 20
27 changes: 13 additions & 14 deletions kokoro/linux/php_all/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/bin/bash
#
# This is the top-level script we give to Kokoro as the entry point for
# running the "pull request" project:
#
# This script selects a specific Dockerfile (for building a Docker image) and
# a script to run inside that image. Then we delegate to the general
# build_and_run_docker.sh script.
# This is the entry point for kicking off a Kokoro job. This path is referenced
# from the .cfg files in this directory.

set -ex

cd $(dirname $0)

# Change to repo root
cd $(dirname $0)/../../..
# Most of our tests use a debug build of PHP, but we do one build against an opt
# php just in case that surfaces anything unexpected.
../test_php.sh gcr.io/protobuf-build/php/linux:8.0.5-14a06550010c0649bf69b6c9b803c1ca609bbb6d

export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput
export TEST_SET="php_all"
./kokoro/linux/build_and_run_docker.sh
../test_php.sh gcr.io/protobuf-build/php/linux:7.0.33-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
../test_php.sh gcr.io/protobuf-build/php/linux:7.3.28-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
../test_php.sh gcr.io/protobuf-build/php/linux:7.4.18-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
../test_php.sh gcr.io/protobuf-build/php/linux:8.0.5-dbg-14a06550010c0649bf69b6c9b803c1ca609bbb6d
6 changes: 6 additions & 0 deletions kokoro/linux/test_php.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -ex

test -t 1 && USE_TTY="-it"
docker run ${USE_TTY} -v$(realpath $(dirname $0)/../..):/workspace $1 "composer test && composer test_c"
5 changes: 5 additions & 0 deletions kokoro/macos/prepare_build_macos_rc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ sudo rm -rf \
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

# This is needed to fix a conflict between the ilmbase and imath packages,
# which seem to conflict with each other by both trying to install
# libImath.dylib.
brew unlink ilmbase

brew update
brew upgrade

Expand Down
17 changes: 14 additions & 3 deletions php/generate_test_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ set -e

cd `dirname $0`

if [[ -d tmp && -z $(find tests/proto ../src/protoc -newer tmp) ]]; then
./prepare_c_extension.sh

if ../src/protoc --help > /dev/null; then
PROTOC=src/protoc
else
(cd .. && bazel build -c opt :protoc)
PROTOC=bazel-bin/protoc
fi


if [[ -d tmp && -z $(find tests/proto ../$PROTOC -newer tmp) ]]; then
# Generated protos are already present and up to date, so we can skip protoc.
#
# Protoc is very fast, but sometimes it is not available (like if we haven't
Expand All @@ -16,12 +26,13 @@ fi
rm -rf tmp
mkdir -p tmp

find tests/proto -type f -name "*.proto"| xargs ../src/protoc --php_out=tmp -I../src -Itests
cd ..
find php/tests/proto -type f -name "*.proto"| xargs $PROTOC --php_out=php/tmp -Isrc -Iphp/tests

if [ "$1" = "--aggregate_metadata" ]; then
# Overwrite some of the files to use aggregation.
AGGREGATED_FILES="tests/proto/test.proto tests/proto/test_include.proto tests/proto/test_import_descriptor_proto.proto"
../src/protoc --php_out=aggregate_metadata=foo#bar:tmp -I../src -Itests $AGGREGATED_FILES
$PROTOC --php_out=aggregate_metadata=foo#bar:php/tmp -Isrc -Iphp/tests $AGGREGATED_FILES
fi

echo "Generated test protos from tests/proto -> tmp"
18 changes: 16 additions & 2 deletions php/prepare_c_extension.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@

cd $(dirname $0)

if [[ -f ext/google/protobuf/third_party/wyhash/wyhash.h && -z $(find ../third_party/wyhash -newer ext/google/protobuf/third_party) ]]; then
# Generated protos are already present and up to date, so we can skip protoc.
#
# Protoc is very fast, but sometimes it is not available (like if we haven't
# built it in Docker). Skipping it helps us proceed in this case.
echo "wyhash is up to date, skipping."
exit 0
fi

# wyhash has to live in the base third_party directory.
# We copy it into the ext/google/protobuf directory for the build
# (and for the release to PECL).
mkdir -p ../ext/google/protobuf/third_party/wyhash
cp ../../third_party/wyhash/* ../ext/google/protobuf/third_party/wyhash
rm -rf ext/google/protobuf/third_party
mkdir -p ext/google/protobuf/third_party/wyhash
cp ../third_party/wyhash/* ext/google/protobuf/third_party/wyhash

echo "Copied wyhash from ../third_party -> ext/google/protobuf/third_party"
5 changes: 4 additions & 1 deletion php/tests/compile_extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ if [ "$1" != "--release" ]; then
CONFIGURE_OPTIONS+=("CFLAGS=-g -O0 -Wall")
fi

FINGERPRINT="$(sha256sum $(which php)) ${CONFIGURE_OPTIONS[@]}"

# If the PHP interpreter we are building against or the arguments
# have changed, we must regenerated the Makefile.
if [[ ! -f Makefile ]] || [[ "$(grep ' \$ ./configure' config.log)" != " $ ${CONFIGURE_OPTIONS[@]}" ]]; then
if [[ ! -f BUILD_STAMP ]] || [[ "$(cat BUILD_STAMP)" != "$FINGERPRINT" ]]; then
phpize --clean
rm -f configure.in configure.ac
phpize
"${CONFIGURE_OPTIONS[@]}"
echo "$FINGERPRINT" > BUILD_STAMP
fi

make
Expand Down

0 comments on commit 45e9707

Please sign in to comment.