Lint commits to follow conventionalcommits
Problem
We started following https://www.conventionalcommits.org/en/v1.0.0/ to automatically generate a release. For this to work properly it requires that every commit follows the conventionalcommits. Most contributors started using this, but it's still something the maintainers have to check manually and inform the author of the merge request about this. We should have an automated process to lint the commits.
Proposal
We can use commitlint which is a tool that will look at the git commits and validate them to a config file. This job should only run for merge requests since we only care about the commits that are being introduced.
Steps
-
Enable pipelines fo merge requests https://docs.gitlab.com/ee/ci/merge_request_pipelines/#use-rules-to-run-pipelines-for-merge-requests 👉 !98 (merged) -
Enable pipelines for merge result https://docs.gitlab.com/ee/ci/merge_request_pipelines/pipelines_for_merged_results/#enable-pipelines-for-merged-results 👉 #31 (comment 458781389) -
Add a job commitlint
that will take commits fromCI_MERGE_REQUEST_TARGET_BRANCH_SHA
to the current branch.
A demo of this can be found in https://gitlab.com/azzsteve/commitlint-demo/-/merge_requests/1
Note: There is an alternative to just use the default branch, similar to secret detection but it gets messy because we need to make sure both branches are available, enabling pipelines for merge results are also beneficial for it's own reasons