diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 31737f38f..5687c7845 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -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'