Enable-ci research for Circle CI

I want to jot down some notes as a result of looking into what we need to do to enable Circle CI in enable-ci.

First of all, Circle CI is lacking the same type of CLI supported by Travis, which we use to encrypt macaroons and save the decryption password in the environment. As a result, the best we can do is encrypt the file (e.g. openssl aes-256-cbc -e -in <config> -out <encrypted config> -k <password>) and guide the user toward adding that password into the environment.

As far as modifying the YAML goes, deployment differs depending on whether the project in question is using v1 or v2, and we’ll need to support both:

As you can see, those two formats are a pretty easy map from the Travis deployment we already support (we’ll use a xenial docker container again, etc.). For v1, it would probably look like this:

deployment:
  snap:
    branch: master
    commands:
      - openssl aes-256-cbc -d -in <encrypted config> -out .snapcraft/snapcraft.cfg -k <key>
      - docker run -v $(pwd):$(pwd) -t snapcore/snapcraft sh -c "apt update -qq && cd $(pwd) && snapcraft && snapcraft push *.snap --release edge"

For v2, it’s a little more complicated. We need to create the job, first, and it’ll look like this:

jobs:
  # ...
  snap:
    steps:
      - checkout
      - run
        command: |
          openssl aes-256-cbc -d -in <encrypted config> -out .snapcraft/snapcraft.cfg -k <key>
          docker run -v $(pwd):$(pwd) -t snapcore/snapcraft sh -c "apt update -qq && cd $(pwd) && snapcraft && snapcraft push *.snap --release edge"

Then we need to add that job to the workflow. We’ll need to be careful not to garbage up what they have already, but we need to add the snap job defined above to the end of the pipeline they’ve already configured, so it looks like this:

workflows:
  version: 2
  <job they already have>:
    # ...
    jobs: [<stuff they already have>, snap]