Search code examples
node.jsmacoscontinuous-integrationgithub-actions

How to install imagemagick and other homebrew dependencies in GitHub Actions/Workflows config?


I had to do this basically on my Mac to get the required dependencies wired up locally for my package:

brew cask install java
brew install graphicsmagick
brew install imagemagick
brew install fontforge
brew install ffmpeg
brew install xetex
brew install nasm
brew install qemu

I am using Node.js, it's a node package. How do I tell GitHub Actions/Workflows to setup all this stuff on the Mac environment? I would like to also try getting an Ubuntu environment going, so it would be nice to know how to run different installation setup scripts for each environment.

My config, which doesn't seem to be working yet, is this essentially: name: build

on:
  pull_request:
    paths-ignore:
      - '**.md'
  push:
    branches:
      - build
    paths-ignore:
      - '**.md'

jobs:
  # linux:
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v2
  #     - uses: actions/setup-node@v1
  #     - run: sudo apt-get install ninja-build
  #     - run: ninja --version

  # windows:
  #   runs-on: windows-latest
  #   steps:
  #     - uses: actions/checkout@v2
  #     - uses: actions/setup-node@v1
  #     - run: choco install ninja
  #     - run: ninja --version

  macos:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 14.x
      - run: brew cask install java
      - run: brew install graphicsmagick
      - run: brew install imagemagick
      - run: brew install fontforge
      - run: brew install ffmpeg
      - run: brew install xetex
      - run: brew install nasm
      - run: brew install qemu
      - run: npm ci
      - run: npm test

I don't have any docker (nor should I be using docker, since I want to run in a Mac environment?). Wondering what I need to do next.


Solution

  • It seems like you have at least three options (and you do not need docker):

    Option 1: Run on Ubuntu and install with brew

    The Ubuntu GitHub Runner already has linuxbrew installed (last bullet in the linked document).

    You might encounter issues here, since this environment will not be completely compatible with your mac.

    Option 2: Run on Ubuntu and install with apt

    Find the respective apt packages for the ones you currently install with brew, and install them normally with a run directive.

    Option 3: Run on a MacOS runner

    This is probably the most suitable for you. If you want the CI environment to more closely resemble your personal environment, run on a mac runner instead of an ubuntu runner. These are the supported environments - you will probably want runs-on: macos-latest. The software installed on the GitHub macos runner is listed at https://github.com/actions/runner-images/tree/main/images/macos