Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooling update and WPCS cleanup #1016

Merged
merged 123 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
014f7a4
Add license info and meta data
kasparsd Jul 11, 2019
e4b4f6a
Validate composer.json during linting
kasparsd Jul 11, 2019
7f42edd
Use standard naming to ensure phpcs can find it
kasparsd Jul 11, 2019
1b831ee
Add helpers for running the linter
kasparsd Jul 11, 2019
c8667cd
Automatic WPCS fixes
kasparsd Jul 11, 2019
94f0bcf
Exclude node modules
kasparsd Jul 11, 2019
cfc447a
Exclude a few for now
kasparsd Jul 11, 2019
c2ca650
Remove unused
kasparsd Jul 11, 2019
2cd3954
Skip these for now
kasparsd Jul 11, 2019
dc1909b
This too
kasparsd Jul 11, 2019
a158b41
Optimize the autoloader
kasparsd Jul 11, 2019
ded8b5b
Lint using local tools instead
kasparsd Jul 11, 2019
a7cfe1d
Switch to eslint to match WP core
kasparsd Jul 11, 2019
fb048c0
Format per WPCS
kasparsd Jul 11, 2019
16de83d
Use eslint instead
kasparsd Jul 11, 2019
0273030
Update deps
kasparsd Jul 11, 2019
985193a
Unused
kasparsd Jul 11, 2019
1dc7cdb
Stick to legacy for now
kasparsd Jul 11, 2019
d363b5e
Add a basic dev environment
kasparsd Jul 11, 2019
c9bb5d0
Ingore the local Vagrant ref
kasparsd Jul 11, 2019
7418f50
And the console output
kasparsd Jul 11, 2019
a7ea87e
Remove duplicates
kasparsd Jul 11, 2019
dec86ed
Not used for now
kasparsd Jul 11, 2019
05d926f
Fake PHP platform to ensure deps match
kasparsd Jul 11, 2019
1be1d55
eslint —fix automatically
kasparsd Jul 11, 2019
ea73054
Ignore the build directory
kasparsd Jul 11, 2019
daa5835
Cleanup comments
kasparsd Jul 11, 2019
70a3dca
Set global
kasparsd Jul 11, 2019
d289291
Rename to avoid matching another var
kasparsd Jul 11, 2019
c328da9
Warn for now
kasparsd Jul 11, 2019
cc65c60
jQuery from global
kasparsd Jul 11, 2019
e1a4739
Strict per eslint
kasparsd Jul 11, 2019
74c9531
Define globals
kasparsd Jul 11, 2019
d52b758
Avoid local shadows
kasparsd Jul 11, 2019
5440d91
Scope local references
kasparsd Jul 11, 2019
c0cb1ae
Better slogan
kasparsd Jul 11, 2019
c0b1f0d
Stick to underscores for now
kasparsd Jul 11, 2019
7995254
Only warn about comments
kasparsd Jul 11, 2019
80541db
Specify a version
kasparsd Jul 11, 2019
77e0c8f
Load in header for now
kasparsd Jul 11, 2019
15feef4
Specify the versions
kasparsd Jul 11, 2019
ea5e50f
Allow local overrides
kasparsd Jul 11, 2019
5a1f7f6
Ignore phpcs warnings for now
kasparsd Jul 11, 2019
611855b
Remove since not used
kasparsd Jul 11, 2019
1f5565c
Add test reporting
kasparsd Jul 11, 2019
386fd7b
Exclude libraries
kasparsd Jul 11, 2019
22175a5
Include wp-cli deps for tests
kasparsd Jul 11, 2019
2b00e0c
Help resolve deps
kasparsd Jul 11, 2019
d3d36ef
Include core phpunit deps
kasparsd Jul 11, 2019
00d1e47
Introduce local config file for unit tests
kasparsd Jul 11, 2019
9a4351d
Build our custom image
kasparsd Jul 11, 2019
62b0c3c
Add helpers
kasparsd Jul 11, 2019
69853a7
Add commands to work with dev env
kasparsd Jul 11, 2019
61ad701
Put in the root instead
kasparsd Jul 11, 2019
c5f8ecc
Reference the source directory which is always available
kasparsd Jul 11, 2019
ff91dc4
Cleanup bootstrap
kasparsd Jul 11, 2019
1335904
Fix references
kasparsd Jul 11, 2019
2b69a0d
Add a helper for running phpunit
kasparsd Jul 11, 2019
b316947
Match the rest of includes
kasparsd Jul 11, 2019
7c2d6db
Revert "Match the rest of includes"
kasparsd Jul 11, 2019
0633063
This is the default… maybe
kasparsd Jul 11, 2019
d7c1614
Setup the site on the first go
kasparsd Jul 11, 2019
25e4ab1
PHPunit does this for us
kasparsd Jul 11, 2019
eb35bd1
Ensure Apache can write to the filesystem.
kasparsd Jul 11, 2019
9c7dcd7
Remove for now
kasparsd Jul 11, 2019
c8c9f77
Introduce a command instead
kasparsd Jul 11, 2019
844a770
Include additional files for coverage reporting
kasparsd Jul 11, 2019
28bf5ee
Sort things
kasparsd Jul 11, 2019
ea8e490
Do include
kasparsd Jul 11, 2019
e55368e
Secify what we have
kasparsd Jul 11, 2019
0d98b38
Add a reminder for now
kasparsd Jul 11, 2019
32d155d
Comment out for now
kasparsd Jul 11, 2019
9648edc
Prepare for bright future
kasparsd Jul 11, 2019
ffb6ce9
Exclude the CLI command for now
kasparsd Jul 11, 2019
08152e3
Exclude feeds that output things
kasparsd Jul 11, 2019
0e58bb0
Do opt-in for clarity
kasparsd Jul 11, 2019
920f6f5
Enable reporting
kasparsd Jul 11, 2019
3ca8474
Remove the capture all
kasparsd Jul 11, 2019
642347a
Not needed for the plugin, yet
kasparsd Jul 11, 2019
a17bdb8
Always run the test report
kasparsd Jul 11, 2019
290c707
Revert "Always run the test report"
kasparsd Jul 11, 2019
4b8399a
Debug PHPunit report
kasparsd Jul 11, 2019
145d6bc
Run unit tests inside docker container
kasparsd Jul 11, 2019
e4cce21
Temp hide versions for quicker debugging
kasparsd Jul 11, 2019
356d105
Don’t use dev-lib
kasparsd Jul 11, 2019
9ffdcb9
Don’t assume a container is up
kasparsd Jul 11, 2019
0298539
Ensure we have the test db too
kasparsd Jul 11, 2019
b44df66
Always restart
kasparsd Jul 11, 2019
ed73ff9
Introduce native commands
kasparsd Jul 11, 2019
37e50e6
No need to change dir
kasparsd Jul 11, 2019
5b2b73d
Assume the containers are running
kasparsd Jul 11, 2019
6942f3e
Use the new commands
kasparsd Jul 11, 2019
c488838
Stick with dev-lib for now
kasparsd Jul 11, 2019
041be90
Debug reports
kasparsd Jul 11, 2019
0d992e8
Lock to avoid config changes with updates
kasparsd Jul 11, 2019
a47049c
Debug phpunit
kasparsd Jul 11, 2019
22d6c48
Spacing
kasparsd Jul 11, 2019
b0e990f
Enable mysql service
kasparsd Jul 11, 2019
87de069
Use the docker runners for unit tests
kasparsd Jul 11, 2019
18f35ca
Remove debugging info
kasparsd Jul 11, 2019
3330cde
Include debugging information
kasparsd Jul 11, 2019
618326d
Add dev-lib as a Composer dep
kasparsd Jul 11, 2019
81310ca
Match recomendations
kasparsd Jul 11, 2019
c4141e4
Debug the working directory
kasparsd Jul 11, 2019
d84c6a9
Require Git for things
kasparsd Jul 11, 2019
20dc41f
Use docker everywhere
kasparsd Jul 11, 2019
903d136
Debug local environment vars
kasparsd Jul 11, 2019
101869c
Add back for readme purposes
kasparsd Jul 11, 2019
56d0a7b
Haha, too much composer in my life
kasparsd Jul 11, 2019
474be37
Ensure the uploads directory exists
kasparsd Jul 11, 2019
37d825d
Explain why we need the dir
kasparsd Jul 11, 2019
aef4432
Didn’t help
kasparsd Jul 11, 2019
a44ea55
Run the init check just once
kasparsd Jul 11, 2019
94471c3
Add a reminder
kasparsd Jul 11, 2019
2f3cc4f
Describe what these do
kasparsd Jul 11, 2019
de84526
Stick to the current setup for now
kasparsd Jul 12, 2019
a6b6caa
Remove leftovers
kasparsd Jul 12, 2019
befc71c
Try another way
kasparsd Jul 12, 2019
9bb66a5
Document the local setup
kasparsd Jul 12, 2019
5575207
Introduce a dedicated readme for devs
kasparsd Jul 12, 2019
e28fdbe
Mention specific things
kasparsd Jul 12, 2019
ecdc55d
Documentation first
kasparsd Jul 12, 2019
22726f4
Move to the right spot
kasparsd Jul 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .codeclimate.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage_clover: tests/reports/clover.xml
json_path: tests/reports/coveralls-upload.json
service_name: travis-ci
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/ui/lib/
**/*.min.js
/vendor/
/node_modules/
/build/
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switch to eslint.

"env": {
"browser": true
},
"extends": [
"plugin:@wordpress/eslint-plugin/es5"
],
"rules": {
"camelcase": "off",
"no-alert": "off",
"vars-on-top": "warn"
}
}
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
.DS_Store
/node_modules/
/vendor/
npm-debug.log
package.lock

# Grunt
/build/
/node_modules/
/.vagrant/
/console.log
/phpcs.xml
npm-debug.log
package.lock

# Compiled files
ui/js/*.min.js
Expand Down
12 changes: 0 additions & 12 deletions .jscsrc

This file was deleted.

4 changes: 0 additions & 4 deletions .jshintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .jshintrc

This file was deleted.

4 changes: 0 additions & 4 deletions .mailmap

This file was deleted.

21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
dist: xenial

language:
- php
- node_js

php:
- 5.6
- 7.0
- 7.2
- 7.3
- "5.6"
- "7.0"
- "7.2"
- "7.3"

addons:
apt:
Expand All @@ -19,13 +21,18 @@ env:
- WP_VERSION=trunk WP_MULTISITE=0
- WP_VERSION=trunk WP_MULTISITE=1

services:
- mysql

install:
- npm install
- export DEV_LIB_PATH=node_modules/wp-dev-lib/scripts
- source $DEV_LIB_PATH/travis.install.sh
- export DEV_LIB_PATH="vendor/xwp/wp-dev-lib/scripts"
- export DEV_LIB_ONLY="phpunit"
- source "$DEV_LIB_PATH/travis.install.sh"

script:
- source $DEV_LIB_PATH/travis.script.sh
- npm run lint
- source "$DEV_LIB_PATH/travis.script.sh"

after_script:
- source $DEV_LIB_PATH/travis.after_script.sh
Expand Down
90 changes: 30 additions & 60 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
/* eslint-env node */
/* jshint node:true */

