Skip to content

Commit

Permalink
ci: Implement conventional commit validation
Browse files Browse the repository at this point in the history
ci: Implement conventional commit validation

ci: Implement conventional commit validation
  • Loading branch information
mahdichtioui committed Dec 3, 2024
1 parent 32add29 commit daf117f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ variables:
- template: build/variables.yml

stages:
- stage: Commit_Validation
dependsOn: []
jobs:
- template: build/stage-commit-validation.yaml

#-if false
# This special if is used to remove those Dotnet_New stages for generated application.
- stage: Dotnet_New_GeneratedApp
dependsOn: Commit_Validation
jobs:
- template: .template.config/build/stage-donetnew.yaml

Expand Down Expand Up @@ -62,9 +68,7 @@ stages:

#-endif
- stage: Build_Staging
#-if false
dependsOn: []
#-endif
dependsOn: Commit_Validation
jobs:
- template: build/stage-build.yml
parameters:
Expand Down
7 changes: 7 additions & 0 deletions build/stage-commit-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This stage is responsible for running the template to validate the commits of the PR
jobs:
- job: OnWindows_ValidateCommits
pool:
vmImage : $(windowsHostedAgentImage)
steps:
- template: templates/validate-commits.yaml
11 changes: 11 additions & 0 deletions build/templates/validate-commits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This template is used to validate that the commit messages follow the Conventional Commits specification (https://www.conventionalcommits.org/en/v1.0.0/).
# Consider placing this at the beginning of the build pipeline to ensure that the commits are valid before proceeding with longer build steps.
steps:
- task: CommitMessageValidator@1
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
inputs:
regExPattern: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\w \p{Extended_Pictographic}])+([\s\S]*)'
regExFlags: "um"
allCommitsMustMatch: true
prMode: true
displayName: 'Validate Commit Messages'

0 comments on commit daf117f

Please sign in to comment.