Skip to content

Commit

Permalink
Add a build test to bazel-common to ensure that all of the libraries …
Browse files Browse the repository at this point in the history
…build correctly

This doesn't ensure that all dependencies are satisfied correctly, but at least it ensures that the build files are properly formatted and sha256s are valid. We've already had a number of CLs that have failed one of these two invariants :-/

Also add a missing dep for the @autofactory processor. I guess these do some validation, inasmuch as the AutoFactoryProcessor required FormattingFiler from google-java-format in it's initialization step, which runs on java compilations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=250682287
  • Loading branch information
ronshapiro committed May 30, 2019
1 parent 2601165 commit 3413f4d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
language: android

os: linux
dist: trusty
sudo: required
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++-4.9-dev # https://github.com/nodegit/nodegit/issues/853
- gcc-4.8
- g++-4.8

android:
components:
- tools
- tools # Duplicated as per https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943
- build-tools-26.0.2
- android-26
- platform-tools
- extra-android-m2repository

before_install:
- wget https://github.com/bazelbuild/bazel/releases/download/"${BAZEL_VERSION}"/bazel_"${BAZEL_VERSION}"-linux-x86_64.deb
- sudo dpkg -i bazel_"${BAZEL_VERSION}"-linux-x86_64.deb
- sudo rm -f /etc/mavenrc
- wget http://www.us.apache.org/dist/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
- tar -zxf apache-maven-3.1.1-bin.tar.gz
- export PATH="$PWD/apache-maven-3.1.1/bin:$PATH"
- mkdir travis_bin
- ln -s $(which gcc-4.8) travis_bin/gcc
- ln -s $(which g++-4.8) travis_bin/g++
- export PATH="${PWD}/travis_bin:${PATH}"

script: ./build_test.sh

env:
global:
- BAZEL_VERSION="0.24.1"

branches:
only:
- master
- /^release.*$/
36 changes: 36 additions & 0 deletions build_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Tests that all libraries in bazel-common can build correctly

libraries=""
for library in $(bazel query --output=label_kind //... | \
grep -v "//tools/maven:" | \
grep _library | \
awk '{print $3}'); do
if [[ -z "${libraries}" ]]; then
libraries=" \"${library}\","
else
printf -v libraries '%s\n "%s",' "${libraries}" "${library}"
fi
done

readonly DIR=build_test

mkdir "${DIR}"

cat <<BUILD_TEST >> "${DIR}"/BUILD
java_library(
name = "build_test",
srcs = ["BuildTest.java"],
deps = [
${libraries}
],
testonly = 1,
)
BUILD_TEST

echo "class BuildTest {}" > "${DIR}"/BuildTest.java

trap "rm -rf ${DIR}/" EXIT

bazel build //build_test
1 change: 1 addition & 0 deletions third_party/java/auto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ java_plugin(
deps = [
":common",
":service",
"//third_party/java/google_java_format",
"//third_party/java/guava",
"//third_party/java/javapoet",
"@com_google_auto_factory_auto_factory//jar",
Expand Down

0 comments on commit 3413f4d

Please sign in to comment.