Add a GitHub Actions workflow for pull request builds. #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
create-provider-hooks
and notmaster/main
TL;DR
Adds a Github Actions CI workflow for pull requests.
Why?
This gives us confidence that new changes will cleanly integrate into the main branch, give us fast feedback mechanisms for linting, testing, compilation and ensures documentation is up-to-date.
I went with Actions over, Travis, Circle CI etc due to its simplicity and first-class integration within the GitHub UI and its free for open-source projects.
What?
The workflow is broken down into four self contained jobs which run concurrently on every push to a pull request:
lint
,test
,build
, anddocs
.Each job consists of the same boilerplate checkout, install node and load npm cache (which unfortunately can't be shared across jobs until this issue is fixed later this year: actions/runner#438 (comment)). All jobs run on a ubuntu image with node 12.x, however I left in a matrix for node versions if we want to test on more than one in the future.
I'm using
npm ci
instead ofnpm install
which should lead to faster builds and it loads the cache for~/.npm
from previous build based on the hash of thepackage-lock.json
contents.lint
runsnpm run lint
and will catch linting errorstest
runsnpm run test
and will catch test failuresbuild
runsnpm run build:dev
and will catch compilation errors. note: this should be changed tonpm run build:prod
when it exists.docs
runsnpm run build:doc
and then validates whether the git tree is clean. This will ensure contributors always commit any updated documentation changes.