CI your MacOS dotfiles with GitHub Actions!
Tags: dotfiles, productivity, macos, devops
Published: 2019-12-02 14:07:28

---
title: CI your MacOS dotfiles with GitHub Actions!
published: true
date: 2019-12-02 06:00:00 UTC
tags: dotfiles,productivity,macos,devops
canonical_url: https://mattorb.com/ci-your-dotfiles-with-github-actions/
---

 ![CI your MacOS dotfiles with GitHub Actions!](https://mattorb.com/content/images/2019/09/goran-ivos-@goran_ivos-yBEyYR8wps-unsplash.jpg) photo credit: [goran-ivos](https://unsplash.com/@goran_ivos)

Dependencies that you can't or won't pin versions of in a reliable persistent cache, have the potential for drift.  Such is the life of [my dotfiles repo](https://github.com/mattorb/dotfiles).  I _don't want_ to pin most things there.  It is an outlier relative to what you might normally set up to produce the most consistent, reliable build process.   For dotfiles, I want to lean way in towards making sure they stay current even if it breaks once in a while in exchange for that posture.

One of the challenges of making sure a dotfiles repo continues to function correctly on a clean machine is that running through them for the first time, in a clean environment, is a rare activity.  It generally only happens when I am configuring a new laptop or others are installing it for the first time.  

If I could do a clean install on a more regular basis, it would decrease the chance that little breakages are piling up over time.  This is where a most basic form of continuous integration comes in.

I am starting with a sanity test . . .

> Can the install script execute, start to finish, without error?

I have already seen this break when a dependency is renamed or when I introduce a subtle syntax error that someone finds in a fork when they try to run everything clean for the first time.  I want to catch those issues as quickly as possible.

## GitHub Actions for MacOS dotfiles CI

When perusing the [GitHub Actions](https://help.github.com/en/articles/about-github-actions) documentation, I noticed they included the ability to run an action on a MacOS VM!

_wat._

For free.

_wat._

For open source repositories.

_oh, yah ok._

Still . . . In case you are not aware, getting a hosted MacOS VM, while possible, is generally not cheap relative to other server options.  The fact that Github is offering [free] to run Mac workloads for opensource projects is a cause for celebration.

Ok.  Let's get to the meat of it:  GitHub Actions are behaviors you define in a yaml file checked in to the repository itself.  

To get started I defined a 'Smoke Test CI' workflow in _.github/workflows/smoke.yml_ in my dotfiles repo:

```
name: Smoke Test CI

on: [push]

jobs:
  build:

    runs-on: macOS-latest
    
    steps:
    - uses: actions/checkout@v1
    - name: Execute full install
      run: ./setup.sh
```

Every single push to the dotfiles repo provisions a temporary MacOS VM, checks out the code with git, and executes the full install of the dotfiles (via ./_setup.sh_).  

The results for the builds that are triggered are in the Actions tab for that Repository on Github:

![CI your MacOS dotfiles with GitHub Actions!](https://mattorb.com/content/images/2019/09/Screen-Shot-2019-09-10-at-8.42.30-AM.png)

and you can drill in to see the results of each step and the logs:

![CI your MacOS dotfiles with GitHub Actions!](https://mattorb.com/content/images/2019/09/Screen-Shot-2019-09-10-at-8.43.03-AM.png)

That's it!

Getting this set up has already caught [some bugs](https://github.com/mattorb/dotfiles/pull/2).\*\*

_\*\*One caveat: For a small handful of things, I had to detect that I was running inside a GitHub action and skip over them because they required privileges that were locked down or not available on that VM.  Prudently, Github provides some default environment variables in the VM when running inside a Github Action.  I used those as a clue to skip them.  _