Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c4e535

Browse files
authored
ci(publishing): enforce conventional commit linting on the PR name (#1413)
Enforce conventional commit linting on the PR name. Add configuration file to codeowners file. doc: add commit message guidelines in the contributing document. Clarifying contributing doc Co-authored-by: julio.gonzalez <[email protected]>
1 parent 0d4ebbe commit 5c4e535

4 files changed

Lines changed: 132 additions & 0 deletions

File tree

.config/commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {extends: ['@commitlint/config-conventional']}

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.clang-format @Datadog/libdatadog
66
.codecov.yml @Datadog/apm-common-components-core
77
.config/nextest.toml @Datadog/apm-common-components-core
8+
.config/commitlint.config.js @Datadog/apm-common-components-core
89
.devcontainer @Datadog/apm-common-components-core
910
.dockerignore @Datadog/libdatadog-core
1011
.github/ @Datadog/apm-common-components-core

.github/workflows/pr-name.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: pr-name
2+
permissions:
3+
pull-requests : read
4+
contents: read
5+
on:
6+
pull_request:
7+
types: ['opened', 'edited', 'reopened', 'synchronize']
8+
branches-ignore:
9+
- "v[0-9]+.[0-9]+.[0-9]+"
10+
- release
11+
12+
jobs:
13+
pr_name_lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
persist-credentials: false
19+
fetch-depth: 0
20+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
21+
name: Install Node.js
22+
with:
23+
node-version: 16
24+
- name: Install dependencies
25+
run: |
26+
npm install @commitlint/[email protected] @commitlint/[email protected] @commitlint/[email protected] @actions/core
27+
- name: Lint PR name
28+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
29+
with:
30+
script: |
31+
const load = require('@commitlint/load').default;
32+
const lint = require('@commitlint/lint').default;
33+
34+
const CONFIG = {
35+
extends: ['./.config/commitlint.config.js'],
36+
};
37+
38+
const title = context.payload.pull_request.title;
39+
40+
core.info(`Linting: ${title}`);
41+
42+
load(CONFIG)
43+
.then((opts) => {
44+
lint(
45+
title,
46+
opts.rules,
47+
opts.parserPreset ? {parserOpts: opts.parserPreset.parserOpts} : {}
48+
).then((report) => {
49+
report.warnings.forEach((warning) => {
50+
core.warning(warning.message);
51+
});
52+
53+
report.errors.forEach((error) => {
54+
core.error(error.message);
55+
});
56+
57+
if (!report.valid) {
58+
core.setFailed("PR title linting failed");
59+
}
60+
});
61+
});

CONTRIBUTING.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,75 @@ We also recommend that you share in your description:
7878
If at any point you have a question or need assistance with your pull request, feel free to mention a project member!
7979
We're always happy to help contributors with their pull requests.
8080

81+
## Commit Message Guidelines
82+
83+
This project uses [Conventional Commits](https://www.conventionalcommits.org/) for commit messages and pull request titles.
84+
This format helps us automatically generate changelogs and determine semantic versioning.
85+
86+
### Format
87+
88+
Commit messages and PR titles should follow this structure:
89+
90+
```
91+
<type>[optional scope]: <description>
92+
93+
[optional body]
94+
95+
[optional footer(s)]
96+
```
97+
98+
### Common Types
99+
100+
- **feat**: Code that adds features to the end user
101+
- **fix**: A bug fix
102+
- **docs**: Documentation changes only
103+
- **style**: Code style changes (formatting, missing semicolons, etc.) that don't affect functionality
104+
- **refactor**: Code changes that neither fix a bug nor add a feature. Removing a public interface is considered a refactor and should be marked with `!`.
105+
- **perf**: Performance improvements
106+
- **test**: Adding or updating tests
107+
- **build**: Changes to the build system or external dependencies
108+
- **ci**: Changes to CI configuration files and scripts
109+
- **chore**: Other changes that don't modify src or test files
110+
111+
### Scope (Optional)
112+
113+
The scope provides additional context about which part of the codebase is affected:
114+
115+
```
116+
feat(crashtracker): add signal handler for SIGSEGV
117+
fix(profiling): correct memory leak in stack unwinding
118+
docs(readme): update installation instructions
119+
```
120+
121+
### Breaking Changes
122+
123+
Breaking changes should be indicated by a `!` after the type/scope:
124+
125+
```
126+
feat!: remove deprecated API endpoint
127+
```
128+
129+
### Examples
130+
131+
Good commit messages:
132+
- `feat: add support for custom metadata tags`
133+
- `fix(profiling): resolve deadlock in thread sampling`
134+
- `docs: add examples for exception tracking`
135+
- `chore: update dependencies to latest versions`
136+
- `test(crashtracker): add integration tests for signal handling`
137+
138+
Poor commit messages:
139+
- `update code` (not descriptive, missing type)
140+
- `Fixed bug` (missing type format, not descriptive)
141+
- `WIP` (not meaningful)
142+
143+
### Pull Request Titles
144+
145+
When your pull request is merged, all commits will be squashed into a single commit. The PR title will become the final
146+
commit message, so it's important that it accurately describes your changes.For that reason your pull request title must
147+
follow the conventional commit format described above. Our CI pipeline will automatically validate the PR title and fail
148+
if it doesn't comply with the format. You can update the PR title at any time to fix any validation issues.
149+
81150
## Final word
82151

83152
Many thanks to all of our contributors, and looking forward to seeing you on Github! :tada:

0 commit comments

Comments
 (0)