[github] cache clang builds

Summary:
Use the cache action to cache the clang build instead of the
facebook-clang-plugins releases.

- the facebook-clang-plugins repo is no longer by infer so its clang
  will soon be out of date

- much simpler to use the cache action

- build clang before setting opam: this is unfortunate but needed to
  ensure there is enough space on GitHub's machines to build clang...

- install ninja on Linux + Mac machines for faster and less OOM-y builds

Reviewed By: martintrojer

Differential Revision: D24160876

fbshipit-source-id: 705e06151
master
Jules Villard 4 years ago committed by Facebook GitHub Bot
parent 6e3435b8e3
commit 33da6fd96c

@ -21,53 +21,50 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Restore opam cache - name: Install Required Apt Packages for Ubuntu
uses: actions/cache@v2 run: |
with: sudo apt install libmpfr-dev libsqlite3-dev ninja-build
path: ~/.opam sudo apt clean
key: opam-${{ runner.os }}-${{ hashFiles('opam.locked') }} if: runner.os == 'Linux'
- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
with:
ocaml-version: ${{ matrix.ocaml-version }}
- name: Install Required Brew Packages for MacOS - name: Install Required Brew Packages for MacOS
run: brew install pkg-config automake jq run: brew install automake jq ninja pkg-config
if: runner.os == 'macOS' if: runner.os == 'macOS'
- name: Install Required Apt Packages for Ubuntu - name: Compute hash of clang installation
run: sudo apt-get install libmpfr-dev libsqlite3-dev id: clang-hash
if: runner.os == 'Linux'
- name: Fetch clang Release
run: | run: |
REPO="facebook/facebook-clang-plugins" echo "::set-output name=value::$(./facebook-clang-plugins/clang/setup.sh --clang-hash)"
URL="https://api.github.com/repos/$REPO"
CLANGFILE="clang-install-${{ matrix.os }}.tar.gz"
RELEASE_INFO="$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$URL/releases/latest")" - name: Attempt to get clang from the cache
if ! ASSET_ID="$(jq ".assets | map(select(.name == \"$CLANGFILE\"))[0].id" <<< "$RELEASE_INFO")"; then id: cache-clang
echo "$RELEASE_INFO" uses: actions/cache@v2
exit 1 with:
fi path: facebook-clang-plugins/clang/install
key: clang-${{ runner.os }}-${{ steps.clang-hash.outputs.value }}
if [[ -z "$ASSET_ID" || "$ASSET_ID" == "null" ]]; then - name: Record that the clang cache was hit
echo "Could not find asset ID" >&2 if: steps.cache-clang.outputs.cache-hit == 'true'
exit 1 run: ./facebook-clang-plugins/clang/setup.sh --only-record-install
fi
curl -J -L "$URL/releases/assets/$ASSET_ID" \ - name: Build clang on cache misses
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ if: steps.cache-clang.outputs.cache-hit != 'true'
-H "Accept: application/octet-stream" \ run: |
-o "$CLANGFILE" ./facebook-clang-plugins/clang/src/prepare_clang_src.sh
./facebook-clang-plugins/clang/setup.sh --ninja --sequential-link
- run: tar -xzf clang-install-${{ matrix.os }}.tar.gz -C facebook-clang-plugins/clang/ - name: Attempt to get opam tree from the cache
uses: actions/cache@v2
with:
path: ~/.opam
key: opam-${{ runner.os }}-${{ hashFiles('opam.locked') }}
- run: ./facebook-clang-plugins/clang/setup.sh --only-record-install - name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
with:
ocaml-version: ${{ matrix.ocaml-version }}
- run: ./build-infer.sh -y all - run: ./build-infer.sh --yes all
- run: make install - run: make install
if: runner.os == 'macOS' if: runner.os == 'macOS'

Loading…
Cancel
Save