From 38b988dd9fc9bbf47febc3499a239115b0d77cc9 Mon Sep 17 00:00:00 2001 From: Thibault Richard Date: Fri, 21 Apr 2023 17:41:18 +0200 Subject: [PATCH 1/3] Add script to check generated release notes --- hack/release-notes/check.sh | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 hack/release-notes/check.sh diff --git a/hack/release-notes/check.sh b/hack/release-notes/check.sh new file mode 100755 index 0000000000..26def10321 --- /dev/null +++ b/hack/release-notes/check.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +# or more contributor license agreements. Licensed under the Elastic License 2.0; +# you may not use this file except in compliance with the Elastic License 2.0. + +# Script that helps identifying changes that have been labeled as belonging to certain release version +# where the corresponding commits are not in the release branch. +# Its main purpose is to discover missing backports. + +set -uo pipefail + +WD="$(cd "$(dirname "$0")" || return; pwd)" +ROOT="$WD/../.." + +get-prev-version() { + local version=$1 + git tag | grep -v '-' | grep -B1 "$version" | head -1 +} + +list-merged-commits() { + local nextVersion=$1 + local prevVersion=$2 + git log --pretty=oneline "$prevVersion..$nextVersion" | grep -o "#[0-9]*" | sort +} + +list-release-notes-pr-commits() { + local version=$1 + version=${version#v} # strip v prefix + grep -o 'pull}[0-9]*' "$ROOT/docs/release-notes/$version.asciidoc" | sed 's/pull}/#/' | sort +} + +count-release-notes-pr-without-merged-commit() { + local nextVersion=$1 + local prevVersion=$2 + local grepOpts=${3:-} + # shellcheck disable=SC2086 + diff \ + <(list-merged-commits "$nextVersion" "$prevVersion") \ + <(list-release-notes-pr-commits "$nextVersion") \ + | grep $grepOpts '>' +} + +main() { + local nextVersion=$1 + local prevVersion=${2:-$(get-prev-version "$nextVersion")} + + echo "Compare 'merged PR from $prevVersion to $nextVersion' with 'release-notes/$nextVersion'" + + count=$(count-release-notes-pr-without-merged-commit "$nextVersion" "$prevVersion" -c) + if [[ "$count" -eq 0 ]]; then + echo "✅ LGTM" + else + echo "❌ Error: no commit found for the following issues:" + count-release-notes-pr-without-merged-commit "$nextVersion" "$prevVersion" + fi +} + +main "$@" From b7074407bceaae6465ca6da5ab92af384a830075 Mon Sep 17 00:00:00 2001 From: Thibault Richard Date: Tue, 25 Apr 2023 09:53:18 +0200 Subject: [PATCH 2/3] check if diff returns an empty string --- hack/release-notes/check.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hack/release-notes/check.sh b/hack/release-notes/check.sh index 26def10321..c8fde4a213 100755 --- a/hack/release-notes/check.sh +++ b/hack/release-notes/check.sh @@ -33,12 +33,10 @@ list-release-notes-pr-commits() { count-release-notes-pr-without-merged-commit() { local nextVersion=$1 local prevVersion=$2 - local grepOpts=${3:-} - # shellcheck disable=SC2086 diff \ <(list-merged-commits "$nextVersion" "$prevVersion") \ <(list-release-notes-pr-commits "$nextVersion") \ - | grep $grepOpts '>' + | grep '>' } main() { @@ -47,8 +45,8 @@ main() { echo "Compare 'merged PR from $prevVersion to $nextVersion' with 'release-notes/$nextVersion'" - count=$(count-release-notes-pr-without-merged-commit "$nextVersion" "$prevVersion" -c) - if [[ "$count" -eq 0 ]]; then + prs=$(count-release-notes-pr-without-merged-commit "$nextVersion" "$prevVersion") + if [[ -z "$prs" ]]; then echo "✅ LGTM" else echo "❌ Error: no commit found for the following issues:" From 155ee9f8b0037bb9854f37c62882ca655dc784fe Mon Sep 17 00:00:00 2001 From: Thibault Richard Date: Tue, 25 Apr 2023 09:57:33 +0200 Subject: [PATCH 3/3] document usage --- hack/release-notes/check.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hack/release-notes/check.sh b/hack/release-notes/check.sh index c8fde4a213..27a545086d 100755 --- a/hack/release-notes/check.sh +++ b/hack/release-notes/check.sh @@ -7,6 +7,8 @@ # Script that helps identifying changes that have been labeled as belonging to certain release version # where the corresponding commits are not in the release branch. # Its main purpose is to discover missing backports. +# +# Usage: check.sh TAG set -uo pipefail