#2542 closed task (blessed) (fixed)
Modernize trunk with Unit Tests, Travis, and Grunt
Reported by: | johnjamesjacoby | Owned by: | |
---|---|---|---|
Milestone: | 2.6 | Priority: | high |
Severity: | normal | Version: | 2.0 |
Component: | Tools - Code Improvements | Keywords: | |
Cc: | aaron@… |
Description (last modified by )
As we start to consider making relatively large changes in queries and tools, we would greatly benefit from having unit tests going forward. Some tickets in upcoming milestones are introducing somewhat monolithic patches that are scary to apply without knowing backwards compatibility can be guaranteed.
Thinking we can clean up what's already been done in BuddyPress, implement it into /trunk
for our current development cycle, and continue improving our test coverage over several releases.
We should also introduce Grunt, Travis, and a stub plugin to help existing trunk installations still function.
Attachments (20)
Change History (100)
#2
@
11 years ago
Initial patch forks BuddyPress PHPUnit
Renamed all the things: BP -> BBP | BuddyPress -> bbPress | bp -> bbp etc
testcase.php and factory.php now needs customizing for bbPress and removal of BuddyPress bits.
#3
@
11 years ago
Patch 2542.2.diff goes down an alternate route and comes via @tierra/@bpetty
https://github.com/tierra/wordpress-plugin-tests (Jetpack also use this in their GitHub repo)
#4
follow-up:
↓ 5
@
11 years ago
The alternate route is a good start. We'll want to write our own installers and tests that are unlikely to be very similar to BuddyPress's at all, considering we're not creating our own tables and such.
We could even go as far as filtering our option values so they don't need to be added to the DB, helping us maintain the environment state across multiple tests if we needed to.
Lots of neat directions our tests can go.
#5
in reply to:
↑ 4
@
11 years ago
Replying to johnjamesjacoby:
The alternate route is a good start. We'll want to write our own installers and tests that are unlikely to be very similar to BuddyPress's at all, considering we're not creating our own tables and such.
We could even go as far as filtering our option values so they don't need to be added to the DB, helping us maintain the environment state across multiple tests if we needed to.
Lots of neat directions our tests can go.
Yes, that all sounds the way to go.
No idea really what I'm doing here besides a general familiarity with PHPUnit and looking at other examples from WP projects such as WP Core, WP-CLI, WP-API, BuddyPress, Jetpack etc for ideas and best practices.
Also as per Boone's info on #buddypress4889 we should be able to bootstrap BP's tests when needed:
Usable by external BP projects (themes, plugins, entire website projects). Say you're building a BuddyPress-dependent plugin, and you want to write unit tests. You'll want two things: that BP is up and running when your tests run (so you'll have access to BP settings, BP functions, BP database tables, etc), and that you have access to BP's testing tools (BP_UnitTestCase, BP's data factories).
#6
@
11 years ago
In 2542.3.diff
- Brings in 'non specific' BuddyPress bits and pieces
- Sets up the structure/layout of the base PHPUnit config for bbPress.
(Doesn't really actually 'do' anything more than the prev patch, architectural changes only)
#7
@
11 years ago
Good progress. The patch still includes some renamed BuddyPress bits that won't apply. If it's any easier, we can start with the simple version, and bolt the BuddyPress bootstrap code into it.
#8
@
11 years ago
In 2542.4.diff, same as 2542.2.diff with a few minor fixes/tweaks
- Tests to be run have a prefix
bbp_
and suffix.php
in the folder/tests/testcases/
#14
@
11 years ago
- Description modified (diff)
- Priority changed from normal to high
- Summary changed from Unit Tests to Modernize trunk with Unit Tests, Travis, and Grunt
- Type changed from defect to task
#26
@
11 years ago
In 2542.5.diff:
- Fixes CSS & JS admin folder path for
BBP_RTL_CSS
,BBP_LTR_CSS
&BBP_JS
in Gruntfile.js - Removes Mint & Evergreen CSS (including RTL) to use Mint & Evergreen SCSS
- Adds
_admin.scss
,_mixins.scss
,_variables.scss
via (/trunk/src/wp-admin/css/colors) to build our Mint & Evergreen admin themes - Adds
/includes/admin/styles/evergreen/colors.scss
&/includes/admin/styles/mint/colors.scss
via MP6 GitHub Repo Changset 2288dcd5b5 - Adds support in Gruntfile.js to build minified and RTL Mint & Evergreen CSS
- Adds
grunt-sass
~0.10.0
topackage.json
to build Mint & Evergreen CSS from SCSS source - Reinstates minified and
SCRIPT_DEBUG
support for minified Mint & Evergreen CSS - Adds minified and
SCRIPT_DEBUG
support for admin javascript & frontend javascript
@ToDo Test RTL CSS generated by cssjanus
, remove RTL CSS stylesheets and update bbpress-functions.php
including minified and SCRIPT_DEBUG
support for front end CSS.
#29
@
11 years ago
In 2542.6.diff:
- Add RTL, minified and
SCRIPT_DEBUG
support for bbPress admin CSS. - RTL bbPress CSS is now compiled with
cssjanus
. (bbpress-rtl.css
file removed) - Add RTL, minified and
SCRIPT_DEBUG
support for bbPress CSS.
#30
@
11 years ago
In 2542.7.diff:
- Adds
grunt-pot
topackage.json
- Adds grunt task
pot
togrunt build
andgrunt build-release
- Creates
bbpress.pot
in/build
- Checks for string keywords
esc_attr__
,esc_attr_e
,esc_attr_x
,esc_html__
,esc_html_e
,esc_html_x
and_nx_noop
. Did I miss any?
See this re: empty pot file created https://github.com/stephenharris/grunt-pot/issues/2 (brew install gettext
)
It doesn't quite work for me as I'm having trouble installing the gettext
dependency in Windows, other than that it appears to work. I was testing it with a dest: BUILD_DIR _ 'pot/',
but I only ever got an empty file :(
If it works cool :)
#31
@
11 years ago
In 2542.8.diff:
- Fixes PHPUnit Multisite Tests
- Fixes
grunt build-realease
to run all PHPUnit tests when building release package (Single & Multisite)
To run all PHPUnit tests at once use the grunt phpunit
or grunt test
GruntJS tasks.
#32
@
11 years ago
In 2542.9.diff:
- Add XML output logging for PHPUnit Tests
- SVN:Ignore the
\tests\phpunit\build\*
directory/sub-directories
#37
@
11 years ago
In 2542.10.diff:
- Add
_n_noop
togrunt-pot
keyword check - Remove grunt task
test
as PHPUnit tests are covered by grunt taskphpunit
- Add grunt task
jstest
to run javascript tasks - Add
grunt-checktextdomain
topackage.json
to check for missing or incorrect text-domain in gettext functions. See https://www.npmjs.org/package/grunt-checktextdomain - Adds grunt task
checktextdomain
togrunt build-release
- Checks for the following keywords:
__:1,2d
,_e:1,2d
,_x:1,2c,3d
,_n:1,2,4d
,_ex:1,2c,3d
,_nx:1,2,4c,5d
,esc_attr__:1,2d
,esc_attr_e:1,2d
,esc_attr_x:1,2c,3d
,esc_html__:1,2d
,esc_html_e:1,2d
,esc_html_x:1,2c,3d
,_n_noop:1,2,3d
,_nx_noop:1,2,3c,4d
#40
@
11 years ago
In 2452.12.diff:
- Switch from
grunt-pot
togrunt-wp-i18n
- Removes difficult to install gettext/xgettext dependency on Windows
The 2452.12 patch works and creates bbpress.pot
in /build/bbpress.pot
I don't think it's the most eloquent configuration and before commiting will await for some feedback on the GitHub issue I raised here https://github.com/blazersix/grunt-wp-i18n/issues/5
#43
@
11 years ago
In 2542.13.diff
Setup travis-ci
- Uses WordPress Git 'develop repo' git://develop.git.wordpress.org/
- Tests WordPress 3.7.1, 3.8.1 and /trunk (master)
- 3.7.x and up require the new unit tests in the 'develop' repo
- 3.6.x and below require the old unit tests repo http://unit-tests.svn.wordpress.org/trunk/
- Switch from WP_CORE_DIR to WP_DEVELOP_DIR for compat with bbPress PHPUnit
bootstrap.php
- Uses
npm install -g grunt-cli
to install globalgrunt-cli
task runner - Uses
npm intsall
to install NodeJS dependencies - Uses
grunt build
to build bbPress - Add
grunt travis
Grunt task toGruntfile.js
- Uses
grunt travis
to run the PHPUnit tests on travis-ci
Things are pretty close here for this to go in ToDo:
- MySQL mysql_connect/mysqli in PHP 5.5 [WP27250]
- See what @djpaul comes up with [BuddyPress8017]
#44
follow-ups:
↓ 45
↓ 55
@
11 years ago
grunt-wp-i18n
spits out a ton of notices for me, but appears to compile the bbpress.pot
file fine enough. Wonder if there's anything we can contribute upstream.
#45
in reply to:
↑ 44
@
11 years ago
Replying to johnjamesjacoby:
grunt-wp-i18n
spits out a ton of notices for me, but appears to compile thebbpress.pot
file fine enough. Wonder if there's anything we can contribute upstream.
I noticed these Sunday whilst messing about with travis-ci.
A quick review of the latest travis-ci build https://travis-ci.org/ntwb/bbPress/builds/19937003
- PHP 5.2 & 5.3 do not spit out the notices
- PHP 5.4 & 5.5 do.
Upstream is error_reporting(E_ALL);
http://i18n.trac.wordpress.org/browser/tools/trunk/add-textdomain.php#L10
http://i18n.trac.wordpress.org/browser/tools/trunk/not-gettexted.php#L229
#46
@
11 years ago
In 2542.14.diff:
- Remove
src/includes/admin/images/index.php
- Remove
src/includes/admin/images/
folder
We're not keeping this for any particular reason are we?
#47
@
11 years ago
In 2542.15.diff:
- Add
BBP_EXCLUDED_FILES
togrunt copy:files
task to exclude files/folders inBBP_EXCLUDED_FILES
being copied to/build
duringgrunt build
andgrunt build-release
tasks - Add
!**/*.scss
toBBP_EXCLUDED_FILES
list (colors
task usesSRC
to create Evergreen and Mint CSS)
#48
@
11 years ago
RE: 2542.15.diff: We have no need for the *.scss files in the /build folder , I think?
(WP Core does as there are plugins that use the *.scss files to create new custom admin themes)
#49
follow-up:
↓ 52
@
11 years ago
I went through audited the r868674 commit to wp.org /trunk repo to check what is or isn't there what should or should not be there.
This is how 2542.14.diff and 2542.15.diff came about, aside from these two issues it looks pretty good to me. :)
Was the resulting bbpress.pot
source compiled from the grunt build-release
task or manually with makebot
?
Trying to ascertain how it ended up with "Last-Translator: JOHN JAMES JACOBY <JJJ@BBPRESS.ORG>\n"
;)
#53
in reply to:
↑ 52
@
11 years ago
Replying to johnjamesjacoby:
Replying to netweb:
Was the resulting
bbpress.pot
source compiled from thegrunt build-release
task or manually withmakebot
?
It was done from
grunt build-release
and I manually editedbbpress.pot
to add my contact info. Happy to put yours (or anyone else's there) if you'd like. ;)
Cool, I thought/hoped you had made some magical ponies insert it for you ;)
#55
in reply to:
↑ 44
@
10 years ago
Replying to johnjamesjacoby:
grunt-wp-i18n
spits out a ton of notices for me, but appears to compile thebbpress.pot
file fine enough. Wonder if there's anything we can contribute upstream.
grunt-wp-i18n
v0.4.1 Update looks to have addressed this.
That said, I'm not seeing these errors on the Travis CI tests anymore whilst still using v0.4.0
Either or, updating to the latest grunt-wp-i18n
v0.4.2 now.
#57
@
10 years ago
Patching from the command line using grunt patch
Have a diff or a patch file in your working Directory, then run grunt patch
.
If multiple files are found, you'll be asked which one to apply.
Enter a ticket number, e.g. grunt patch:15705
Enter a ticket url, e.g. grunt patch:https://core.trac.wordpress.org/ticket/15705
Enter a patch url, e.g. grunt patch:https://core.trac.wordpress.org/attachment/ticket/11817/13711.diff
#58
follow-up:
↓ 59
@
10 years ago
- Cc aaron@… added
RE: grunt-patch-wordpress. If anyone has any issues running it, feel free to let me know. You can run it with the debug flag and it will give a lot of info that can help with debugging if you do come across any issues. There is a bit of WordPress specific code based on the fact that patches for that are still accepted from http://core.svn.wordpress.org/trunk/ in addition to http://develop.svn.wordpress.org/ and I don't know if it will cause conflicts.
#59
in reply to:
↑ 58
@
10 years ago
Replying to jorbin:
RE: grunt-patch-wordpress. If anyone has any issues running it, feel free to let me know. You can run it with the debug flag and it will give a lot of info that can help with debugging if you do come across any issues. There is a bit of WordPress specific code based on the fact that patches for that are still accepted from http://core.svn.wordpress.org/trunk/ in addition to http://develop.svn.wordpress.org/ and I don't know if it will cause conflicts.
Thanks, will keep an eye on it, we should be quite similar in that we are also using /src
and /build
and any older patches not using /src
should behave similar to WordPress core.svn patches.
I added a couple of extra patches to #2537 for a bit of testing fun, grunt patch:2537
#60
@
10 years ago
In 5327:
Edit: Removed personal details, couldn't stop them being hyperlinked
Edit2: That didn't work but the diff says it did :/
#65
@
10 years ago
We should have a readme.txt/readme.md/README file in the root of the repo explaining the repo setup:
- Install instructions Node.js
- Install instructions Grunt-CLI
- Instructions to create the bbPress
/build
- Overview of all the available Grunt tasks
- Instructions to create a release a package for plugins.trac.wordpress.org repo
Maybe add /assets
folder for WP plugin repo assets plugins.trac.wordpress.org/browser/bbpress/assets
#66
@
10 years ago
Completely agree about all-of-the-things, except for the assets (they don't change very much, so I'm fine with them being manually curated for the time being.)
#68
@
10 years ago
In README.md.patch
first pass of a README.md for the root of the repo
Preview in markdown here https://cloudup.com/cJToaYJb7We
#70
@
10 years ago
The latest Travis CI build https://travis-ci.org/ntwb/bbPress/builds/24447073
In 2542.travis.yml.diff
- WordPress versions tested: 3.7.3, 3.8.3, 3.9.0(3.9) and master (/trunk)
- PHP 5.2, 5.3, 5.4, 5.5 & 5.6 beta (5.6 is allowed to fail)
- Exludes PHP 5.5 WP 3.7.3 build combination that will always fail due to mysqli
- Uses
grunt phpunit
to include single and multisite tests- (Previously a separate VM instances were spawned for each test in the matrix)
- Uses
git clone --depth=50
as a 'shallow clone' to improve performance of WP's develop repo
#73
@
10 years ago
In 2542.travis.yml.2.diff updates 2542.travis.yml.diff detailes per #comment:70 with:
- Added Grunt task
grunt travis
to runjshint
andphpunit
tasks on Travis CI
#75
@
10 years ago
Summary of outstanding issues to be able to close those ticket:
- Point GlotPress to
bbpress.pot
at https://plugins.trac.wordpress.org/browser/bbpress/ - Update
.travis.yml
(complete, patch incoming) - Configure git-svn mirror at https://github.com/bbpress
- Add/edit/update README.md /ticket/2542/README.md.patch
#76
@
10 years ago
In 2542.travis.yml.3.diff:
- Switch to a 'shallow' Git clone of the official WordPress Git repo for faster WordPress upstream checkout, timings below
- The addition of the
fast_finish: true
flag in the build matrix will mark the buildpassed
orerrored
as soon as a single build job has failed. Previously the build status was not reported until ALL tests had completed regardless of status.
- Moves the 'build configuration' to
before_install
allowing non-bbPress test configuration to report aserrored
(MySQL database creation, and WordPress Git checkout etc). When a failure occurs in this section the build is marked as errored which is a more accurate description in that the environment we are setting up has failed and not the actual bbPress tests we are testing.
- Introduces PHP 5.6 and HHVM testing into the build matrix, both of these are allowed to fail in that they will not be included in the overall build job failed, errored, or passed build status. This allows bbPress testing to play nice with these alpha/beta version of PHP/HHVM until stable and officially released.
- wget http://wordpress.org/latest.tar.gz -OutFile ./wordpress.tar.gz (Only 'core, not dev repo)
- Avg ~15 seconds (WordPress core only, no tests or tools folder)
- wget https://github.com/wordpress/wordpress/archive/master.zip -OutFile ./wordpress-gh.tar.gz
- Avg ~55 seconds
- svn co --ignore-externals https://develop.svn.wordpress.org/tags/3.9 svn-tag39
- Avg ~70 seconds
- git clone --depth=1 --branch="tags/3.9.1" git://develop.git.wordpress.org/ tag39\
- Avg ~30 seconds
http://codex.bbpress.org/developer/automated-testing/