Github Actions: setting up Docker on macOS

Gnomock had a very extensive test suite since the very beginning. The tests ran on Github Actions and CircleCI platforms, on Linux, to make sure that both CI/CD platforms are properly supported. After all, Gnomock is used during CI, and not only locally.

Locally though I use macOS for development, and the same tests that run on Linux during CI must run correctly on my laptop as well. Even though docker should make the underlying platform unimportant, sometimes there are platform specific issues that must be caught during CI. For example, on macOS the host is accessible using host.docker.internal domain name, and there is some platform specific code in Gnomock that uses this feature.

Lack of macOS builds obviously led to Gnomock breaking at some point. It clearly was the time to add macOS builds to the pipeline.

Github Actions Linux runners have docker, as well as other software, pre-installed, but macOS runners don’t, so for Gnomock tests to pass on macOS, docker must be installed first.

Luckily, there is a setup-docker Github Action to setup docker easily (but not so quickly…)

  test-core:
    name: "[core] gnomock, gnomockd"
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      # ...

      - uses: docker-practice/actions-setup-docker@master
        if: ${{ matrix.os == 'macos-latest' }}

      # ...

Internally, it installs docker, starts it and waits for it to become available. This process takes time, making the builds pretty slow: in Gnomock, this step takes 10-15 minutes.

Thankfully, Github Actions are free for open source projects, so Gnomock is now be tested on both Linux and macOS.

2021-06-11 Update

Just one week after I originally wrote this note, setup-docker action became very unstable, and I decided to stop running Gnomock tests on Mac OS, at least temporarily. Your experience might be different.