module.exports = function( grunt ) {
'use strict';

grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),

// JavaScript linting with JSHint.
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: ['Gruntfile.js', 'ui/js/*.js', '!ui/js/*.min.js']
},

// Minify .js files.
uglify: {
options: {
preserveComments: false
preserveComments: false,
},
core: {
files: [
{
expand: true,
cwd: 'ui/js/',
src: ['*.js', '!*.min.js'],
src: [ '*.js', '!*.min.js' ],
dest: 'ui/js/',
ext: '.min.js'
}
]
ext: '.min.js',
},
],
},
alerts: {
files: [
{
expand: true,
cwd: 'alerts/js/',
src: ['*.js', '!*.min.js'],
src: [ '*.js', '!*.min.js' ],
dest: 'alerts/js/',
ext: '.min.js'
}
]
}
ext: '.min.js',
},
],
},
},

// Minify .css files.
Expand All @@ -51,12 +42,12 @@ module.exports = function( grunt ) {
{
expand: true,
cwd: 'ui/css/',
src: ['*.css', '!*.min.css'],
src: [ '*.css', '!*.min.css' ],
dest: 'ui/css/',
ext: '.min.css'
}
]
}
ext: '.min.css',
},
],
},
},

// Build a deploy-able plugin
Expand All @@ -72,40 +63,23 @@ module.exports = function( grunt ) {
'includes/**',
'ui/**',
'languages/*',
'readme.txt'
'readme.md',
],
dest: 'build',
expand: true,
dot: true
}
dot: true,
},
readme: {
src: 'readme.txt.md',
dest: 'build/readme.txt',
},
},

