Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion third_party/googleapis/.bazeliskrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# See https://github.com/bazelbuild/bazelisk
USE_BAZEL_VERSION=4.0.0
USE_BAZEL_VERSION=4.2.2
3 changes: 3 additions & 0 deletions third_party/googleapis/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# To make proto_library rules to include source info in the descriptor
build --protocopt=--include_source_info
build --protocopt=--experimental_allow_proto3_optional
# New boringssl requires C++14
build --repo_env=BAZEL_CXXOPTS="-std=c++14"


# This is to avoid JVM SIGBUS crashes on highly parallel builds,
# see https://github.com/bazelbuild/bazel/issues/3236 for more details
Expand Down
1 change: 1 addition & 0 deletions third_party/googleapis/.github/mistaken-pull-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
filters:
# Don't close PRs in the pubsub_dev branch.
- '@.pull_request.base.ref != "pubsub_dev"'
- '@.pull_request.base.ref != "diregapic"'

# The message to post to the closed PR.
commentBody: |
Expand Down
50 changes: 50 additions & 0 deletions third_party/googleapis/.github/workflows/diregapic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: DIREGAPIC Updater
on: # yamllint disable-line rule:truthy
schedule:
- cron: '19 */8 * * *'
workflow_dispatch:

jobs:
regenerate-compute:
runs-on: ubuntu-latest
container: gcr.io/gapic-images/googleapis:20220711
steps:
- name: Checkout master
uses: actions/checkout@v3
with:
ref: master
- name: Download discovery docs
run: |
curl https://www.googleapis.com/discovery/v1/apis/compute/v1/rest --output google/cloud/compute/v1/compute.v1.json
echo compute_revision=$(grep -oP '"revision":\s*"\d+"' google/cloud/compute/v1/compute.v1.json | grep -oP '\d+') >> $GITHUB_ENV
- name: Regenerate API definitions
run: |
bazel build //google/cloud/compute/v1:compute_gen
cp bazel-bin/google/cloud/compute/v1/compute_gen.proto google/cloud/compute/v1/compute.proto
bazel build //google/cloud/compute/v1:compute_grpc_service_config_gen
cp bazel-bin/google/cloud/compute/v1/compute_grpc_service_config_gen.json google/cloud/compute/v1/compute_grpc_service_config.json
bazel build //google/cloud/compute/v1:compute_gapic_gen
cp bazel-bin/google/cloud/compute/v1/compute_gapic_gen.yaml google/cloud/compute/v1/compute_gapic.yaml
echo api_changes=$(git diff-index --shortstat HEAD) >> $GITHUB_ENV
- name: Build GAPIC clients
if: contains(env.api_changes, 'file')
run: |
bazel build //google/cloud/compute/v1/...
bazel build //google/cloud/compute/v1/...
- name: Create PR
uses: googleapis/code-suggester@v2
env:
ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
with:
command: pr
upstream_owner: googleapis
upstream_repo: googleapis
title: 'feat: [DIREGAPIC] Update API definitions'
description: 'feat: Update Compute Engine API to revision ${{ env.compute_revision }}'
message: 'feat: Update Compute Engine API to revision ${{ env.compute_revision }}'
primary: 'master'
branch: diregapic
git_dir: '.'
force: true
fork: true
6 changes: 3 additions & 3 deletions third_party/googleapis/.kokoro/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.10

RUN apt-get update

Expand All @@ -11,9 +11,9 @@ RUN apt-get install -y \

RUN mkdir -p /tools
WORKDIR /tools
RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.8.0/bazelisk-linux-amd64 -o bazelisk
RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.12.0/bazelisk-linux-amd64 -o bazelisk
RUN chmod +x bazelisk
RUN curl -L https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-linux-x86_64 -o bazel
RUN curl -L https://github.com/bazelbuild/bazel/releases/download/5.2.0/bazel-5.2.0-linux-x86_64 -o bazel
RUN chmod +x bazel
WORKDIR /

Expand Down
6 changes: 4 additions & 2 deletions third_party/googleapis/.kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ set -e

cd ${KOKORO_ARTIFACTS_DIR}/github/googleapis
cp .kokoro/.bazelrc $HOME/.bazelrc
CACHE_BUCKET=client-libraries-bazel-cache-github
CACHE_CMDLINE="--remote_cache=https://storage.googleapis.com/${CACHE_BUCKET} --google_default_credentials"

#
# Run build and tests
#
${BAZELISK_BIN} --output_user_root=${BAZEL_ROOT} build --keep_going //...
${BAZELISK_BIN} --output_user_root=${BAZEL_ROOT} test --flaky_test_attempts=3 --keep_going //...
${BAZELISK_BIN} --output_user_root=${BAZEL_ROOT} build ${CACHE_CMDLINE} --keep_going //...
${BAZELISK_BIN} --output_user_root=${BAZEL_ROOT} test ${CACHE_CMDLINE} --flaky_test_attempts=3 --keep_going //...
134 changes: 134 additions & 0 deletions third_party/googleapis/.kokoro/docker_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/sh

# This script will build a Docker image for googleapis and recompile
# PHP and Ruby runtimes binaries to use in GAPIC generators for these
# languages.
#
# Run from any local working directory where you have write access.
#
# Usage:
# $ mkdir workdir
# $ cd workdir
# $ sh /google/src/head/depot/google3/third_party/googleapis/stable/.kokoro/docker_update.sh
#
# After the script completes, it should print out commands to push the new
# Docker image and to create pull requests against Ruby and PHP generators.
# Whenever the image is published, tag it here:
# https://pantheon.corp.google.com/gcr/images/gapic-images/global/googleapis?project=gapic-images
# then release new versions of the generators and update the image tag in
# start.sh scripts in Kokoro folders in all googleapis workspaces.

set -e

PWD="`pwd`"
SHARED="$PWD/volume"
SCRIPT=$0
DIRNAME=`dirname $SCRIPT`

if test -d "$SHARED"; then
echo "The working directory $SHARED already exists, please delete it first."
exit 1
fi
mkdir -p "$SHARED"

# 1. Build the latest Docker image using the Dockerfile from google3

echo "Using Dockerfile from $DIRNAME"
cat "$DIRNAME/Dockerfile" > "$PWD/Dockerfile"

echo "Building googleapis Docker image..."
docker build -t googleapis .
docker tag googleapis gcr.io/gapic-images/googleapis
echo "Done."

# 2. Clone Ruby and PHP generators
cd "$SHARED"
echo "Cloning Ruby generator..."
git clone --depth 1 git@github.com:googleapis/gapic-generator-ruby.git
echo "Done."
echo "Cloning PHP generator..."
git clone --depth 1 git@github.com:googleapis/gapic-generator-php.git
echo "Done."

# 3. Generate a script that would run Bazel to build both generators
cat > build.sh <<EOD
#!/bin/sh
set -e
export USER="$USER"
export HOME=/volume
cd /volume
cd gapic-generator-ruby
bazel build //rules_ruby_gapic/gapic-generator:gapic_generator_bundled_context
cd /volume
cd gapic-generator-php
bazel build //rules_php_gapic:php_gapic_generator_binary
cd ..
EOD
chmod +x build.sh

# 4. Execute the script inside Docker image
echo "Building generators inside Docker..."
# Note: without --privileged, the container has problems accessing the filesystem.
# We don't care much about it at this moment. Discussed here:
# https://forums.docker.com/t/what-capabilities-are-required-for-ls/92223
DOCKER_COMMAND="docker run --privileged --user=$UID --workdir=/volume -i --rm -v $SHARED:/volume"
$DOCKER_COMMAND --entrypoint /volume/build.sh googleapis
echo "Done."

# Fix permissions of the mounted folder
chmod -R u+w "$SHARED"

# 5. Pack the resulting Ruby and PHP binaries
RUBY_DIRECTORY=`ls -d .cache/bazel/*/*/external/gapic_generator_ruby_runtime`
RUBY_VERSION=`echo 'puts RUBY_VERSION' | $DOCKER_COMMAND --entrypoint "" googleapis /volume/$RUBY_DIRECTORY/bin/ruby`

echo "Ruby version: $RUBY_VERSION, packing..."
RUBY_ARCHIVE_DIR="ruby-$RUBY_VERSION"
RUBY_TARBALL_FILENAME="ruby-${RUBY_VERSION}_glinux_x86_64.tar.gz"
mkdir -p "$RUBY_ARCHIVE_DIR"
cp -r "$RUBY_DIRECTORY"/bin "$RUBY_DIRECTORY"/include "$RUBY_DIRECTORY"/lib "$RUBY_ARCHIVE_DIR"
tar cfz "$RUBY_TARBALL_FILENAME" "$RUBY_ARCHIVE_DIR"
echo "Done: $RUBY_TARBALL_FILENAME"

