[#31734] lint: Keep name on same line as DEFINE macros #70
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, synchronize, reopened, edited ] | |
| 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 ::Pull Request title must include issue ID, code area," | |
| echo "::error :: and a short description, with no extra whitespace." | |
| 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 | |
| echo "Pull Request title is valid." | |
| - 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 ::Pull Request title should not specify target branch for master." | |
| exit 1 | |
| fi | |
| echo "Pull Request title is valid for master branch." | |
| else | |
| if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then | |
| BACKPORT_BRANCH="${BASH_REMATCH[2]}" | |
| if [[ "${BACKPORT_BRANCH}" != "${{ github.base_ref }}" ]]; then | |
| echo "::error ::Backport branch in title (${BACKPORT_BRANCH}) does not match" | |
| echo "::error :: Pull Request base ref (${{ github.base_ref }})." | |
| exit 1 | |
| fi | |
| echo "Pull Request title branch reference ($BACKPORT_BRANCH) matches base reference." | |
| else | |
| echo "::error ::Pull Request title must begin with target release branch in 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 | |
| - name: Check Backport references | |
| run: | | |
| BACKPORT_RE='^\[BACKPORT ([0-9]+(\.[0-9]+)+)\]' | |
| # Check for true backport, not just target branch in title. | |
| if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then | |
| body="${{ github.event.pull_request.body }}" | |
| bp_error=0 | |
| COMMIT_HDR_RE=($'\n'\|^)'Original commit(s)?:' | |
| COMMIT_LIST_RE='(- )?[0-9a-f]+ / [#D][0-9]+' | |
| if [[ "$body" =~ $COMMIT_HDR_RE ]]; then | |
| echo "Found original commit(s) tag." | |
| else | |
| bp_error=1 | |
| fi | |
| if (( bp_error == 0 )) && [[ "$body" =~ $COMMIT_LIST_RE ]]; then | |
| echo "Found original commit info: ${BASH_REMATCH[0]}" | |
| else | |
| bp_error=1 | |
| fi | |
| if (( bp_error == 1 )); then | |
| echo "::error ::Backport Pull Request must include original commit info." | |
| echo "::error ::Include SHA (full or prefix) and issue reference in the" | |
| echo "::error :: Pull Request description." | |
| echo "::error ::Start at beginning of a line. Examples:" | |
| echo "::error ::Original commit: 123abc / #12345" | |
| echo "::error ::Original commits:" | |
| echo "::error ::- 123abc / #12345" | |
| echo "::error ::- 345def / #43555" | |
| exit 1 | |
| fi | |
| else | |
| echo "Pull Request title does not indicate a backport." | |
| fi |