Skip to content

Commit e2ebe53

Browse files
[stable2412] Backport #8435 (#8438)
Backport #8435 into `stable2412` from EgorPopelyaev. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> --------- Co-authored-by: Egor_P <egor@parity.io>
1 parent d77b878 commit e2ebe53

File tree

3 files changed

+68
-13
lines changed

3 files changed

+68
-13
lines changed

.github/scripts/common/lib.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,37 @@ prepare_docker_stable_tag() {
519519
exit 1
520520
fi
521521
}
522+
523+
# Parse names of the branches from the github labels based on the pattern
524+
#
525+
# input: labels (array of lables like ("A3-backport" "RO-silent" "A4-backport-stable2407" "A4-backport-stable2503"))
526+
# output: BRANCHES (array of the branch names)
527+
parse_branch_names_from_backport_labels() {
528+
labels="$1"
529+
BRANCHES=""
530+
531+
for label in $labels; do
532+
if [[ "$label" =~ ^A4-backport-stable[0-9]{4}$ ]]; then
533+
branch_name=$(sed 's/A4-backport-//' <<< "$label")
534+
BRANCHES+=" ${branch_name}"
535+
fi
536+
done
537+
538+
BRANCHES=$(echo "$BRANCHES" | sed 's/^ *//')
539+
echo "$BRANCHES"
540+
}
541+
542+
# Extract the PR number from the PR title
543+
#
544+
# input: PR_TITLE
545+
# output: PR_NUMBER or exit 1 if the PR title does not contain the PR number
546+
extract_pr_number_from_pr_title() {
547+
PR_TITLE=$1
548+
if [[ "$PR_TITLE" =~ \#([0-9]+) ]]; then
549+
PR_NUMBER="${BASH_REMATCH[1]}"
550+
else
551+
echo "⚠️ The PR title does not contain original PR number. PR title should be in form: [stableBranchName] Backport #originalPRNumber"
552+
exit 1
553+
fi
554+
echo $PR_NUMBER
555+
}

.github/workflows/check-prdoc.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,19 @@ jobs:
4343
echo "Checking PRdoc version"
4444
$ENGINE run --rm -v $PWD:/repo $IMAGE --version
4545
46-
- name: Get PR number
46+
- name: Get Original PR number
4747
if: ${{ github.event.pull_request.number != '' && !contains(steps.get-labels.outputs.labels, 'R0') }}
48+
shell: bash
49+
env:
50+
PR_TITLE: ${{ github.event.pull_request.title }}
4851
run: |
52+
. ./.github/scripts/common/lib.sh
4953
original_pr_number=''
5054
PR_TITLE="${{ github.event.pull_request.title }}"
5155
if [[ $PR_TITLE =~ 'Backport' ]]; then
5256
# Extracting the original PR number from the backport's PR title
53-
if [[ $PR_TITLE =~ \#([0-9]+) ]]; then
54-
original_pr_number="${BASH_REMATCH[1]}"
55-
echo "Extracted PR number: $original_pr_number"
56-
else
57-
echo "⚠️ The PR title dose not contain original PR number. PR title should be in form: [stableBranchName] Backport #originalPRNumber"
58-
exit 1
59-
fi
57+
original_pr_number=$(extract_pr_number_from_pr_title "$PR_TITLE")
58+
echo "Extracted PR number: $original_pr_number"
6059
else
6160
original_pr_number=${{ github.event.pull_request.number }}
6261
fi

.github/workflows/check-semver.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,36 @@ jobs:
7272
rustup default $TOOLCHAIN
7373
rustup component add rust-src --toolchain $TOOLCHAIN
7474
75-
- name: install parity-publish
75+
- name: Install parity-publish
76+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'R0-silent') }}
7677
# Set the target dir to cache the build.
7778
run: CARGO_TARGET_DIR=./target/ cargo install parity-publish@0.8.0 --locked -q
7879

79-
- name: check semver
80+
- name: Get original PR number
81+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'R0-silent') }}
82+
shell: bash
83+
env:
84+
PR_TITLE: ${{ github.event.pull_request.title }}
85+
run: |
86+
. ./.github/scripts/common/lib.sh
87+
original_pr_number=''
88+
89+
echo "Checking PR title: $PR_TITLE"
90+
91+
if [[ "$PR_TITLE" =~ 'Backport' ]]; then
92+
# Extracting the original PR number from the backport's PR title
93+
original_pr_number=$(extract_pr_number_from_pr_title "$PR_TITLE")
94+
echo "Extracted PR number: $original_pr_number"
95+
else
96+
original_pr_number=${{ github.event.pull_request.number }}
97+
fi
98+
echo "PR_NUMBER=$original_pr_number" >> $GITHUB_ENV
99+
100+
- name: Check semver
101+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'R0-silent') }}
102+
env:
103+
PRDOC_EXTRA_ARGS: ${{ env.PRDOC_EXTRA_ARGS }}
104+
PR: ${{ env.PR_NUMBER }}
80105
run: |
81106
export CARGO_TARGET_DIR=target
82107
export RUSTFLAGS='-A warnings -A missing_docs'
@@ -96,6 +121,3 @@ jobs:
96121
97122
exit 1
98123
fi
99-
env:
100-
PR: ${{ github.event.pull_request.number }}
101-
PRDOC_EXTRA_ARGS: ${{ env.PRDOC_EXTRA_ARGS }}

0 commit comments

Comments
 (0)