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: Fix Commits Validator #431

Merged
merged 1 commit into from
Feb 6, 2025
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Prefix your items with `(Template)` if the change is about the template and not
- Updated Pipeline Code Coverage Task from V1 to V2.
- Fixed iOS crash by updating package and configuring the interpreter.
- Added support for arm64 and x86 cpus in the mobile project.
- Update Uno packages from 5.2.121 to 5.5.95.
- Updated Uno packages from 5.2.121 to 5.6.30.
- Adding workaround for uno safe area issue https://github.com/unoplatform/uno/issues/6218
- Removing MaterialCommandbarHeight property.
- Updated commit validation for the CI/CD.

## 3.7.X
- Replacing Appcenter with Firebase app distribution for Android.
Expand Down
11 changes: 6 additions & 5 deletions build/templates/validate-commits.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This template is used to validate that the commit messages follow the Conventional Commits specification (https://www.conventionalcommits.org/en/v1.0.0/).
# 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: PowerShell@2
Expand All @@ -18,8 +18,9 @@ steps:
Write-Host "Retrieving commits..."
git fetch origin
Write-Host "Commit Range: origin/$(System.PullRequest.TargetBranch)..origin/$(System.PullRequest.SourceBranch)"
$commits = git log origin/$(System.PullRequest.TargetBranch)..origin/$(System.PullRequest.SourceBranch) --pretty=format:"%H %B"
$commitCount = ($commits | Measure-Object).Count
$commits = git log origin/$(System.PullRequest.TargetBranch)..origin/$(System.PullRequest.SourceBranch) --pretty=format:"%s"
$commitArray = $commits -split "`n"
$commitCount = $commitArray.Count
Write-Host "Commits found: $commitCount"

# Regex pattern for Conventional Commits
Expand All @@ -28,8 +29,8 @@ steps:

# Validate each commit message
$invalidCommits = @()
foreach ($commit in $commits -split "`n") {
$commitMessage = $commit.Substring($commit.IndexOf(" ") + 1)
foreach ($commit in $commitArray) {
$commitMessage = $commit.Trim()
Write-Host "Validating commit: $commitMessage"

if ($commitMessage -notmatch $pattern) {
Expand Down