From 8796f2c7ef38f24d55b55d5eb85cc354d157a5ff Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 20 Jun 2016 10:47:11 -0700 Subject: [PATCH] add travis CI Summary: Add a Travis file that builds Infer via opam. Will add docker soon. Reviewed By: cristianoc Differential Revision: D3444060 fbshipit-source-id: 11432da --- .travis.yml | 26 ++++++++++++++++++++++++++ .travis/docker_tests.sh | 28 ++++++++++++++++++++++++++++ .travis/local_install_tests.sh | 18 ++++++++++++++++++ README.md | 2 +- infer/src/Makefile | 4 ++-- opam | 1 + 6 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 .travis.yml create mode 100644 .travis/docker_tests.sh create mode 100644 .travis/local_install_tests.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..3993e5c7a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +sudo: required +language: c +os: + - linux + - osx +services: docker +osx_image: xcode7.3 +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install opam; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam init; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam switch 4.02.3; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then eval `opam config env`; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam install -y depext; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam pin add -y merlin 'https://github.com/the-lambda-church/merlin.git#reason-0.0.1'; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam pin add -y merlin_extend 'https://github.com/let-def/merlin-extend.git#reason-0.0.1'; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam pin add -y --no-action reason 'https://github.com/facebook/reason.git#0.0.6'; fi +install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam pin add -y --no-action infer .; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam depext infer; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then opam install -y infer; fi +script: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/local_install_tests.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/docker_tests.sh; fi + - git diff --exit-code diff --git a/.travis/docker_tests.sh b/.travis/docker_tests.sh new file mode 100644 index 000000000..cc791542b --- /dev/null +++ b/.travis/docker_tests.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright (c) 2016 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# assumes we are in .travis/ +cd "${SCRIPT_DIR}/../docker" + +docker build -t infer . + +echo 'Running `infer -- javac /infer/examples/Hello.java`' +docker run -t infer \ + /bin/bash -c \ + 'infer -- javac /infer/examples/Hello.java | grep -q "NULL_DEREFERENCE: *1"' +echo + +echo 'Running `infer -- clang -c /infer/examples/hello.c`' +docker run -t infer \ + /bin/bash -c \ + 'infer -- clang -c /infer/examples/hello.c | grep -q "NULL_DEREFERENCE: *1"' +echo diff --git a/.travis/local_install_tests.sh b/.travis/local_install_tests.sh new file mode 100644 index 000000000..be9f01dc3 --- /dev/null +++ b/.travis/local_install_tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Copyright (c) 2016 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# go to the root of the repo -- assumes we are in .travis/ +cd "${SCRIPT_DIR}/.." + +echo 'Running `infer -- javac examples/Hello.java`' +infer -- javac examples/Hello.java | grep -q 'NULL_DEREFERENCE: *1' +echo diff --git a/README.md b/README.md index 8f6febf77..a0ef2866c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Infer +# Infer [![Build Status](https://travis-ci.org/facebook/infer.svg?branch=master)](https://travis-ci.org/facebook/infer) [Infer](http://fbinfer.com/) is a static analysis tool for Java, Objective-C and C, written in [OCaml](https://ocaml.org/). diff --git a/infer/src/Makefile b/infer/src/Makefile index fcfc5db48..1292001f9 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -164,7 +164,7 @@ endif all: infer -infer: init $(INFERPRINT_ATDGEN_STUBS) $(CLANG_BINIOU_DICT) +infer: init $(INFERPRINT_ATDGEN_STUBS) $(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) $(INFER_CONFIG_TARGETS) $(COPY) $(INFER_BUILD_DIR)/$(INFERANALYZE_MAIN).native $(INFERANALYZE_BIN) $(COPY) $(INFER_BUILD_DIR)/$(INFERPRINT_MAIN).native $(INFERPRINT_BIN) @@ -185,7 +185,7 @@ ifeq ($(ENABLE_OCAML_ANNOT),yes) endif ifeq ($(BUILD_C_ANALYZERS),yes) -infer: $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) +infer: $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) $(CLANG_BINIOU_DICT) endif ifeq ($(BUILD_LLVM_ANALYZERS),yes) infer: $(LLVM_SOURCES)/lLexer.ml $(LLVM_SOURCES)/lParser.ml diff --git a/opam b/opam index 0274a1de9..f1ba1d5ef 100644 --- a/opam +++ b/opam @@ -33,6 +33,7 @@ depends: [ "javalib" {>="2.3.1"} "extlib" {>="1.5.4"} "ounit" {>="2.0.0"} + "reason" {>="0.0.5"} ] depexts: [ [ ["ubuntu"] ["python2.7-dev"] ]