-
Notifications
You must be signed in to change notification settings - Fork 860
[Changelogs] Add check_changelogs bash script #9249
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
Merged
weronikaolejniczak
merged 13 commits into
elastic:main
from
weronikaolejniczak:feat/update-changelog-check
Dec 3, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0d481fb
chore: add check changelogs bash script
weronikaolejniczak 7cb87f9
chore: remove summary, too verbose
weronikaolejniczak d6c1d0f
chore: add comma to impacted packages for clarity
weronikaolejniczak e558aed
chore: add a list of changed files
weronikaolejniczak 99df676
Update scripts/check_changelogs.sh
weronikaolejniczak 18caf09
Merge branch 'main' into feat/update-changelog-check
weronikaolejniczak 14e9bb8
chore: bump to actions/checkout@v5
weronikaolejniczak 7153598
chore: use ubuntu-slim
weronikaolejniczak a4664ff
chore: use yarn workspaces to simplify the script
weronikaolejniczak 352b966
chore: compare HEAD to parent only
weronikaolejniczak 52b3a41
chore: use fetch depth 2
weronikaolejniczak 94fba70
Merge branch 'main' into feat/update-changelog-check
weronikaolejniczak 97167c5
Merge branch 'main' into feat/update-changelog-check
weronikaolejniczak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,20 @@ | ||
| name: "Changelog required" | ||
| name: 'Changelog required' | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| # Check for changes in all public packages, needed in the `changelog` job | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| changed-packages: ${{ steps.changes.outputs.changed-packages }} | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Detect package changes | ||
| id: changes | ||
| uses: ./.github/actions/detect-package-changes | ||
|
|
||
| # Enforces the update of a changelog file on every pull request for all public packages | ||
| # unless the PR contains the `skip-changelog` label | ||
| changelog-checks: | ||
| needs: detect-changes | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| package: ${{ fromJson(needs.detect-changes.outputs.changed-packages) }} | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Check changelog for ${{ matrix.package }} | ||
| # TODO specific "package" labels could be checked here? | ||
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changelog') }} | ||
| uses: ./.github/actions/check-changelog | ||
| with: | ||
| pr-number: ${{ github.event.pull_request.number }} | ||
| package-path: packages/${{ matrix.package }} | ||
|
|
||
| # This job will always run and succeed, ensuring the overall check completes. | ||
| changelog: | ||
| needs: changelog-checks | ||
| runs-on: ubuntu-latest | ||
| if: always() | ||
| runs-on: ubuntu-slim | ||
| steps: | ||
| - name: Finish changelog checks | ||
| run: echo "Changelog checks finished." | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 2 | ||
| - name: Check changelogs | ||
| run: | | ||
| ./scripts/check_changelogs.sh \ | ||
| "${{ github.event.pull_request.number }}" \ | ||
| "${{ join(github.event.pull_request.labels.*.name, '|') }}" | ||
| env: | ||
| GITHUB_BASE_REF: ${{ github.base_ref }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Checks that a changelog entry exists for every changed public package in a PR. | ||
| # | ||
| # Skip logic: | ||
| # | ||
| # - if a package is private, changelog check for that specific package is skipped, | ||
| # - if "skip-changelog" label is present, all changelog checks are skipped, | ||
| # - if "skip-changelog-<package-name>" is present, changelog check for that specific package is skipped. | ||
|
|
||
| set -e | ||
|
|
||
| # Pull request ID | ||
| PR_NUMBER="$1" | ||
| # Pipe-separated PR labels | ||
| LABELS="$2" | ||
|
|
||
| if [ -z "$PR_NUMBER" ]; then | ||
| echo "Error: PR_NUMBER argument is missing." | ||
| echo "Usage: $0 <pr_number> [labels]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if a label exists in the list | ||
| has_label() { | ||
| local label="$1" | ||
| local labels_piped="|$LABELS|" | ||
| [[ "$labels_piped" == *"|$label|"* ]] | ||
| } | ||
|
|
||
| # Check for global skip | ||
| if has_label "skip-changelog"; then | ||
| echo "⏩ \`skip-changelog\` label detected. Skipping all changelog checks." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "🔍 Detecting changed public packages..." | ||
|
|
||
| CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD) | ||
|
|
||
| if [ -n "$CHANGED_FILES" ]; then | ||
| echo "Changed files:" | ||
| echo "$CHANGED_FILES" | sed 's/^/- /' | ||
| fi | ||
|
|
||
| CHANGED_PACKAGES=() | ||
| MISSING_CHANGELOGS=() | ||
|
|
||
| # For all public workspaces | ||
| for pkg_path in $(yarn workspaces list --json --no-private | jq -r '.location'); do | ||
| pkg_name=$(basename "$pkg_path") | ||
|
|
||
| # look for the package path in the changed files list | ||
| if echo "$CHANGED_FILES" | grep -Fq "$pkg_path/"; then | ||
| CHANGED_PACKAGES+=("$pkg_name") | ||
| fi | ||
| done | ||
|
|
||
| if [ ${#CHANGED_PACKAGES[@]} -eq 0 ]; then | ||
| echo "✅ No public package changes detected." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "📦 Changed packages: $(echo "${CHANGED_PACKAGES[*]}" | sed 's/ /, /g')" | ||
|
|
||
| # For all public changed workspaces | ||
| for pkg_name in "${CHANGED_PACKAGES[@]}"; do | ||
| # skip if package-specific skip label is present | ||
| if has_label "skip-changelog-$pkg_name"; then | ||
| echo "⏩ Skipping changelog check for \`$pkg_name\` (label \`skip-changelog-$pkg_name\` present)." | ||
| continue | ||
| fi | ||
|
|
||
| # look for the changelog file | ||
| CHANGELOG_FILE="packages/$pkg_name/changelogs/upcoming/$PR_NUMBER.md" | ||
|
|
||
| if [ -f "$CHANGELOG_FILE" ]; then | ||
| echo "✅ \`$pkg_name\`: Changelog entry found ($CHANGELOG_FILE)." | ||
| else | ||
| echo "🚫 \`$pkg_name\`: Changelog entry missing." | ||
| MISSING_CHANGELOGS+=("$pkg_name") | ||
| fi | ||
| done | ||
|
|
||
| if [ ${#MISSING_CHANGELOGS[@]} -gt 0 ]; then | ||
| echo "Please add an \`.md\` file named \`${PR_NUMBER}.md\` to the \`changelogs/upcoming/\` directory of the respective packages." | ||
| echo "Example: \`packages/${MISSING_CHANGELOGS[0]}/changelogs/upcoming/${PR_NUMBER}.md\`" | ||
| echo "You can read more about changelogs here: https://github.com/elastic/eui/blob/main/wiki/contributing-to-eui/documenting/changelogs.md" | ||
| exit 1 | ||
| else | ||
| echo "🎉 All changelog requirements satisfied." | ||
| exit 0 | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