From 436c25aa474ebff5eabca7e23261762df94ab5f4 Mon Sep 17 00:00:00 2001 From: "Lytovchenko, Danylo" Date: Mon, 26 May 2025 15:13:31 +0200 Subject: [PATCH] SWDEV-12345 Add PR title and commit message validation (#349) [ROCm/clr commit: 7f6020d599ddea241e34617b1ecba92f3d22d54c] --- .../.github/workflows/pr-title-validate.yml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 projects/clr/.github/workflows/pr-title-validate.yml diff --git a/projects/clr/.github/workflows/pr-title-validate.yml b/projects/clr/.github/workflows/pr-title-validate.yml new file mode 100644 index 0000000000..65f5564d81 --- /dev/null +++ b/projects/clr/.github/workflows/pr-title-validate.yml @@ -0,0 +1,42 @@ +name: Validate PR Title + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + validate-pr-title: + runs-on: ubuntu-latest + steps: + - name: Check PR Title + id: check-pr-title + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + + if [[ ! "$PR_TITLE" =~ ^SWDEV-[0-9]+ ]]; then + echo "::error::PR title must start with a Jira ticket ID, SWDEV-" + exit 1 + else + echo "PR title is valid" + fi + + validate-commit-messages: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Check all commit messages + id: validate-commit-messags + run: | + COMMITS=$(git log --format="%H %s" origin/${{ github.event.pull_request.base.ref }}..origin/${{ github.event.pull_request.head.ref }}) + echo "$COMMITS" + echo "$COMMITS" | while read -r hash message; do + echo -e "$hash $message\n " + if [[ ! "$message" =~ ^SWDEV-[0-9]+ ]]; then + echo "::error:: $hash commit should start with Jira ticket ID, SWDEV-" + exit 1 + fi + done