Skip to content

Commit

Permalink
docs: describe conventional commits (#789)
Browse files Browse the repository at this point in the history
Co-authored-by: adeeri <[email protected]>
  • Loading branch information
rti and adeeri authored Oct 22, 2024
1 parent 99dd1ee commit 44216ed
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions docs/conventional-commits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Conventional commits

[Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) are human and machine readable commit messages. We use them to automatically generate changelog items and [semantic version (SemVer)](https://semver.org/) bumps on release using [NX](https://nx.dev). Here is an example of a commit message describing a bug fix in a backup script. Releasing this change would bump the project's patch version number:

```
fix(backup-script): report error if no space left on device
```

On release of a project, NX collects all commit messages from git for the project's directory (e.g. `build/wdqs`) since last release (e.g. `[email protected]`). For this to work well we need to follow a certain procedure in our Pull requests:

- Use conventional commit syntax for the PR title, then squash merge the PR, so that the squashed commit will contain the conventional commit message from the PR title on the target branch. The PR body will become the commit message body.
- Or: Merge with merge commit so that all commits from the PR are retained on the target branch. All commits in the PR should follow conventional commit syntax then.

## Supported types

NX supports [a number of](https://github.com/nrwl/nx/blob/db10812da789cd48d3a722628a00feda9d0e3810/packages/nx/src/command-line/release/config/conventional-commits.ts) conventional commit types. We use the following for changelog generation as configured in our [nx.json](https://github.com/wmde/wikibase-release-pipeline/blob/main/nx.json):

| Type | SemVer Bump | Changelog Title |
| -------- | ----------- | ---------------- |
| build | patch | πŸ“¦ Build |
| chore | patch | 🏑 Chore |
| ci | patch | πŸ€– CI |
| docs | patch | πŸ“– Documentation |
| feat | minor | πŸš€ Features |
| fix | patch | 🩹 Fixes |
| perf | patch | πŸ”₯ Performance |
| refactor | patch | πŸ’… Refactors |
| style | patch | 🎨 Styles |
| test | patch | βœ… Tests |

## Examples

### Feature

A new feature implementation bumping the minor version:

```
feat: added support for cats
```

Will generate the following changelog entry:

#### πŸš€ Features

- added support for cats

### Documentation update

Some update to the docs bumping a minor version:

```
docs: describe how to work around sleeping cats
```

Will generate the following changelog entry:

#### πŸ“– Documentation

- describe how to work around sleeping cats

### Breaking change

All types can be breaking changes. Here is an example for a breaking refactor, bumping a major version.

```
refactor!: remove support for sabre-toothed tiger
```

Will generate the following changelog entry:

#### πŸ’… Refactors

- remove support for sabre-toothed tiger

### Performance change for a certain component

Noting that a change is specific to a component or subsystem in a project.

```
pref(food-dispenser): improved speed
```

Will generate the following changelog entry:

#### πŸ”₯ Performance

- food-dispenser: improved speed

0 comments on commit 44216ed

Please sign in to comment.