April 5, 2020

Git Stuff. CI Stuff.

Trying out GitHub Actions.

Spent most of the day testing using GitHub Actions for BanChain‘s continuous integration pipeline.

GitHub Actions

Some useful actions I came across:

General

  • actions/cache - Cache dependencies and build outputs in GitHub Actions

This one in particular seems really useful. From what I’ve read and understand, it caches any dependencies (e.g. node_modules) across workflow runs. This means that, for one version of package.json, npm install or yarn install need to be run only once and the rest of the times we can just use the cached modules.

There does seem to be a 5GB limit on the size of the cache per repository, but that’s more than sufficient for my case.

Go

  • actions/setup-go - Set up your GitHub Actions workflow with a specific version of Go

Rust

Git CLI

One problem with our current GitLab CI workflow is that since we are technically pushing any changes to GitHub then mirroring that to GitLab, GitLab seems to not be able to detect a pull request’s based commit (the commit that git checkout -b <BRANCH-NAME> was run from master).

For our mono-repo containing multiple projects, each with their own workflow and tests, this makes running running tests associated with the files that’ve been changed since branching very difficult, if not impossible. Up until now, we resorted to running the full test suite for all projects before allowing a merge. If we could change that to a ‘per-changed-directory’ approach, things would be a lot more efficient.

To that end, I managed to find a git command that lists all the files changed since branch checkout:

git log origin..HEAD --name-only --pretty="" | sort | uniq

Now I just need to figure out a way for GitHub Actions to make use of that list.

© Sawit Trisirisatayawong 2020

Powered by Hugo & Kiss.