// Clean up the build
clean: {
build: {
src: ['build']
}
},

// VVV (Varying Vagrant Vagrants) Paths
vvv: {
plugin: '/srv/www/wordpress-develop/public_html/src/wp-content/plugins/stream',
coverage: '/srv/www/default/coverage/stream'
},

// Shell actions
shell: {
options: {
stdout: true,
stderr: true
},
phpunit: {
command: 'vagrant ssh -c "cd <%= vvv.plugin %> && phpunit"'
src: [ 'build' ],
},
phpunit_c: {
command:
'vagrant ssh -c "cd <%= vvv.plugin %> && phpunit --coverage-html <%= vvv.coverage %>"'
}
},

// Deploys a git Repo to the WordPress SVN repo
Expand All @@ -115,25 +89,21 @@ module.exports = function( grunt ) {
plugin_slug: 'stream',
plugin_main_file: 'stream.php',
build_dir: 'build',
assets_dir: 'assets'
}
}
}
assets_dir: 'assets',
},
},
},
} );

// Load tasks
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-shell' );
grunt.loadNpmTasks( 'grunt-wp-deploy' );

// Register tasks
grunt.registerTask( 'default', ['jshint', 'uglify', 'cssmin'] );
grunt.registerTask( 'phpunit', ['shell:phpunit'] );
grunt.registerTask( 'phpunit_c', ['shell:phpunit_c'] );
grunt.registerTask( 'build', ['default', 'copy'] );
grunt.registerTask( 'deploy', ['build', 'wp_deploy', 'clean'] );
grunt.registerTask( 'default', [ 'uglify', 'cssmin' ] );
grunt.registerTask( 'build', [ 'default', 'copy' ] );
grunt.registerTask( 'deploy', [ 'build', 'wp_deploy', 'clean' ] );
};
21 changes: 21 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load File.join(
File.dirname(__FILE__),
"vendor/wpsh/local/Vagrantfile"
)

Vagrant.configure(2) do |config|
config.vm.hostname = "stream"

# Wait 10 seconds before the docker containers are up.
config.vm.provision "shell",
inline: "sleep 10",
run: "always"

# Setup the WP sites.
config.vm.provision "shell",
path: "local/vagrant/setup-wp.sh",
run: "always",
env: {
"DOCKER_COMPOSE_FILE" => "/vagrant/docker-compose.yml"
}
end
Loading