-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a89a347
commit e8e262a
Showing
9 changed files
with
190 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
# | ||
# Builds docker image and runs a command under it. | ||
# This is a generic script that is configured with the following variables: | ||
# | ||
# DOCKERHUB_ORGANIZATION - The organization on docker hub storing the | ||
# Dockerfile. | ||
# DOCKERFILE_DIR - Directory in which Dockerfile file is located. | ||
# DOCKER_RUN_SCRIPT - Script to run under docker (relative to protobuf repo root) | ||
# OUTPUT_DIR - Directory that will be copied from inside docker after finishing. | ||
# $@ - Extra args to pass to docker run | ||
|
||
|
||
#### Work in progress ### | ||
|
||
set -ex | ||
|
||
cd $(dirname $0)/../.. | ||
GIT_REPO_ROOT=$(pwd) | ||
cd - | ||
|
||
# Use image name based on Dockerfile sha1 | ||
if [ -z "$DOCKERHUB_ORGANIZATION" ] | ||
then | ||
DOCKERHUB_ORGANIZATION=grpctesting/protobuf | ||
DOCKER_IMAGE_NAME=${DOCKERHUB_ORGANIZATION}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) | ||
else | ||
# TODO(teboring): Remove this when all tests have been migrated to separate | ||
# docker images. | ||
DOCKERFILE_PREFIX=$(basename $DOCKERFILE_DIR) | ||
DOCKER_IMAGE_NAME=${DOCKERHUB_ORGANIZATION}/${DOCKERFILE_PREFIX}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) | ||
fi | ||
CONTAINER_IMAGE=gcr.io/protobuf-build/bazel/linux@sha256:05a41edee21f620445ca01c46b9d33be2e4d06c3d8adced4341ac5abea754baa | ||
|
||
# Pull dockerimage from Dockerhub. This sometimes fails intermittently, so we | ||
# keep trying until we succeed. | ||
until docker pull $DOCKER_IMAGE_NAME; do sleep 10; done | ||
|
||
# Ensure existence of ccache directory | ||
CCACHE_DIR=/tmp/protobuf-ccache | ||
mkdir -p $CCACHE_DIR | ||
|
||
# Choose random name for docker container | ||
CONTAINER_NAME="build_and_run_docker_$(uuidgen)" | ||
|
||
echo $git_root | ||
|
||
# Run command inside docker | ||
docker run \ | ||
"$@" \ | ||
-e CCACHE_DIR=$CCACHE_DIR \ | ||
-e KOKORO_BUILD_NUMBER=$KOKORO_BUILD_NUMBER \ | ||
-e KOKORO_BUILD_ID=$KOKORO_BUILD_ID \ | ||
-e EXTERNAL_GIT_ROOT="/var/local/kokoro/protobuf" \ | ||
-e TEST_SET="$TEST_SET" \ | ||
-v "$git_root:/var/local/kokoro/protobuf:ro" \ | ||
-v $CCACHE_DIR:$CCACHE_DIR \ | ||
-w /var/local/git/protobuf \ | ||
--name=$CONTAINER_NAME \ | ||
$DOCKER_IMAGE_NAME \ | ||
bash -l "/var/local/kokoro/protobuf/$DOCKER_RUN_SCRIPT" || FAILED="true" | ||
|
||
# remove the container, possibly killing it first | ||
docker rm -f $CONTAINER_NAME || true | ||
|
||
[ -z "$FAILED" ] || { | ||
exit 1 | ||
} | ||
|
||
CONTAINER_IMAGE=gcr.io/protobuf-build/bazel/linux@sha256:05a41edee21f620445ca01c46b9d33be2e4d06c3d8adced4341ac5abea754baa | ||
|
||
if [[ -z "${PLATFORM}" ]]; then | ||
PLATFORM_CONFIG="" | ||
else | ||
PLATFORM_CONFIG="--config=${PLATFORM}" | ||
fi | ||
|
||
if $DEBUG_MODE; then | ||
DEBUG_FLAG="-s" | ||
else | ||
DEBUG_FLAG="" | ||
fi | ||
|
||
# Fetch external deps w/ network access enabled. | ||
docker run \ | ||
-v $GIT_REPO_ROOT:/workspace \ | ||
$CONTAINER_IMAGE \ | ||
build --nobuild --config=cross_config $BAZEL_TARGETS | ||
|
||
# Execute the requested command against the requested targets in a | ||
# fully offline context. | ||
docker run \ | ||
--network none \ | ||
-v $GIT_REPO_ROOT:/workspace \ | ||
$CONTAINER_IMAGE \ | ||
$BAZEL_COMMAND \ | ||
$DEBUG_FLAG \ | ||
$PLATFORM_CONFIG \ | ||
$BAZEL_TARGETS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#!/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. | ||
# Build file to set up and run tests | ||
|
||
set -eu | ||
|
||
# Install Bazel 4.0.0. | ||
use_bazel.sh 4.0.0 | ||
bazel version | ||
|
||
# Change to repo root | ||
cd $(dirname $0)/../../.. | ||
|
||
export DOCKERHUB_ORGANIZATION=protobuftesting | ||
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/csharp | ||
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh | ||
export OUTPUT_DIR=testoutput | ||
export TEST_SET="csharp" | ||
./kokoro/linux/build_and_run_docker.sh | ||
# Get kokoro scripts from repo root by default. | ||
: ${SCRIPT_ROOT:=$(pwd)} | ||
source ${SCRIPT_ROOT}/kokoro/common/pyenv.sh | ||
|
||
./tests.sh csharp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Common config shared by presubmit and continuous. | ||
|
||
bazel_setting: { | ||
project_id: "protobuf-build" | ||
bes_backend_address: "buildeventservice.googleapis.com" | ||
foundry_backend_address: "remotebuildexecution.googleapis.com" | ||
upsalite_frontend_address: "https://source.cloud.google.com" | ||
local_execution: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#!/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. | ||
# Build file to set up and run tests | ||
|
||
set -eu | ||
|
||
# Install Bazel 4.0.0. | ||
use_bazel.sh 4.0.0 | ||
bazel version | ||
|
||
# Change to repo root | ||
cd $(dirname $0)/../../.. | ||
|
||
export DOCKERHUB_ORGANIZATION=protobuftesting | ||
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/python310 | ||
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh | ||
export OUTPUT_DIR=testoutput | ||
export TEST_SET="python310" | ||
./kokoro/linux/build_and_run_docker.sh | ||
# Get kokoro scripts from repo root by default. | ||
: ${SCRIPT_ROOT:=$(pwd)} | ||
source ${SCRIPT_ROOT}/kokoro/common/pyenv.sh | ||
|
||
./tests.sh python310 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Common config shared by presubmit and continuous. | ||
|
||
bazel_setting: { | ||
project_id: "protobuf-build" | ||
bes_backend_address: "buildeventservice.googleapis.com" | ||
foundry_backend_address: "remotebuildexecution.googleapis.com" | ||
upsalite_frontend_address: "https://source.cloud.google.com" | ||
local_execution: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#!/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. | ||
# Build file to set up and run tests | ||
|
||
set -eu | ||
|
||
# Install Bazel 4.0.0. | ||
use_bazel.sh 4.0.0 | ||
bazel version | ||
|
||
# Change to repo root | ||
cd $(dirname $0)/../../.. | ||
|
||
export DOCKERHUB_ORGANIZATION=protobuftesting | ||
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/python310 | ||
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh | ||
export OUTPUT_DIR=testoutput | ||
export TEST_SET="python310_cpp" | ||
./kokoro/linux/build_and_run_docker.sh | ||
# Get kokoro scripts from repo root by default. | ||
: ${SCRIPT_ROOT:=$(pwd)} | ||
source ${SCRIPT_ROOT}/kokoro/common/pyenv.sh | ||
|
||
./tests.sh python310_cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Common config shared by presubmit and continuous. | ||
|
||
bazel_setting: { | ||
project_id: "protobuf-build" | ||
bes_backend_address: "buildeventservice.googleapis.com" | ||
foundry_backend_address: "remotebuildexecution.googleapis.com" | ||
upsalite_frontend_address: "https://source.cloud.google.com" | ||
local_execution: true | ||
} |