Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to check generated release notes #6723

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions hack/release-notes/check.sh
Original file line number Diff line number Diff line change
@@ -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.
thbkrkr marked this conversation as resolved.
Show resolved Hide resolved

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)
thbkrkr marked this conversation as resolved.
Show resolved Hide resolved
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 "$@"