diff --git a/.travis.bazelrc b/.travis.bazelrc new file mode 100644 index 000000000..a34c9f070 --- /dev/null +++ b/.travis.bazelrc @@ -0,0 +1,9 @@ +# This is from Bazel's former travis setup, to avoid blowing up the RAM usage. +startup --host_jvm_args=-Xms2000m +startup --host_jvm_args=-Xmx3000m +test --ram_utilization_factor=10 + +# This is so we understand failures better +build --verbose_failures +test --test_output=errors + diff --git a/.travis.yml b/.travis.yml index e0516ab51..e20d41408 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,29 @@ matrix: sdk: oraclejdk8 - name: "Ant JDK9" script: scripts/run-ant.sh + - name: "Bazel" + script: scripts/bazel.sh + # Prerequisites for Bazel + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - curl + - pkg-config + - zip + - g++ + - zlib1g-dev + - unzip + - python + before_install: + - mkdir -p tools + - curl -L https://github.com/bazelbuild/bazel/releases/download/0.16.1/bazel_0.16.1-linux-x86_64.deb -o tools/bazel-0.16.1.deb + install: + - java -version + - sudo apt-get install ./tools/bazel-0.16.1.deb + sudo: true + after_success: blaze shutdown # Empty the previously built artifacts # They cannot be deleted in the before_cache phase, diff --git a/jflex/.gitignore b/jflex/.gitignore deleted file mode 100644 index c3ebe0a51..000000000 --- a/jflex/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by ant -build - diff --git a/jflex/examples/.gitignore b/jflex/examples/.gitignore index 298e948b2..e8851ff06 100644 --- a/jflex/examples/.gitignore +++ b/jflex/examples/.gitignore @@ -1,3 +1,3 @@ -build +antbuild target out diff --git a/jflex/examples/BUILD b/jflex/examples/BUILD new file mode 100644 index 000000000..bddad4a25 --- /dev/null +++ b/jflex/examples/BUILD @@ -0,0 +1,24 @@ +# Root bazel package + +# This pacakge exists because +# `bazel build //...` needs at least one package + +# But bazel test //... fails with +# No test targets were found, yet testing was requested +# So here is a test: + +sh_test( + name = "hello_test", + size = "small", + srcs = [":hello_test_lib"], +) +sh_library( + name = "hello_test_lib", + srcs = [":gen_hello_test_sh"], +) +genrule( + name = "gen_hello_test_sh", + srcs = [], + outs = ["hello_test.sh"], + cmd = "echo 'echo \"Hello World\"' > $@", +) diff --git a/jflex/examples/WORKSPACE b/jflex/examples/WORKSPACE new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/jflex/examples/WORKSPACE @@ -0,0 +1 @@ + diff --git a/scripts/bazel.sh b/scripts/bazel.sh new file mode 100755 index 000000000..bd11ba2b5 --- /dev/null +++ b/scripts/bazel.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Run bazel on examples + +CWD="$PWD" +BASEDIR="$(cd "$(dirname "$0")" && pwd -P)"/.. +# Provides the logi function +source "$BASEDIR"/scripts/logger.sh +# fail on error +set -e + +if [[ $TRAVIS ]]; then + BAZEL="bazel --bazelrc=$TRAVIS_BUILD_DIR/.travis.bazelrc" +else + BAZEL='bazel' +fi + +logi "Start Bazel" +logi "===========" +cd jflex/examples +$BAZEL info + +logi "Build everything" +logi "================" +$BAZEL build //... + +logi "Test everything" +logi "===============" +$BAZEL test //... + +cd "$CWD" diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index b19a56872..94c5ebf82 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -31,6 +31,9 @@ if [[ -z "$TEST_SUITE" || "$TEST_SUITE" == "ant" ]]; then "$BASEDIR"/scripts/ant-build.sh "$BASEDIR"/scripts/test-examples.sh fi +if [[ -z "$TEST_SUITE" || "$TEST_SUITE" == "bazel" ]]; then + "$BASEDIR"/scripts/bazel.sh +fi logi "Success" cd "$CWD"