Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Dec 13, 2023
1 parent 2936660 commit 2881d63
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 9 deletions.
10 changes: 7 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
https://github.com/WordPress/gutenberg/blob/trunk/CONTRIBUTING.md -->

## What?
<!-- In a few words, what is the PR actually doing? -->
<!-- In a few words, describe what this PR does. -->

## Why?
<!-- Why is this PR necessary? What problem is it solving? Reference any existing previous issue(s) or PR(s), but please add a short summary here, too -->

## How?
<!-- How is your PR addressing the issue at hand? What are the implementation details? -->
<!-- How is your PR address the problem or requirement? What are the implementation details? -->

## Testing Instructions
<!-- Please include step by step instructions on how to test this PR. -->
<!-- Please include step-by-step instructions on how to test this PR. -->
<!-- 1. Open a post or page. -->
<!-- 2. Insert a heading block. -->
<!-- 3. etc. -->
Expand All @@ -20,3 +20,7 @@ https://github.com/WordPress/gutenberg/blob/trunk/CONTRIBUTING.md -->
<!-- How can you test the changes by using the keyboard only? Please note, this is required for PRs that change the user interface (UI). This ensures the PR can be tested for any possible accessibility regressions. -->

## Screenshots or screencast <!-- if applicable -->

<!-- AUTO-GENERATED-WORDPRESS-PLAYGROUND-LINK -->
<!-- Generates a test link to WordPress Playground. Please do not remove these comments. -->
<!-- end: AUTO-GENERATED-WORDPRESS-PLAYGROUND-LINK -->
12 changes: 6 additions & 6 deletions .github/workflows/php-changes-detection.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: OPTIONAL - Confirm if PHP changes require backporting to WordPress Core

on:
pull_request:
pull_request_target:
types: [opened, synchronize]
jobs:
detect_php_changes:
name: Detect PHP changes
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request_target' }}
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -41,15 +41,15 @@ jobs:
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- pr-contains-php-changes -->'

- name: Create comment
if: steps.find-comment.outputs.comment-id == '' && steps.changed-files-php.outputs.any_changed == 'true'
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ github.event.number }}
body: |
<!-- pr-contains-php-changes -->
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.
Expand All @@ -70,7 +70,7 @@ jobs:
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ github.event.number }}
edit-mode: replace
body: |
<!-- pr-contains-php-changes -->
Expand All @@ -92,7 +92,7 @@ jobs:
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ github.event.number }}
edit-mode: replace
body: |
<!-- pr-contains-php-changes -->
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/pull-request-playground-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Leaves a comment on a pull request with a link to test the changes in a WordPress Playground instance.
name: OPTIONAL - Comment on a pull request with Playground details

on:
pull_request_target:
types:
- opened

jobs:
test_using_wordpress_playground:
name: Test using WordPress Playground
runs-on: ubuntu-latest
permissions:
issues: write
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request_target' }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Update PR Description
uses: actions/github-script@v6
with:
script: |
// Extract information about the pull request
const prNumber = github.event.number;
// Fetch the current PR description
const currentDescription = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
}).then(response => response.data.body);
// Define the start and end comments
const startComment = '<!-- AUTO-GENERATED-WORDPRESS-PLAYGROUND-LINK -->';
const endComment = '<!-- end: AUTO-GENERATED-WORDPRESS-PLAYGROUND-LINK -->;
// Find the positions of the start and end comments
const startIndex = currentDescription.indexOf(startComment);
const endIndex = currentDescription.indexOf(endComment);
// Check if both start and end comments are present
if (startIndex !== -1 && endIndex !== -1) {
// Extract the content between the start and end comments
const placeholderContent = currentDescription.slice(startIndex + startComment.length, endIndex);
// Replace the content with your updated content
const newContent = `## Test this pull request with WordPress Playground
| :arrow_forward: **[Click here to load this PR into WordPress Playground](https://playground.wordpress.net/gutenberg.html?pr=56964)** |
| ------------- |
> [!TIP]
> _WordPress Playground uses the latest build of Gutenberg from this pull request. If your changes are not reflected in WordPress Playground , it's likely that the most recent build isn't complete or has failed. Check the [build workflow runs to be sure](https://github.com/WordPress/gutenberg/actions/workflows/build-plugin-zip.yml)._
Read more about [WordPress Playground](https://developer.wordpress.org/playground/) and its [limitations](https://wordpress.github.io/wordpress-playground/limitations/).
`;
const newDescription = currentDescription.replace(`${startComment}${placeholderContent}${endComment}`, `${startComment}${newContent}${endComment}`);
// Update PR description using GitHub API
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: newDescription,
});
} else {
console.log("Start or end comment not found in the PR description.");
}
1 change: 1 addition & 0 deletions lib/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ function gutenberg_default_demo_title( $title ) {

return $title;
}

add_filter( 'default_title', 'gutenberg_default_demo_title' );

0 comments on commit 2881d63

Please sign in to comment.