Git Hooks

Git Hooks are git’s system for triggering custom scripts when certain important actions occur. This project uses husky to automatically install git hooks for developers.

The scripts themselves can be found in the .husky folder. Their actions are summarised here:

commit-msg

Lint the commit message to ensure it matches Conventional Commits specification.

pre-commit

  1. Generates a README for the terraform configuration.
  2. Formats all staged files using prettier
  3. Lints all the terraform configuration using TFLint
  4. Lints source code using each affected project’s linter
  5. Runs all the unit tests for affected projects

For details on what “affected” projects are, see Nx.

pre-push

Runs the end-to-end tests for all affected projects.

For details on what “affected” projects are, see Nx.

GitHub

As I am using GitOps, it is imperative that all commits on the main are in a production ready state.

Using Github’s protected branches, any commits directly to the main branch are rejected. For a commit to be included on main it must be:

  1. A verified signed commit;
  2. Committed to a branch other than main and merged via pull request;
  3. All required GitHub actions must have been run against it and pass.

This ensures that, in so far as possible, the main branch is production ready.