-
Notifications
You must be signed in to change notification settings - Fork 11
/
Gruntfile.js
112 lines (100 loc) · 4.33 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
module.exports = function (grunt) {
var magento2path = '../../../../';
var phpunitXmlPath = __dirname + '/phpunit.xml';
var buildPath = __dirname + '/Build/';
if (grunt.file.isDir('/tmp/magento2/')) {
magento2path = '/tmp/magento2/';
phpunitXmlPath = '/tmp/magento2/vendor/tig/postcode/phpunit.xml.dist';
}
var phpcsCommand = 'php -ddisplay_errors=1 vendor/bin/phpcs -p ' +
'--runtime-set installed_paths ' +
'vendor/squizlabs/php_codesniffer/CodeSniffer/Standards,' +
'vendor/magento/marketplace-eqp,' +
'vendor/object-calisthenics/phpcs-calisthenics-rules/src/ ';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
exec: {
phpcs: phpcsCommand + '--standard=phpcs.xml .',
phpcsTest: phpcsCommand + '--standard=phpcs.test.xml --severity=10 Test',
unitTests: 'cd ' + magento2path + ' && vendor/phpunit/phpunit/phpunit -c "' + phpunitXmlPath + '"',
// No integration test availble yet.
integrationTests:
'cd ' + magento2path + 'dev/tests/integration &&' +
'php -ddisplay_errors=1 ../../../vendor/phpunit/phpunit/phpunit --testsuite "TIG Postcode Integration Tests"',
ciTests:
'cd ' + magento2path + 'dev/tests/integration &&' +
'php -ddisplay_errors=1 ../../../vendor/phpunit/phpunit/phpunit',
phplint: 'if find . -name "*.php" ! -path "./vendor/*" -print0 | xargs -0 -n 1 -P 8 php -l | grep -v "No syntax errors detected"; then exit 1; fi',
codeCoverage:
'mkdir -p ' + buildPath + '/coverage/{unit,integration} && ' +
'cd ' + magento2path + ' && ' +
'vendor/bin/phpunit -c "' + phpunitXmlPath + '" --coverage-html ' + buildPath + '/coverage/unit' +
'cd dev/tests/integration &&' +
'../../../vendor/bin/phpunit --testsuite "TIG Postcode Integration Tests" --coverage-html ' + buildPath + '/coverage/integration'
},
jshint: {
all: [
'view/frontend/web/js/**/*.js',
'view/admihtml/web/js/**/*.js'
]
},
less: {
// css to less files
},
watch: {
// files to watch
}
});
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
/**
* Register the available tasks
*/
grunt.registerTask('lint', 'Lint all PHP al JavaScript files', ['exec:phplint', 'jshint:all']);
grunt.registerTask('phpcs', 'Run the Code Sniffer: For all production code and for the test code', ['exec:phpcs', 'exec:phpcsTest']);
grunt.registerTask('codeCoverage', 'Generate the code coverage report in build', ['exec:codeCoverage']);
grunt.registerTask('runTests', 'Run all available tests: Unit and integration', ['exec:unitTests']); // 'exec:integrationTests'
grunt.registerTask('test', 'Run all code validation check: Unit tests, Code Sniffer, Linting, etc.', [
'phpcs',
'lint',
'runTests'
]);
grunt.registerTask('ci', 'This task is to be meant for running in CI only', [
'phpcs',
'lint',
'exec:ciTests'
]);
grunt.registerTask('default', 'Run the default task (test)', ['test']);
};