[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
uses: actions/checkout@v2
- name: Restore opam 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 }}
- 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 pkg-config automake jq
run: brew install automake jq ninja pkg-config
if: runner.os == 'macOS'
- name: Install Required Apt Packages for Ubuntu
run: sudo apt-get install libmpfr-dev libsqlite3-dev
if: runner.os == 'Linux'
- name: Fetch clang Release
- name: Compute hash of clang installation
id: clang-hash
run: |
REPO="facebook/facebook-clang-plugins"
URL="https://api.github.com/repos/$REPO"
CLANGFILE="clang-install-${{ matrix.os }}.tar.gz"
echo "::set-output name=value::$(./facebook-clang-plugins/clang/setup.sh --clang-hash)"
RELEASE_INFO="$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$URL/releases/latest")"
if ! ASSET_ID="$(jq ".assets | map(select(.name == \"$CLANGFILE\"))[0].id" <<< "$RELEASE_INFO")"; then
echo "$RELEASE_INFO"
exit 1
fi
- 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 }}
if [[ -z "$ASSET_ID" || "$ASSET_ID" == "null" ]]; then
echo "Could not find asset ID" >&2
exit 1
fi
- 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
curl -J -L "$URL/releases/assets/$ASSET_ID" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/octet-stream" \
-o "$CLANGFILE"
- 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
- 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
if: runner.os == 'macOS'

Loading…
Cancel
Save