wp-github-pull-request-travis-ci-trac-sync
Sync from GitHub Pull Requests to WordPress Trac via Travis CI
This script facilitates contributing to WordPress Core via GitHub Pull Requests. See WordPress Trac #34694.
Caveat: This is intended for users in trusted contributor teams as it requires the user
to open open an internal (intra-repo) pull request from feature branch to master
.
It will not work when opening a pull request from a fork due to Travis CI’s security restrictions
on environment variables. So any pull requests from external contributors will
need to be manually applied to a feature branch by a repo contributor and then
open an intra-repo pull request (while closing the original inter-repo pull request).
Installation
-
Clone the
develop.git.wordpress.org
repo onto GitHub and enable Travis CI for it. See instructions in Contributing to WordPress Core via GitHub. -
Create a bot user on WordPress.org (e.g.
xwp-bot
) and request that theXML_RPC
privilege be granted for that user. - Ensure the patch from Trac #34694 is applied to WordPress Core; if not already upstreamed, make it the first commit to each feature branch.
- Edit the Travis CI settings for your WordPress GitHub clone to add the following environment variables:
-
WP_TRAVISCI_CUSTOM_BEFORE_INSTALL_SRC
: https://raw.githubusercontent.com/xwp/wp-github-pull-request-travis-ci-trac-sync/master/travis.before_install.sh -
WP_TRAVISCI_CUSTOM_SCRIPT_SRC
: https://raw.githubusercontent.com/xwp/wp-github-pull-request-travis-ci-trac-sync/master/travis.script.sh -
WP_TRAVISCI_CUSTOM_AFTER_SCRIPT_SRC
: https://raw.githubusercontent.com/xwp/wp-github-pull-request-travis-ci-trac-sync/master/travis.after_script.sh -
WPORG_USERNAME
: Use the Trac bot user you created. -
WPORG_PASSWORD
: Use password for Trac bot user, and make sure added with “Display value in build log” off.
For more information, see Streamlining Contributions to WordPress Core via GitHub.
Usage
Once configured, a developer with write access to the GitHub repo can contribute to WordPress Core as follows:
- Ensure that a Trac ticket exists.
-
Push commits to a feature branch on GitHub named after the Trac ticket (e.g.
trac-12345
). -
Open pull request to
master
; this must be an internal (intra-repo) pull request, not from a fork (inter-repo). - Watch Travis CI run its tests, and when completed look at Trac to see the patch uploaded.
As a bonus, the changes in the pull request will also have the following checks run:
- Modified PHP files will be checked for syntax errors.
-
PHP changes will be checked with PHP_CodeSniffer against the
WordPress-Core
andWordPress-Docs
standards. -
JS changes will be checked with JSCS against the
wordpress
preset.
Note that if there are no PHP files modified in a pull request, the PHPUnit tests will be skipped altogether, drastically speeding up the build time.
Background
For the initial post that describes the approach, as linked above, see Streamlining Contributions to WordPress Core via GitHub.
For a prior post describing the manual workflow that is being streamlined here, also as linked above, see Contributing to WordPress Core via GitHub.
See also the WordPress Trac #34694: Facilitate automated testing in context of pull requests and diffs.
Credits
Written by Weston Ruter (westonruter), XWP.
The functionality incorporates logic from trac-attach.sh
by Andrew Nacin (nacin) and Michael Adams (mdawaffe).
License GPLv2.