PHP_DIRECTORY=`ls -d .cache/bazel/*/*/external/php_micro`
PHP_VERSION=`echo '<? echo phpversion(); ?>' | $DOCKER_COMMAND --entrypoint "" googleapis /volume/$PHP_DIRECTORY/bin/php`

echo "PHP version: $PHP_VERSION, packing..."
PHP_ARCHIVE_DIR="php-$PHP_VERSION"
PHP_TARBALL_FILENAME="php-${PHP_VERSION}_linux_x86_64.tar.gz"
mkdir -p "$PHP_ARCHIVE_DIR"
cp -r "$PHP_DIRECTORY"/bin "$PHP_DIRECTORY"/include "$PHP_DIRECTORY"/lib "$PHP_ARCHIVE_DIR"
tar cfz "$PHP_TARBALL_FILENAME" "$PHP_ARCHIVE_DIR"
echo "Done: $PHP_TARBALL_FILENAME"

# 6. Commit the tarballs
BRANCH="update-binary-`date +%Y%m%dT%H%M%S`"

RUBY_TARBALL_LOCATION=rules_ruby_gapic/prebuilt
cd "$SHARED/gapic-generator-ruby"
git checkout -b "$BRANCH"
git rm -f "$RUBY_TARBALL_LOCATION"/*.tar.gz
cp "$SHARED/$RUBY_TARBALL_FILENAME" "$RUBY_TARBALL_LOCATION/"
git add "$RUBY_TARBALL_LOCATION/$RUBY_TARBALL_FILENAME"
git commit -m "fix: update Ruby prebuilt binary, version $RUBY_VERSION"
echo "Pushing Ruby branch to GitHub..."
git push --set-upstream origin "$BRANCH"
echo "Done"

PHP_TARBALL_LOCATION=rules_php_gapic/resources
cd "$SHARED/gapic-generator-php"
git checkout -b "$BRANCH"
git rm -f "$PHP_TARBALL_LOCATION"/*.tar.gz
cp "$SHARED/$PHP_TARBALL_FILENAME" "$PHP_TARBALL_LOCATION/"
git add "$PHP_TARBALL_LOCATION/$PHP_TARBALL_FILENAME"
git commit -m "fix: update PHP prebuilt binary, version $PHP_VERSION"
echo "Pushing PHP branch to GitHub..."
git push --set-upstream origin "$BRANCH"
echo "Done"

echo
echo "Please create pull requests:"
echo " https://github.com/googleapis/gapic-generator-ruby/pull/new/$BRANCH"
echo " https://github.com/googleapis/gapic-generator-php/pull/new/$BRANCH"
echo "and push this Docker image to gcr.io:"
echo " docker push gcr.io/gapic-images/googleapis"
2 changes: 1 addition & 1 deletion third_party/googleapis/.kokoro/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ docker container run \
--workdir ${KOKORO_ROOT} \
--ipc=host \
--entrypoint ${KOKORO_ARTIFACTS_DIR}/github/googleapis/.kokoro/build.sh \
gcr.io/gapic-images/googleapis:20210423
gcr.io/gapic-images/googleapis:20220711
3 changes: 1 addition & 2 deletions third_party/googleapis/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

alias(
name = "build_gen",
actual = "@rules_gapic//bazel:build_file_generator",
)

2 changes: 1 addition & 1 deletion third_party/googleapis/PACKAGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Auto-Generated Packages for Google Cloud Platform

This indexes the gRPC and GAPIC packages delivered to the the [Google Cloud
This indexes the gRPC and GAPIC packages delivered to the [Google Cloud
Platform](https://github.com/GoogleCloudPlatform) teams and where they can be
found. Currently, package delivery is only being done for Python.

Expand Down
2 changes: 1 addition & 1 deletion third_party/googleapis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ libraries, documentation, and other artifacts.
### Bazel

The recommended way to build the API client libraries is through
[Bazel](https://bazel.build/) >= 2.0.0.
[Bazel](https://bazel.build/) >= 4.2.2.

First, [install bazel](https://docs.bazel.build/versions/master/install.html).

Expand Down
Loading