<commit_before>#!/bin/bash

set -exu -o pipefail
cat /VERSION

BASE_DIR="$(pwd)"

# Install gRPC and codegen for the Android examples
# (a composite gradle build can't find protoc-gen-grpc-java)

cd "$BASE_DIR/github/grpc-java"

export LDFLAGS=-L/tmp/protobuf/lib
export CXXFLAGS=-I/tmp/protobuf/include
export LD_LIBRARY_PATH=/tmp/protobuf/lib
export OS_NAME=$(uname)

cat <<EOF >> gradle.properties
# defaults to -Xmx512m -XX:MaxMetaspaceSize=256m
# https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory
# Increased due to java.lang.OutOfMemoryError: Metaspace failures
org.gradle.jvmargs=-Xmx512m -XX:MaxMetaspaceSize=512m
EOF

echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"

# Proto deps
buildscripts/make_dependencies.sh

# Build grpc-cronet

pushd cronet
../gradlew build
popd

# Build grpc-android

pushd android
../gradlew build
popd

# Build android-interop-testing
pushd android-interop-testing
../gradlew build
popd

# Examples pull dependencies from maven local
./gradlew publishToMavenLocal

# Build examples

cd ./examples/android/clientcache
../../gradlew build
cd ../routeguide
../../gradlew build
cd ../helloworld
../../gradlew build

# Skip APK size and dex count comparisons for non-PR builds

if [[ -z "${KOKORO_GITHUB_PULL_REQUEST_COMMIT:-}" ]]; then
    echo "Skipping APK size and dex count"
    exit 0
fi

# Save a copy of set_github_status.py (it may differ from the base commit)<commit_msg>buildscripts: Check for out-of-date codegen after android builds<commit_after>#!/bin/bash

set -exu -o pipefail
cat /VERSION

BASE_DIR="$(pwd)"

# Install gRPC and codegen for the Android examples
# (a composite gradle build can't find protoc-gen-grpc-java)

cd "$BASE_DIR/github/grpc-java"

export LDFLAGS=-L/tmp/protobuf/lib
export CXXFLAGS=-I/tmp/protobuf/include
export LD_LIBRARY_PATH=/tmp/protobuf/lib
export OS_NAME=$(uname)

cat <<EOF >> gradle.properties
# defaults to -Xmx512m -XX:MaxMetaspaceSize=256m
# https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory
# Increased due to java.lang.OutOfMemoryError: Metaspace failures
org.gradle.jvmargs=-Xmx512m -XX:MaxMetaspaceSize=512m
EOF

echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"

# Proto deps
buildscripts/make_dependencies.sh

# Build grpc-cronet

pushd cronet
../gradlew build
popd

# Build grpc-android

pushd android
../gradlew build
popd

# Build android-interop-testing
pushd android-interop-testing
../gradlew build
popd

# Examples pull dependencies from maven local
./gradlew publishToMavenLocal

if [[ ! -z $(git status --porcelain) ]]; then
  git status
  echo "Error Working directory is not clean. Forget to commit generated files?"
  exit 1
fi

# Build examples

cd ./examples/android/clientcache
../../gradlew build
cd ../routeguide
../../gradlew build
cd ../helloworld
../../gradlew build

# Skip APK size and dex count comparisons for non-PR builds

if [[ -z "${KOKORO_GITHUB_PULL_REQUEST_COMMIT:-}" ]]; then
    echo "Skipping APK size and dex count"
    exit 0
fi

# Save a copy of set_github_status.py (it may differ from the base commit)
{'fraction_non_alphanumeric': 0.11262690355329949, 'fraction_numerical': 0.011104060913705584, 'mean_word_length': 4.28140703517588, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4913615', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1067, 'n_words': 301}