diff --git a/.config/commitlint.config.js b/.config/commitlint.config.js new file mode 100644 index 0000000000..28fe5c5bf9 --- /dev/null +++ b/.config/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ebc802cf5b..f54cc9cebc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,7 @@ .clang-format @Datadog/libdatadog .codecov.yml @Datadog/apm-common-components-core .config/nextest.toml @Datadog/apm-common-components-core +.config/commitlint.config.js @Datadog/apm-common-components-core .devcontainer @Datadog/apm-common-components-core .dockerignore @Datadog/libdatadog-core .github/ @Datadog/apm-common-components-core diff --git a/.github/workflows/pr-name.yaml b/.github/workflows/pr-name.yaml new file mode 100644 index 0000000000..93162244be --- /dev/null +++ b/.github/workflows/pr-name.yaml @@ -0,0 +1,61 @@ +name: pr-name +permissions: + pull-requests : read + contents: read +on: + pull_request: + types: ['opened', 'edited', 'reopened', 'synchronize'] + branches-ignore: + - "v[0-9]+.[0-9]+.[0-9]+" + - release + +jobs: + pr_name_lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + fetch-depth: 0 + - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 + name: Install Node.js + with: + node-version: 16 + - name: Install dependencies + run: | + npm install @commitlint/lint@18.6.1 @commitlint/load@18.6.1 @commitlint/config-conventional@18.6.2 @actions/core + - name: Lint PR name + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 + with: + script: | + const load = require('@commitlint/load').default; + const lint = require('@commitlint/lint').default; + + const CONFIG = { + extends: ['./.config/commitlint.config.js'], + }; + + const title = context.payload.pull_request.title; + + core.info(`Linting: ${title}`); + + load(CONFIG) + .then((opts) => { + lint( + title, + opts.rules, + opts.parserPreset ? {parserOpts: opts.parserPreset.parserOpts} : {} + ).then((report) => { + report.warnings.forEach((warning) => { + core.warning(warning.message); + }); + + report.errors.forEach((error) => { + core.error(error.message); + }); + + if (!report.valid) { + core.setFailed("PR title linting failed"); + } + }); + }); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0134a0ba71..bf6c3a1847 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,75 @@ We also recommend that you share in your description: If at any point you have a question or need assistance with your pull request, feel free to mention a project member! We're always happy to help contributors with their pull requests. +## Commit Message Guidelines + +This project uses [Conventional Commits](https://www.conventionalcommits.org/) for commit messages and pull request titles. +This format helps us automatically generate changelogs and determine semantic versioning. + +### Format + +Commit messages and PR titles should follow this structure: + +``` +[optional scope]: + +[optional body] + +[optional footer(s)] +``` + +### Common Types + +- **feat**: Code that adds features to the end user +- **fix**: A bug fix +- **docs**: Documentation changes only +- **style**: Code style changes (formatting, missing semicolons, etc.) that don't affect functionality +- **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 `!`. +- **perf**: Performance improvements +- **test**: Adding or updating tests +- **build**: Changes to the build system or external dependencies +- **ci**: Changes to CI configuration files and scripts +- **chore**: Other changes that don't modify src or test files + +### Scope (Optional) + +The scope provides additional context about which part of the codebase is affected: + +``` +feat(crashtracker): add signal handler for SIGSEGV +fix(profiling): correct memory leak in stack unwinding +docs(readme): update installation instructions +``` + +### Breaking Changes + +Breaking changes should be indicated by a `!` after the type/scope: + +``` +feat!: remove deprecated API endpoint +``` + +### Examples + +Good commit messages: +- `feat: add support for custom metadata tags` +- `fix(profiling): resolve deadlock in thread sampling` +- `docs: add examples for exception tracking` +- `chore: update dependencies to latest versions` +- `test(crashtracker): add integration tests for signal handling` + +Poor commit messages: +- `update code` (not descriptive, missing type) +- `Fixed bug` (missing type format, not descriptive) +- `WIP` (not meaningful) + +### Pull Request Titles + +When your pull request is merged, all commits will be squashed into a single commit. The PR title will become the final +commit message, so it's important that it accurately describes your changes.For that reason your pull request title must +follow the conventional commit format described above. Our CI pipeline will automatically validate the PR title and fail +if it doesn't comply with the format. You can update the PR title at any time to fix any validation issues. + ## Final word Many thanks to all of our contributors, and looking forward to seeing you on Github! :tada: