|
|
|
name: Install
|
|
|
|
|
|
|
|
on:
|
|
|
|
- push
|
|
|
|
- pull_request
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- macOS-latest
|
|
|
|
- ubuntu-latest
|
|
|
|
ocaml-version:
|
|
|
|
- 4.11.1
|
|
|
|
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Install Required Apt Packages for Ubuntu
|
|
|
|
run: |
|
|
|
|
sudo apt install libmpfr-dev libsqlite3-dev ninja-build
|
|
|
|
sudo apt clean
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
|
|
|
|
- name: Install Required Brew Packages for MacOS
|
|
|
|
run: brew install automake jq ninja pkg-config
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
|
|
|
|
- name: Compute hash of clang installation
|
|
|
|
id: clang-hash
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=value::$(./facebook-clang-plugins/clang/setup.sh --clang-hash)"
|
|
|
|
|
|
|
|
- name: Attempt to get clang from the cache
|
|
|
|
id: cache-clang
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: facebook-clang-plugins/clang/install
|
|
|
|
key: clang-${{ runner.os }}-${{ steps.clang-hash.outputs.value }}
|
|
|
|
|
|
|
|
- name: Record that the clang cache was hit
|
|
|
|
if: steps.cache-clang.outputs.cache-hit == 'true'
|
|
|
|
run: ./facebook-clang-plugins/clang/setup.sh --only-record-install
|
|
|
|
|
|
|
|
- name: Build clang on cache misses
|
|
|
|
if: steps.cache-clang.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
./facebook-clang-plugins/clang/src/prepare_clang_src.sh
|
|
|
|
./facebook-clang-plugins/clang/setup.sh --ninja --sequential-link
|
|
|
|
|
|
|
|
- name: Attempt to get opam tree from the cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.opam
|
|
|
|
key: opam-${{ runner.os }}-${{ hashFiles('opam.locked') }}
|
|
|
|
|
|
|
|
- name: Use OCaml ${{ matrix.ocaml-version }}
|
|
|
|
uses: avsm/setup-ocaml@v1
|
|
|
|
with:
|
|
|
|
ocaml-version: ${{ matrix.ocaml-version }}
|
|
|
|
|
|
|
|
- run: ./build-infer.sh --yes all
|
|
|
|
|
|
|
|
- run: make install
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
|
|
|
|
- run: sudo make install
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
|
|
|
|
- name: Test infer
|
|
|
|
run: |
|
|
|
|
eval $(opam env)
|
|
|
|
|
|
|
|
{
|
|
|
|
echo 'class FailingTest {'
|
|
|
|
echo ' String mayReturnNull(int i) {'
|
|
|
|
echo ' if (i > 0) {'
|
|
|
|
echo ' return "Hello, Infer!";'
|
|
|
|
echo ' }'
|
|
|
|
echo ' return null;'
|
|
|
|
echo ' }'
|
|
|
|
echo ' int mayCauseNPE() {'
|
|
|
|
echo ' String s = mayReturnNull(0);'
|
|
|
|
echo ' return s.length();'
|
|
|
|
echo ' }'
|
|
|
|
echo '}'
|
|
|
|
} > FailingTest.java
|
|
|
|
|
|
|
|
{
|
|
|
|
echo " class PassingTest {"
|
|
|
|
echo " String mayReturnNull(int i) {"
|
|
|
|
echo " if (i > 0) {"
|
|
|
|
echo ' return "Hello, Infer!";'
|
|
|
|
echo " }"
|
|
|
|
echo " return null;"
|
|
|
|
echo " }"
|
|
|
|
echo " int mayCauseNPE() {"
|
|
|
|
echo " String s = mayReturnNull(0);"
|
|
|
|
echo " return s == null ? 0 : s.length();"
|
|
|
|
echo " }"
|
|
|
|
echo " }"
|
|
|
|
} > PassingTest.java
|
|
|
|
|
|
|
|
# first command should exit with status 2
|
|
|
|
infer --fail-on-issue -P -- javac FailingTest.java || if [[ $? -ne 2 ]]; then exit 1; fi
|
|
|
|
infer --fail-on-issue -P -- javac PassingTest.java
|
|
|
|
|
|
|
|
{
|
|
|
|
echo "#include <stdio.h>"
|
|
|
|
echo "int main()"
|
|
|
|
echo "{ int *s = NULL; *s = 42; return 0; } "
|
|
|
|
} > FailingTest.c
|
|
|
|
|
|
|
|
{
|
|
|
|
echo "#include <stdio.h>"
|
|
|
|
echo "int main()"
|
|
|
|
echo "{ int *s = NULL; if (s != NULL) { *s = 42; } return 0; }"
|
|
|
|
} > PassingTest.c
|
|
|
|
|
|
|
|
# first command should exit with status 2
|
|
|
|
infer --fail-on-issue -P -- clang -c FailingTest.c || if [[ $? -ne 2 ]]; then exit 1; fi
|
|
|
|
infer --fail-on-issue -P -- clang -c PassingTest.c
|