Unverified Commit fdc278a4 authored by s3krit's avatar s3krit Committed by GitHub
Browse files

[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
parent 183848b6
Pipeline #97200 passed with stages
in 21 minutes and 32 seconds
......@@ -157,9 +157,7 @@ build-wasm-release:
<<: *compiler_info
# Note: We likely only want to do this for tagged releases, hence the 'only:'
only:
# FIXME remove when ready to merge
- /^[0-9]+$/
# - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
script:
- time wasm-pack build --target web --out-dir wasm --release cli -- --no-default-features --features browser
- mkdir -p ./artifacts/wasm
......
......@@ -3,21 +3,43 @@
#shellcheck source=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
labels=(
releasenotes_labels=(
'B0-silent'
'B1-releasenotes'
'B2-runtimenoteworthy'
)
echo "[+] Checking labels for $CI_COMMIT_BRANCH"
criticality_labels=(
'C1-low'
'C3-medium'
'C7-high'
'C9-critical'
)
echo "[+] Checking release notes (B) labels for $CI_COMMIT_BRANCH"
if ensure_labels "${releasenotes_labels[@]}"; then
echo "[+] Release notes label detected. All is well."
else
echo "[!] Release notes label not detected. Please add one of: ${releasenotes_labels[*]}"
exit 1
fi
for label in "${labels[@]}"; do
if has_label 'paritytech/polkadot' "$CI_COMMIT_BRANCH" "$label"; then
echo "[+] Label $label detected, test passed"
exit 0
fi
done
echo "[+] Checking release criticality (C) labels for $CI_COMMIT_BRANCH"
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
echo "[!] PR does not have one of the required labels! Please add one of: ${labels[*]}"
exit 1
exit 0
......@@ -52,8 +52,63 @@ This release was built with the following versions of \`rustc\`. Other versions
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
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 has_label 'paritytech/polkadot' "$pr_id" 'B2-runtimenoteworthy'; then
runtime_changes="$runtime_changes
......@@ -77,10 +132,10 @@ fi
echo "$release_text"
# 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}')
git checkout "$last_version"
old_substrate_commit=$(grep -A 2 'name = "sc-cli"' Cargo.lock | grep -E -o '[a-f0-9]{40}')
old_substrate_commit=$(git diff "refs/tags/$last_version" Cargo.lock |\
grep -A 2 'name = "sc-cli"' | grep -E -o '[a-f0-9]{40}')
pushd $substrate_dir || exit
git checkout master > /dev/null
git pull > /dev/null
......@@ -94,6 +149,27 @@ pushd $substrate_dir || exit
while IFS= read -r line; do
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
if has_label 'paritytech/substrate' "$pr_id" 'B0-silent'; then
continue
......@@ -114,8 +190,6 @@ $line"
done <<< "$all_substrate_changes"
popd || exit
echo "[+] Changes generated. Removing temporary repos"
# Make the substrate section if there are any substrate changes
if [ -n "$substrate_runtime_changes" ] ||
[ -n "$substrate_api_changes" ] ||
......@@ -148,6 +222,18 @@ $substrate_api_changes"
$substrate_changes"
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"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment