[2025.2][DEVOPS-3735] ci: github actions for PR static check #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "yb-gh" | |
| # The title/description checks are only really needed on open/edit events, | |
| # But then it won't be available from head commit if the PR is synchronized. | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened] | |
| paths-ignore: | |
| - README.md | |
| - 'docs/**' | |
| jobs: | |
| pr-title: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check PR title | |
| run: | | |
| TITLE_RE='^(\[(BACKPORT )?([0-9]+(\.[0-9]+)+)\])?' | |
| TITLE_RE+='\[((#[0-9]+(,#[0-9]+)*)|([A-Z]+-[0-9]+(,[A-Z]+-[0-9]+)*))\]' | |
| TITLE_RE+=' [a-zA-Z0-9_-]+(,[[a-zA-Z0-9_]-]+)*:' | |
| TITLE_RE+=' \S.{8,98}\S$' | |
| if [[ ! "${{ github.event.pull_request.title }}" =~ $TITLE_RE ]]; then | |
| echo "::error ::PR title must include issue ID, code area (no extra whitespace)," | |
| echo "::error :: and a short description." | |
| echo "::error ::Issue referenced must be a github issue or YB-internal Jira ID" | |
| echo "::error ::Short description must be less than 100 characters." | |
| echo "::error ::Backport branch should be used only for non-master release branches." | |
| echo "::error ::Examples:" | |
| echo "::error :: [#12345,#12367] area: Cool feature xyz" | |
| echo "::error :: [BACKPORT 2045.1][#12345] area1,area2: Must have fix" | |
| exit 1 | |
| fi | |
| - name: Check Backport title | |
| run: | | |
| BACKPORT_RE='^(\[(BACKPORT )?([0-9]+(\.[0-9]+)+)\])' | |
| if [[ "${{ github.base_ref }}" == "master" ]]; then | |
| if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then | |
| echo "::error ::PR title should not specify target branch if targeting master." | |
| exit 1 | |
| fi | |
| else | |
| if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then | |
| BACKPORT_BRANCH="${BASH_REMATCH[1]}" | |
| if [[ "${BACKPORT_BRANCH}" != "${{ github.base_ref }}" ]]; then | |
| echo "::error ::Backport branch in title (${BACKPORT_BRANCH}) does not match" | |
| echo "::error :: PR base ref (${{ github.base_ref }})." | |
| exit 1 | |
| fi | |
| else | |
| echo "::error ::PR title must begin with target release branch in square brackets." | |
| echo "::error ::Examples:" | |
| echo "::error :: [BACKPORT 2045.1][#12345] area1,area2: Must have fix from master" | |
| echo "::error :: [2045.2][#12345] area: release-specific change" | |
| exit 1 | |
| fi | |
| fi | |
| # Check if there is backport commit/PR info in desc. |