Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add GitHub Action to enforce PR title format #1351

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/pr-title-checker-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"LABEL": {
"name": ""
},
"CHECKS": {
"NOTE": "You can test the regex here: https://regex101.com/r/nDeps5/1",
"regexp": "(^(?<type>build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|BREAKING CHANGE)(?<scope>\\([\\w\\s*-]+\\))?(?<breaking_change>!?): (?<body>([a-z]).+[^.|\\s])$)",
"regexpFlags": "gm"
},
"MESSAGES": {
"success": "All OK",
"failure": "PR title not following the semantic-release guidelines. Please check https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines for more information.",
"notice": ""
}
}
22 changes: 22 additions & 0 deletions .github/workflows/pr-title-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: PR Title Checker

on:
pull_request:
branches:
- master
types:
- opened
- edited
- synchronize
- labeled
- unlabeled

jobs:
check-pr-title:
runs-on: ubuntu-latest
steps:
- uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: .github/pr-title-checker-config.json #(optional. defaults to .github/pr-title-checker-config.json)
39 changes: 0 additions & 39 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind leave the main README minimal and move the PR information in a dedicated file under folder docs.
Maybe something like docs/contributing/pr-guidlines.md

Original file line number Diff line number Diff line change
Expand Up @@ -218,45 +218,6 @@ Following are the post that I found useful working on the migration:
- https://docs.nestjs.com/openapi/types-and-parameters
- https://docs.nestjs.com/openapi/decorators

## New Release Version Bump Workflow

### Workflow Overview

Scicat Backend controls new releases with the `GitHub-tag-and-release` GitHub Action. This workflow is triggered by push events to the release branch. It automates the version bumping and release processes based on semantic commit messages. Full documentation of the action package can be found on [github-tag-action](https://github.com/marketplace/actions/github-tag)

The image below shows visualized workflow.
![image](https://github.com/SciCatProject/scicat-backend-next/assets/78078898/0f3c5386-4a16-4ed1-a2ee-d71ef6f34e99)

### Workflow Trigger Condition

> [!Caution]
> Any push to the `release` branch initiates the workflow.

### Versioning and Release Strategy

**Semantic Versioning:**

- The version is automatically bumped according to the semantic PR titles, using the [semantic-release](https://github.com/semantic-release/semantic-release) conventions:

- `fix:` prefixed titles generate a patch release.
- `feat:` prefixed titles generate a minor release.
- `BREAKING CHANGE:` in the commit message triggers a major release.

**Auto-generated Release Notes:**

The release log is automatically populated with all commit messages since the last tag, providing a detailed changelog for the release. By default semantic-release uses [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).

In order to generate detailed changelog for the release, the following type for the `commit message`/`PR title` should be used:

- feat: message - A new feature
- fix: message - A bug fix
- docs: message - Documentation only changes
- style: message - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: message - A code change that neither fixes a bug nor adds a feature
- perf: message - A code change that improves performance
- test: message - Adding missing or correcting existing tests
- chore: message - Changes to the build process or auxiliary tools and libraries such as documentation generation

## License

This project is licensed under the GPL License - see the [LICENSE](LICENSE) file for details
Expand Down
37 changes: 37 additions & 0 deletions docs/developer-guide/contributing/pr-guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Pull Request Guidelines

When creating a pull request (PR) for this repository, it's important to follow the guidelines for PR titles and PR template to ensure consistency and clarity. Proper PR titles help maintain a clear and understandable project history and facilitate better release notes.

## PR Title Format

All PR titles must adhere to the conventional commits format. This format helps in automating the release process and generating changelogs. The format is as follows:

```
<type>(<scope>): <description>
```

type: The type of change being made. It must be one of the following:

- `feat:` A new feature
- `fix:` A bug fix
- `ci:` Continuous integration-related changes.
- `docs:` Documentation only changes
- `style:` Changes that do not affect the meaning of the code (white -space, formatting, missing semi -colons, etc)
- `refactor:` A code change that neither fixes a bug nor adds a feature
- `revert`: Reverts a previous commit.
- `perf:` A code change that improves performance
- `test:` Adding missing or correcting existing tests
- `chore:` Changes to the build process or auxiliary tools and libraries such as documentation generation
- `build:` Changes that affect the build system or external dependencies.
- `BREAKING CHANGE:` A change that introduces a breaking API change.

scope: An `optional` description of the section of the codebase affected by the changes (e.g., api, ui, docs). This is enclosed in parentheses.

description: A brief summary of the changes made.

## Examples

- feat(api): add new endpoint for data retrieval
- fix(ui): correct button alignment on mobile devices
- docs: update contributing guidelines
- BREAKING CHANGE: refactor authentication middleware to use new library
27 changes: 27 additions & 0 deletions docs/developer-guide/release-guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# New Release Version Bump Workflow

## Workflow Overview

Scicat Backend controls new releases with the `GitHub-tag-and-release` GitHub Action. This workflow is triggered by push events to the release branch. It automates the version bumping and release processes based on semantic commit messages. Full documentation of the action package can be found on [github-tag-action](https://github.com/marketplace/actions/github-tag)

The image below shows visualized workflow.
![image](https://github.com/SciCatProject/scicat-backend-next/assets/78078898/0f3c5386-4a16-4ed1-a2ee-d71ef6f34e99)

## Workflow Trigger Condition

> [!Caution]
> Any push to the `release` branch initiates the workflow.

## Versioning and Release Strategy

**Semantic Versioning:**

- The version is automatically bumped according to the semantic PR titles, using the [semantic-release](https://github.com/semantic-release/semantic-release) conventions:

- `fix:` prefixed titles generate a patch release.
- `feat:` prefixed titles generate a minor release.
- `BREAKING CHANGE:` in the commit message triggers a major release.

**Auto-generated Release Notes:**

The release log is automatically populated with all commit messages since the last tag, providing a detailed changelog for the release. By default semantic-release uses [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).
Loading