Skip to content

Commit

Permalink
Workflows: try a backport changelog (#61785)
Browse files Browse the repository at this point in the history
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: priethor <[email protected]>
Co-authored-by: vcanales <[email protected]>
  • Loading branch information
4 people authored May 20, 2024
1 parent 91b7be4 commit ae6cf0c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/check-backport-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Verify Core Backport Changlog

on:
pull_request:
types: [opened, synchronize]
paths:
- 'lib/**'
- '!lib/load.php'
- '!lib/experiments-page.php'
- '!lib/experimental/**'
- 'phpunit/**'
- '!phpunit/experimental/**'
- '!phpunit/blocks/**'
- 'packages/**/*.php'
- '!packages/block-library/**'
- '!packages/e2e-tests/**'
jobs:
check:
name: Check CHANGELOG diff
runs-on: ubuntu-latest
steps:
- name: 'Get PR commit count'
run: echo "PR_COMMIT_COUNT=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- name: Checkout code
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: ${{ env.PR_COMMIT_COUNT }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: 'Fetch relevant history from origin'
run: git fetch origin ${{ github.event.pull_request.base.ref }}
- name: Check CHANGELOG status
env:
PR_NUMBER: ${{ github.event.number }}
run: |
changelog_folder="backport-changelog"
# Find any changelog file that contains the Gutenberg PR link
gutenberg_pr_url="https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}"
changelog_file=$(grep -rl "[-*] ${gutenberg_pr_url}" "${changelog_folder}" | head -n 1)
# Confirm that there is an entry containing the Gutenberg PR link
if [[ -z "${changelog_file}" ]]; then
echo "Please create a core backport PR and add a file with the path <wp-release-number>/<core-pr-number>.md in the $changelog_folder folder with the core backport PR URL and a list item with this PR URL."
echo "If changes are related to an existing, open core PR, you may add this PR URL to the core PR's file."
echo "See $changelog_folder/readme.md for more information."
exit 1
fi
core_pr_number=$(basename "${changelog_file}" .md)
core_pr_url="https://github\.com/WordPress/wordpress-develop/pull/${core_pr_number}"
# Confirm that the entry has the correct core backport PR URL.
if ! grep -q -e "${core_pr_url}" "${changelog_file}"; then
echo "Please update the content of ${changelog_file} to include the core backport PR URL, or update the file name to match the core backport PR number."
exit 1
fi
16 changes: 16 additions & 0 deletions backport-changelog/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Core Backport Changelog

Any PR that makes changes to be backported to [core](https://github.com/WordPress/wordpress-develop) should log a core PR here. It's possible to have multiple Gutenberg PRs link to a single core backport PR. The core backport PR can remain open as long as wanted/needed. The entries are sorted by core release (in folders), and each entry should be an md file with the core PR number as the file name, and the link to the Gutenberg PR in the file content. The file content should start with the core PR URL, followed by a Markdown list of Gutenberg PRs (see example). Files are used to avoid rebase conflicts.

If you think a file path is wrongly flagged as needing a core backport PR, you can add it to the list of exceptions in `.github/workflows/check-backport-changelog.yml`.

## Example

Path: `{wp-release-number-x.x}/{core-pr-number}.md`, e.g. `6.6/1234.md`.
File content:
```md
https://github.com/WordPress/wordpress-develop/pull/{core-pr-number}

* https://github.com/WordPress/gutenberg/pull/{first-gb-pr-number}
* https://github.com/WordPress/gutenberg/pull/{second-gb-pr-number}
```

1 comment on commit ae6cf0c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in ae6cf0c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9162897642
📝 Reported issues:

Please sign in to comment.