Peter
Peter

Reputation: 3163

GitHub Actions: homebrew slow

I have never used macOS in my life so I'm not sure if this is a problem with the image used by GitHub actions, homebrew itself or how I'm using it:

I'm trying to use GitHub actions to build and test a C++ project on Ubuntu and macOS. Building the code using CMake only takes around one minute in both cases, however, installing the dependencies (Boost and Lua) takes more than three minutes on macOS as opposed to 20 seconds on Ubuntu. My workflow.yml looks as follows:

jobs:
  build-and-test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        include:
        - os: ubuntu-latest
          INSTALL_DEPS: sudo apt-get install -yq libboost-dev libboost-graph-dev lua5.3 liblua5.3-dev
          CC: gcc
          CXX: g++
        - os: macos-latest
          INSTALL_DEPS: brew install boost lua
          CC: clang
          CXX: clang++
    steps:
      - uses: actions/checkout@v2
      - name: install-dependencies
        run: ${{ matrix.INSTALL_DEPS }}
      # ...

It seems as though boost is the only package I can install using homebrew, as opposed to the more fine-grained libboost-dev + libboost-graph-dev.

Is there anything I can do here if I don't want to build Boost from source on macOS? I know that it's possible to cache dependencies using GitHub actions but that seems overly complicated for my use-case and I don't actually know how to use that with homebrew in the first case.

Upvotes: 1

Views: 1528

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40849

I made small test to check how long it does take to use brew on Ubuntu

jobs:
  build-and-test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        include:
        - os: ubuntu-latest
          INSTALL_DEPS: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" && date && brew install boost lua && date
          #INSTALL_DEPS: sudo apt-get install -yq libboost-dev libboost-graph-dev lua5.3 liblua5.3-dev
          CC: gcc
          CXX: g++
        - os: macos-latest
          INSTALL_DEPS: brew install boost lua
          CC: clang
          CXX: clang++
    steps:
      - uses: actions/checkout@v2
      - name: install-dependencies
        run: ${{ matrix.INSTALL_DEPS }}

And to run brew install boost lua it took about 26 seconds

Fri Dec 18 11:16:02 UTC 2020
Fri Dec 18 11:16:28 UTC 2020

Where on MacOS I got 2:33, 46s, 45s. So comparing to highest value this is a big difference. But comparing 45s to 26s is not (still almost 2 times, but it doesn't sound such bad). I think that there is no point actually to optimizing that. There can be plenty of aspects which may impact and even this message may also play role on that

enter image description here

If you are on good way to finish your pipeline focus on that, as you may loose plenty of time fighting for best performance without a luck as some aspect could be out of your control.

Upvotes: 2

Related Questions