From: Timo Tijhof Date: Wed, 23 Jan 2019 23:51:49 +0000 (-0800) Subject: build: Use headless Chrome and Firefox for QUnit testing X-Git-Tag: 1.34.0-rc.0~2862 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=d056d4c273a069d572ceb2160346ee697d7b87de;p=lhc%2Fweb%2Fwiklou.git build: Use headless Chrome and Firefox for QUnit testing Also: * Remove "watch" task from Gruntfile. This wasn't exposed via npm-run and afaik rarely if ever used. It seems mostly obsoleted by modern editors which perform linting and style guidance as-you-type and on-save. * Remove "chromium" target from karma config, the default target supports both Chromium and Chrome. * Remove unused "default" alias in Gruntfile. Was only accessible if developers installed grunt-cli globally, which we don't require and shouldn't encourage. The new minify task is now exposed as "npm run build". * Remove "test" alias in Gruntfile. Was only used by "npm run test", which now uses "grunt lint" directly, which makes it more clear that these are only linters, and not unit tests. This references T211784 because ensuring no headed browsers are used (which would need Xvfb to start), is a prerequisite for the new Node 10 images. We may still need to provide a slower Xvfb-wrapped variant for some repos, but would be nice of mw-core wasn't one of them. Bug: T211784 Change-Id: I270a16d2b4f799ac7c9f84e9e2ee23806bdbc57e --- diff --git a/Gruntfile.js b/Gruntfile.js index fdbf0efbc5..2592815659 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,7 +8,6 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-contrib-copy' ); - grunt.loadNpmTasks( 'grunt-contrib-watch' ); grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-karma' ); @@ -103,6 +102,18 @@ module.exports = function ( grunt ) { }, karma: { options: { + customLaunchers: { + ChromeCustom: { + base: 'ChromeHeadless', + // Chrome requires --no-sandbox in Docker/CI. + // Newer CI images expose CHROMIUM_FLAGS which sets this (and + // anything else it might need) automatically. Older CI images, + // (including Quibble for MW) don't set it yet. + flags: ( process.env.CHROMIUM_FLAGS || + ( process.env.ZUUL_PROJECT ? '--no-sandbox' : '' ) + ).split( ' ' ) + } + }, proxies: karmaProxy, files: [ { pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export', @@ -122,13 +133,10 @@ module.exports = function ( grunt ) { crossOriginAttribute: false }, main: { - browsers: [ 'Chrome' ] - }, - chromium: { - browsers: [ 'Chromium' ] + browsers: [ 'ChromeCustom' ] }, firefox: { - browsers: [ 'Firefox' ] + browsers: [ 'FirefoxHeadless' ] } }, copy: { @@ -159,7 +167,4 @@ module.exports = function ( grunt ) { grunt.registerTask( 'minify', 'svgmin' ); grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] ); grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] ); - - grunt.registerTask( 'test', [ 'lint' ] ); - grunt.registerTask( 'default', [ 'minify', 'test' ] ); }; diff --git a/package.json b/package.json index 3ab6b0c4ae..387e74eaee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "private": true, "scripts": { - "test": "grunt test", + "build": "grunt minify", + "test": "grunt lint", "qunit": "grunt qunit", "doc": "jsduck", "postdoc": "grunt copy:jsduck",