mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
[CI] Add criticality of release to release notes (#1259)
* Enforces presence of C-labels to designate the importance of a release * Iterates over them on a release, takes the highest present and includes it in the release notes * Lists the change(s) that caused the release to be that priority
This commit is contained in:
@@ -157,9 +157,7 @@ build-wasm-release:
|
|||||||
<<: *compiler_info
|
<<: *compiler_info
|
||||||
# Note: We likely only want to do this for tagged releases, hence the 'only:'
|
# Note: We likely only want to do this for tagged releases, hence the 'only:'
|
||||||
only:
|
only:
|
||||||
# FIXME remove when ready to merge
|
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
|
||||||
- /^[0-9]+$/
|
|
||||||
# - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
|
|
||||||
script:
|
script:
|
||||||
- time wasm-pack build --target web --out-dir wasm --release cli -- --no-default-features --features browser
|
- time wasm-pack build --target web --out-dir wasm --release cli -- --no-default-features --features browser
|
||||||
- mkdir -p ./artifacts/wasm
|
- mkdir -p ./artifacts/wasm
|
||||||
|
|||||||
@@ -3,21 +3,43 @@
|
|||||||
#shellcheck source=lib.sh
|
#shellcheck source=lib.sh
|
||||||
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
|
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
|
||||||
|
|
||||||
|
ensure_labels() {
|
||||||
|
for label in "$@"; do
|
||||||
|
if has_label 'paritytech/polkadot' "$CI_COMMIT_BRANCH" "$label"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Must have one of the following labels
|
# Must have one of the following labels
|
||||||
labels=(
|
releasenotes_labels=(
|
||||||
'B0-silent'
|
'B0-silent'
|
||||||
'B1-releasenotes'
|
'B1-releasenotes'
|
||||||
'B2-runtimenoteworthy'
|
'B2-runtimenoteworthy'
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "[+] Checking labels for $CI_COMMIT_BRANCH"
|
criticality_labels=(
|
||||||
|
'C1-low'
|
||||||
|
'C3-medium'
|
||||||
|
'C7-high'
|
||||||
|
'C9-critical'
|
||||||
|
)
|
||||||
|
|
||||||
for label in "${labels[@]}"; do
|
echo "[+] Checking release notes (B) labels for $CI_COMMIT_BRANCH"
|
||||||
if has_label 'paritytech/polkadot' "$CI_COMMIT_BRANCH" "$label"; then
|
if ensure_labels "${releasenotes_labels[@]}"; then
|
||||||
echo "[+] Label $label detected, test passed"
|
echo "[+] Release notes label detected. All is well."
|
||||||
exit 0
|
else
|
||||||
fi
|
echo "[!] Release notes label not detected. Please add one of: ${releasenotes_labels[*]}"
|
||||||
done
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[!] PR does not have one of the required labels! Please add one of: ${labels[*]}"
|
echo "[+] Checking release criticality (C) labels for $CI_COMMIT_BRANCH"
|
||||||
exit 1
|
if ensure_labels "${criticality_labels[@]}"; then
|
||||||
|
echo "[+] Release criticality label detected. All is well."
|
||||||
|
else
|
||||||
|
echo "[!] Release criticality label not detected. Please add one of: ${criticality_labels[*]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|||||||
@@ -52,8 +52,63 @@ This release was built with the following versions of \`rustc\`. Other versions
|
|||||||
|
|
||||||
runtime_changes=""
|
runtime_changes=""
|
||||||
|
|
||||||
|
# Following variables are for tracking the priority of the release (i.e.,
|
||||||
|
# how important it is for the user to upgrade).
|
||||||
|
# It's frustrating that we need to make an array of indexes (in this case the
|
||||||
|
# labels), but it's necessary to maintain the correct order. Labels and
|
||||||
|
# descriptions *must* be kept in lockstep
|
||||||
|
|
||||||
|
priority_labels=(
|
||||||
|
'C1-low'
|
||||||
|
'C3-medium'
|
||||||
|
'C7-high'
|
||||||
|
'C9-critical'
|
||||||
|
)
|
||||||
|
|
||||||
|
declare -A priority_descriptions=(
|
||||||
|
['C1-low']="Upgrade priority: **Low** (upgrade at your convenience)"
|
||||||
|
['C3-medium']="Upgrade priority: **Medium** (timely upgrade recommended)"
|
||||||
|
['C7-high']="Upgrade priority:❗ **HIGH** ❗ Please upgrade your node as soon as possible"
|
||||||
|
['C9-critical']="Upgrade priority: ❗❗ **URGENT** ❗❗ PLEASE UPGRADE IMMEDIATELY"
|
||||||
|
)
|
||||||
|
|
||||||
|
max_label=-1
|
||||||
|
priority="${priority_descriptions['C1-low']}"
|
||||||
|
declare -a priority_changes
|
||||||
|
|
||||||
|
# Iterate through every PR
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/')
|
pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/')
|
||||||
|
|
||||||
|
# Release priority check:
|
||||||
|
# For each PR, we look for every label equal to or higher than the current highest
|
||||||
|
# I.e., if there has already been a PR marked as 'medium', we only need
|
||||||
|
# to look for priorities medium or above. If we find one, we set the
|
||||||
|
# priority to that level.
|
||||||
|
for ((index=max_label; index<${#priority_labels[@]}; index++)) ; do
|
||||||
|
cur_label="${priority_labels[$index]}"
|
||||||
|
echo "[+] Checking #$pr_id for presence of $cur_label label"
|
||||||
|
if has_label 'paritytech/polkadot' "$pr_id" "$cur_label" ; then
|
||||||
|
echo "[+] #$pr_id has label $cur_label. Setting max."
|
||||||
|
prev_label="$max_label"
|
||||||
|
max_label="$index"
|
||||||
|
priority="${priority_descriptions[$cur_label]}"
|
||||||
|
# If it's not an increase in priority, we just append the PR to the list
|
||||||
|
if [ "$prev_label" == "$max_label" ]; then
|
||||||
|
priority_changes+=("${line/\* /}")
|
||||||
|
fi
|
||||||
|
# If the priority has increased, we override previous changes with new changes
|
||||||
|
if [ "$prev_label" != "$max_label" ]; then
|
||||||
|
priority_changes=("${line/\* /}")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If the PR is labelled silent, we can do an early continue to save a little work
|
||||||
|
if has_label 'paritytech/polkadot' "$pr_id" 'B0-silent'; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# If the PR has a runtimenoteworthy label, add to the runtime_changes section
|
# If the PR has a runtimenoteworthy label, add to the runtime_changes section
|
||||||
if has_label 'paritytech/polkadot' "$pr_id" 'B2-runtimenoteworthy'; then
|
if has_label 'paritytech/polkadot' "$pr_id" 'B2-runtimenoteworthy'; then
|
||||||
runtime_changes="$runtime_changes
|
runtime_changes="$runtime_changes
|
||||||
@@ -77,10 +132,10 @@ fi
|
|||||||
echo "$release_text"
|
echo "$release_text"
|
||||||
|
|
||||||
# Get substrate changes between last polkadot version and current
|
# Get substrate changes between last polkadot version and current
|
||||||
|
# By grepping the Cargo.lock for a substrate crate, and grepping out the commit hash
|
||||||
cur_substrate_commit=$(grep -A 2 'name = "sc-cli"' Cargo.lock | grep -E -o '[a-f0-9]{40}')
|
cur_substrate_commit=$(grep -A 2 'name = "sc-cli"' Cargo.lock | grep -E -o '[a-f0-9]{40}')
|
||||||
git checkout "$last_version"
|
old_substrate_commit=$(git diff "refs/tags/$last_version" Cargo.lock |\
|
||||||
old_substrate_commit=$(grep -A 2 'name = "sc-cli"' Cargo.lock | grep -E -o '[a-f0-9]{40}')
|
grep -A 2 'name = "sc-cli"' | grep -E -o '[a-f0-9]{40}')
|
||||||
|
|
||||||
pushd $substrate_dir || exit
|
pushd $substrate_dir || exit
|
||||||
git checkout master > /dev/null
|
git checkout master > /dev/null
|
||||||
git pull > /dev/null
|
git pull > /dev/null
|
||||||
@@ -94,6 +149,27 @@ pushd $substrate_dir || exit
|
|||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/')
|
pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/')
|
||||||
|
|
||||||
|
# Basically same check as Polkadot priority
|
||||||
|
# We only need to check for any labels of the current priority or higher
|
||||||
|
for ((index=max_label; index<${#priority_labels[@]}; index++)) ; do
|
||||||
|
cur_label="${priority_labels[$index]}"
|
||||||
|
echo "[+] Checking substrate/#$pr_id for presence of $cur_label label"
|
||||||
|
if has_label 'paritytech/substrate' "$pr_id" "$cur_label" ; then
|
||||||
|
echo "[+] #$pr_id has label $cur_label. Setting max."
|
||||||
|
prev_label="$max_label"
|
||||||
|
max_label="$index"
|
||||||
|
priority="${priority_descriptions[$cur_label]}"
|
||||||
|
# If it's not an increase in priority, we just append
|
||||||
|
if [ "$prev_label" == "$max_label" ]; then
|
||||||
|
priority_changes+=("${line/\* /}")
|
||||||
|
fi
|
||||||
|
# If the priority has increased, we override previous changes with new changes
|
||||||
|
if [ "$prev_label" != "$max_label" ]; then
|
||||||
|
priority_changes=("${line/\* /}")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Skip if the PR has the silent label - this allows us to skip a few requests
|
# Skip if the PR has the silent label - this allows us to skip a few requests
|
||||||
if has_label 'paritytech/substrate' "$pr_id" 'B0-silent'; then
|
if has_label 'paritytech/substrate' "$pr_id" 'B0-silent'; then
|
||||||
continue
|
continue
|
||||||
@@ -114,8 +190,6 @@ $line"
|
|||||||
done <<< "$all_substrate_changes"
|
done <<< "$all_substrate_changes"
|
||||||
popd || exit
|
popd || exit
|
||||||
|
|
||||||
echo "[+] Changes generated. Removing temporary repos"
|
|
||||||
|
|
||||||
# Make the substrate section if there are any substrate changes
|
# Make the substrate section if there are any substrate changes
|
||||||
if [ -n "$substrate_runtime_changes" ] ||
|
if [ -n "$substrate_runtime_changes" ] ||
|
||||||
[ -n "$substrate_api_changes" ] ||
|
[ -n "$substrate_api_changes" ] ||
|
||||||
@@ -148,6 +222,18 @@ $substrate_api_changes"
|
|||||||
$substrate_changes"
|
$substrate_changes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Finally, add the priorities to the *start* of the release notes
|
||||||
|
# If polkadot and substrate priority = low, no need for list of changes
|
||||||
|
if [ "$priority" == "${priority_descriptions['C1-low']}" ]; then
|
||||||
|
release_text="$priority
|
||||||
|
|
||||||
|
$release_text"
|
||||||
|
else
|
||||||
|
release_text="$priority - due to change(s): *${priority_changes[*]}*
|
||||||
|
|
||||||
|
$release_text"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[+] Release text generated: "
|
echo "[+] Release text generated: "
|
||||||
echo "$release_text"
|
echo "$release_text"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user