Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bazel job in Travis #395

Merged
merged 16 commits into from
Sep 30, 2018
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .travis.bazelrc
Original file line number Diff line number Diff line change
@@ -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

23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions jflex/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion jflex/examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build
antbuild
target
out
24 changes: 24 additions & 0 deletions jflex/examples/BUILD
Original file line number Diff line number Diff line change
@@ -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\"' > $@",
)
1 change: 1 addition & 0 deletions jflex/examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions scripts/bazel.sh
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"