natcap / invest

InVEST®: models that map and value the goods and services from nature that sustain and fulfill human life.
Apache License 2.0
170 stars 71 forks source link

Design an InVEST automated release process #14

Closed phargogh closed 4 years ago

phargogh commented 4 years ago

The InVEST release process has been quite manual (documented here: https://bitbucket.org/natcap/invest/wiki/Release Checklist) and pretty involved, requiring a nontrivial amount of engineering time to become confident in our releases before we send it out.

In short, it would be a fantastic improvement to our team productivity if we could design a process that:

Other related questions we’ll want to consider are:

phargogh commented 4 years ago

I've started this process by working on a couple of scripts to do some of the text processing required for this sort of automation, all written (at present) to ci/release/. Next steps are to figure out how to create a new release object in the repository via the github api during an actions run.

phargogh commented 4 years ago

I've added a script to ci/release/tag-github-repo.py` to tag a target github repository.

The best thing to do at this point will be to work up a prototype on a sample repository on my own account. This prototype should have two workflows:

  1. A workflow that will do a 'build' (maybe zip something up or something like that). This should execute on every push, PR and Release. If the triggering event is a release, the build should also upload its artifact to the correct release in the correct repository.
  2. A workflow that will create a github release, but only if there are new commits on master.
  3. I'm concerned that all of this will cause release to be automatically created on forks as well. This prototype should only trigger the creation of releases IFF on the main repository, not on a fork.
phargogh commented 4 years ago
phargogh commented 4 years ago

I'm currently having some challenges with ensuring that builds happen under the following circumstances:

Right now there's also a complication which is that pushing tags also counts as a push. Is this incorrect? Unlike with mercurial (where making a tag also makes a new commit), pushing a tag will also trigger a rebuild and retest.

dcdenu4 commented 4 years ago

Oh that's tricky. Yea I believe Git treats tags like branches basically, so you have to push them to the remote server like you would a local branch.

phargogh commented 4 years ago

@dcdenu4 it makes sense given how git works! But it's still a little strange to rebuild things for the same commit (just with a different version number).

phargogh commented 4 years ago

This is coming along! I've gotten the release-object and binaries automation up and running in my fork, but there's still some extra work to be done to streamline what is currently working.

phargogh commented 4 years ago

Before I leave this for the weekend, just making notes on where things were left off. Remaining tasks are:

phargogh commented 4 years ago

It turns out that you cannot have events authenticated with $GITHUB_TOKEN trigger other events (see https://help.github.com/en/actions/reference/events-that-trigger-workflows). If we want to be able to trigger other events, it must be authenticated with a personal access token. There are a couple of possible ways that we could move forward from this

  1. Continue with full release automation The cron action will need to be authenticated with a personal access token, but after doing so, we should then be able to have the job trigger the other binary builds as needed.
  2. Automate everything except the release creation Instead of automating releases, we could determine by hand when to create the release object, and then have a pile of other automation start up in response to this. Fortunately, retagging the repo with the same commit can be done, and the release object will be updated to point to the correct revision.

Somewhat interestingly, these two options are not mutually exclusive. Let's say master is in a state where the full release automation won't do an automated release (like when tests are failing on master). We could still follow a few steps by hand to have the same effect:

  1. Update the HISTORY on a branch
  2. PR the branch into master
  3. Once the PR is merged into master, create a release object with the appropriate text derived from HISTORY (and converted to Markdown, such as via pandoc).
  4. Once the release is created, this will push a tag and will therefore trigger a build of the new ref. And because actions will be building at a ref, the files will be uploaded to the release object.
phargogh commented 4 years ago

Currently pending #83

phargogh commented 4 years ago

We now have an InVEST automated release process. I'll close this issue and instead work on improving the existing process.