diff --git a/.github/workflows/chart-test.yaml b/.github/workflows/chart-test.yaml index be4428e5..25376460 100644 --- a/.github/workflows/chart-test.yaml +++ b/.github/workflows/chart-test.yaml @@ -104,6 +104,11 @@ jobs: ./tools/dev/check-uncommitted-changes.sh || \ (echo "run 'just update-lock' and commit the result." && exit 1) + # checks that bumped chart versions have a corresponding NEWS.md entry + - name: Check NEWS.md entries + if: github.ref != 'refs/heads/main' + run: ./tools/dev/check-news-entries.sh main + - name: Notify Slack of chart unittest failure if on main if: github.ref == 'refs/heads/main' && steps.unittest.outcome == 'failure' uses: slackapi/slack-github-action@v1.27.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47fe3626..41bb06d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,8 @@ We'll try to be as responsive as possible in reviewing and accepting pull reques [Go templating](./charts/_templates.gotmpl) and `helm-docs`. - Run `just setup` to install `helm-doc`. - CI requires that the chart version get bumped for any change in the directory. +- When bumping a chart version, add a `## X.Y.Z` entry to the chart's `NEWS.md` + describing what changed. CI will check for this. - Use `just update-lock` to update all chart's lockfiles. - Changes to the `rstudio-library` chart will update all downstream charts at the same time (via the `file://` syntax in `Chart.yaml`) diff --git a/tools/dev/check-news-entries.sh b/tools/dev/check-news-entries.sh new file mode 100755 index 00000000..c895e6d5 --- /dev/null +++ b/tools/dev/check-news-entries.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# +# Verify that changed charts with a version bump also have a NEWS.md entry +# for the new version. Runs in CI alongside the existing version bump check. +# +set -euo pipefail + +TARGET_BRANCH="${1:-main}" +exit_code=0 + +for chart_dir in charts/*/ other-charts/*/; do + chart_yaml="${chart_dir}Chart.yaml" + news_md="${chart_dir}NEWS.md" + + [ -f "$chart_yaml" ] || continue + + # Get the current version + current_version=$(grep '^version:' "$chart_yaml" | awk '{print $2}') + + # Get the version on the target branch + base_version=$(git show "origin/${TARGET_BRANCH}:${chart_yaml}" 2>/dev/null | grep '^version:' | awk '{print $2}' || echo "") + + # Skip if version didn't change + [ "$current_version" != "$base_version" ] || continue + + # Version was bumped — check for NEWS.md entry + if [ ! -f "$news_md" ]; then + echo "Error: ${chart_dir} has a version bump ($base_version -> $current_version) but no NEWS.md file." + exit_code=1 + continue + fi + + if ! grep -q "^## ${current_version}$" "$news_md"; then + echo "Error: ${news_md} is missing an entry for version ${current_version}." + echo "" + echo " Chart version was bumped from ${base_version} to ${current_version}," + echo " but NEWS.md has no '## ${current_version}' heading." + echo "" + echo " To fix, add a section like this to ${news_md}:" + echo "" + echo " ## ${current_version}" + echo "" + echo " - Description of what changed" + echo "" + exit_code=1 + fi +done + +if [ $exit_code -eq 0 ]; then + echo "All changed charts have NEWS.md entries." +fi + +exit $exit_code