Skip to content

Internal: Automatically create a revert PR [ED-20000]#31827

Merged
Svitlana-Dykun merged 24 commits intomainfrom
ED-20000-internal-automatically-create-a-revert-pr
Jul 14, 2025
Merged

Internal: Automatically create a revert PR [ED-20000]#31827
Svitlana-Dykun merged 24 commits intomainfrom
ED-20000-internal-automatically-create-a-revert-pr

Conversation

@Svitlana-Dykun
Copy link
Copy Markdown
Contributor

@Svitlana-Dykun Svitlana-Dykun commented Jul 12, 2025

Summary

This PR introduces an automatic revert PR creation functionality that triggers when Playwright tests fail on pushes to main or version branches (3.x).

What's New

🔄 Automatic Revert PR Creation

  • New GitHub Action: .github/workflows/create-revert-pr/action.yml
  • Enhanced Playwright Workflow: Updated to trigger revert PR creation on test failures
  • Test Workflow: Comprehensive testing workflow for the revert functionality

🛠️ Key Features

  1. Smart Revert Detection: Automatically detects when tests fail on critical branches
  2. Duplicate Prevention: Prevents creating multiple revert PRs for the same commit
  3. Rich PR Information: Includes original commit details, author, and failure context
  4. Auto-labeling: Adds 'run-tests' label to trigger tests on revert PRs
  5. Proper Branch Management: Creates revert branches from parent commit (pre-failure state)

📋 How It Works

  1. Trigger: When Playwright tests fail on push to main or 3.x branches
  2. Detection: Identifies the failing commit and retrieves its metadata
  3. Branch Creation: Creates a new revert branch from the parent commit
  4. PR Creation: Automatically creates a PR with detailed information about the failure
  5. Labeling: Adds run-tests label to ensure the revert is tested

🔧 Technical Implementation

  • Permissions: Added required permissions for content writing and PR management
  • Composite Action: Reusable GitHub Action for creating revert PRs
  • Error Handling: Robust error handling and duplicate prevention
  • Testing Infrastructure: Comprehensive test workflow with multiple scenarios

🧪 Testing

The PR includes a dedicated test workflow (.github/workflows/test-revert-pr.yml) that supports:

  • Revert Creation Testing: End-to-end testing of revert PR creation
  • Duplicate Prevention Testing: Ensures no duplicate PRs are created
  • Action-Only Testing: Tests the action in isolation
  • Cleanup: Automatic cleanup of test data

🎯 Benefits

  • Faster Recovery: Immediate revert PRs when tests fail on critical branches
  • Reduced Manual Work: Eliminates need for manual revert PR creation
  • Better Visibility: Clear documentation of what failed and why
  • Consistent Process: Standardized revert PR format and information

📝 Files Changed

  • .github/workflows/create-revert-pr/action.yml - New composite action
  • .github/workflows/playwright.yml - Enhanced with revert PR creation
  • .github/workflows/test-revert-pr.yml - Comprehensive test workflow
  • .github/workflows/cherry-pick-pr.yml - Permission fixes
  • tests/playwright/sanity/includes/widgets/basic-gallery.test.ts - Test improvements

This feature significantly improves the development workflow by providing immediate, automated responses to test failures on critical branches, ensuring faster recovery and better code quality maintenance.

✨ PR Description

Purpose: Add automatic revert PR creation functionality when tests fail on main or version branches to quickly restore stability.
Main changes:

  • Created new GitHub Action for generating revert PRs when Playwright tests fail
  • Added permissions and workflow configurations to support automatic PR creation
  • Implemented duplicate PR detection and workflow file change handling
  • Added intentional test break for testing the revert PR functionality

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

- Add reusable action for creating revert PRs when tests fail
- Modify Playwright workflow to use the new revert action
- Add proper permissions and error handling
- Include duplicate prevention logic
- Add test-revert-functionality branch to Playwright workflow triggers
- Add test comment to basic-gallery.test.ts for testing purposes
- This commit will be used to test the automatic revert PR creation
- Add test-revert-functionality branch to revert PR conditions
- Create dedicated failing test for revert PR functionality testing
- Fix v4-tests by removing intentional failure
- This commit should trigger revert PR creation when pushed
## PR Checklist
<!-- 
Please check if your PR fulfills the following requirements:
**Filling out the template is required.** Any pull request that does not
include enough information to be reviewed in a timely manner may be
closed at the maintainers' discretion.
 -->
- [ ] The commit message follows our guidelines:
https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md


## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x" with no
spaces eg: [x]. -->
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## Summary

This PR can be summarized in the following changelog entry:

*

## Description
An explanation of what is done in this PR

*

## Test instructions
This PR can be tested by following these steps:

*

## Quality assurance

- [ ] I have tested this code to the best of my abilities
- [ ] I have added unittests to verify the code works as intended
- [ ] Docs have been added / updated (for bug fixes / features)

Fixes #
## PR Checklist
<!-- 
Please check if your PR fulfills the following requirements:
**Filling out the template is required.** Any pull request that does not
include enough information to be reviewed in a timely manner may be
closed at the maintainers' discretion.
 -->
- [ ] The commit message follows our guidelines:
https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md


## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x" with no
spaces eg: [x]. -->
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## Summary

This PR can be summarized in the following changelog entry:

*

## Description
An explanation of what is done in this PR

*

## Test instructions
This PR can be tested by following these steps:

*

## Quality assurance

- [ ] I have tested this code to the best of my abilities
- [ ] I have added unittests to verify the code works as intended
- [ ] Docs have been added / updated (for bug fixes / features)

Fixes #
## PR Checklist
<!-- 
Please check if your PR fulfills the following requirements:
**Filling out the template is required.** Any pull request that does not
include enough information to be reviewed in a timely manner may be
closed at the maintainers' discretion.
 -->
- [ ] The commit message follows our guidelines:
https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md


## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x" with no
spaces eg: [x]. -->
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## Summary

This PR can be summarized in the following changelog entry:

*

## Description
An explanation of what is done in this PR

*

## Test instructions
This PR can be tested by following these steps:

*

## Quality assurance

- [ ] I have tested this code to the best of my abilities
- [ ] I have added unittests to verify the code works as intended
- [ ] Docs have been added / updated (for bug fixes / features)

Fixes #
- Remove debugging text from cherry-pick workflow step name
- Remove test branch condition from Playwright workflow
- Remove intentional test failure file
- Keep only essential revert workflow functionality
- Remove invalid 'workflows' permission (not a valid GitHub Actions permission)
- Add configurable ALLOW_WORKFLOW_CHANGES parameter to bypass workflow safety check
- Enable revert PR creation for commits that modify workflow files
- Update Playwright workflow to allow workflow changes in revert PRs
gitstream-cm[bot]

This comment was marked as resolved.

The test-revert-functionality branch was only needed for testing the revert PR functionality. Now that the feature is working and ready for production, we can remove it from the push triggers to keep the workflow clean.
gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

gitstream-cm[bot]

This comment was marked as resolved.

@Svitlana-Dykun Svitlana-Dykun merged commit 078f55f into main Jul 14, 2025
51 checks passed
@Svitlana-Dykun Svitlana-Dykun deleted the ED-20000-internal-automatically-create-a-revert-pr branch July 14, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants