diffs now correctly output errors. This will pick up changes to
index.js and index.js.json that have not been committed
--exit-code is passed to ensure that if there are changes then an
error is thrown and the action is not allowed.
The dist folder became out of date as depending on what version
of node you run, the output is different.
To aid debugging, the script that checks the diff now outputs the
node version and the npm version. From now on, we will all have
to use the same node version to build assets.
This is annoying, but we will re-evaluate the approach we are taking
to build assets in T202743. We can easily work around this by all using
nvm and making consistent use of the same node version.
The assets have been rebuilt with the node version that CI uses.
Bug: T202748
Change-Id: I82aee879d4b04ca06447f95eb81230bfc24d20e9
The script is needed to run the new Docker-based Jenkins job that runs daily and targets beta cluster.
selenium-test script and NPM packages are dependencies. selenium-daily now just calls selenium-test.
selenium-daily might seem redundant, but it provides flexibility. In case a
repository does not want to run all tests daily, that's easily fixed by updating the
selenium-daily script.
Bug: T188742
Change-Id: I35c93ff1897afc4b9e66703a1acf765e3fe7b643
Enabling SVGO automation with 'grunt-svgmin' and conservative
plugin settings to build step, among those:
- enable removeRasterImages and sortAttrs,
- disable cleanupIDs, removeDesc, removeTitle, & removeViewBox as
described in
https://www.mediawiki.org/wiki/Manual:Coding_conventions/SVG#Exemplified_safe_configuration
- disable removeXMLProcInst; if the SVG doesn't start with an XML
declaration, then it's MIME type will be detected as "text/plain"
rather than "image/svg+xml" by libmagic and, consequently, MediaWiki's
CSSMin CSS minifier. libmagic's default database currently requires
that SVGs contain an XML declaration:
<https://github.com/threatstack/libmagic/blob/master/magic/Magdir/sgml#L5>.
- make use of pretty and multipass options.
Settings are stored in a JSON file to be independent of the Grunt build
process. Also updating SVG accordingly.
Bug: T185596
Change-Id: I715ad4cf2e900665e4c32c78b4c2d9d9cebf0222
Whe user moves mouse away and we abort the http request we shouldn't
count that request as a FETCH_FAILED. The reasoning behind is that
FETCH_FAILED state increments the counter.PagePreviewsApiFailure.
Our StatsD graph gets polluted with lots of aborted requests and it
becomes unsuable. It doesn't show only the failed requests.
Changes:
- introduced new state: FETCH_ABORTED
- switch to FETCH_ABORTED when browser aborts the request
Bug: T199482
Change-Id: I58047eb80f0700b78b2991daff9395ecc92553b8
* Force arrow-parens
* Disable no-prototype-builtins for time being
* Drop unnecessary maxlen rule
Change-Id: Iceb0fe47354a5753202d2c6ad9e1a9c76791f744
mw-node-qunit has moved to a new NPM package, @wikimedia/mw-node-qunit.
There are no functional changes with this release but dependencies
should be kept up to date.
https://github.com/wikimedia/mw-node-qunit/blob/9a368a1/CHANGELOG.md#500
Bug: T197251
Change-Id: I25bfc541551cbc29812985df7fa05dc17f0338c5
The tap-dot executable crashes on some test failure outputs.[0] This is
confusing since a test failure in itself often requires debugging. The
issue is present from v1.0.1 to the latest, v2.0.0.
Instead of downgrading, replace tap-dot with the popular
tap-mocha-reporter. This change comes with a bonus: console.log is no
longer filtered out. The benefit cannot be overstated.
[0]: https://github.com/scottcorgan/tap-dot/issues/9
Change-Id: I4ce2d2816885b7c5214f5c1863be595be0d8b1aa
Since it can be unexpected for a pre-commit hook to make edits to the
commit, leverage the existing tests to simply verify that the proper
files have been staged. This also slightly simplifies the existing NPM
scripts and forces the dev to run the same test about to be executed CI,
`npm test` itself, which previously had no other automation tie in.
Change-Id: I74e407ea17a6c2809a49ba56d3ef28b25d5ba5de
The `doc:start` NPM script simply runs the `doc` script whenever a
change is detected. It doesn't seem especially useful for standard
development and adds an extra nodemon depedency. This patch removes the
script and nodemon.
Change-Id: Ib679f6d83bd10f0b8d1572c07080fba7f8d6a701
Replace Istanbul with nyc, Istanbul's CLI. nyc appears to have some
bugs that this patch works around:
- When all files in the project are considered, not just those
imported via tests, the coverage rates and line numbers vary between
runs. This patch disables the `all` option for now and points to the
bug:
https://github.com/istanbuljs/nyc/issues/537#issuecomment-390814662.
- Source map line numbers appear to be incorrect except when `all` is
enabled and working correctly (see previous bullet).
- `sourceMap` must be disabled to avoid ENAMETOOLONG errors when nyc
tries to include them as encoded strings. The patch disables the
setting and points to: https://github.com/istanbuljs/nyc/issues/847.
Using babel-plugin-istanbul and source-map-support appears to have
no effect (the former in tests/node-qunit/run.js and .babelrc).
- CI fails with
`Error: EACCES: permission denied, mkdir '/nonexistent'`. Specify
`SPAWN_WRAP_SHIM_ROOT` instead of constructing a subdirectory from a
nonexistent home directory.
Bug: T196952
Bug: T193519
Change-Id: Idf2e3accd4a6277cbef91c1156fcd206c9e7d882
The invocation of `rm -rf resources/dist` in package.json
(`check-built-assets`) is replaced with clean-webpack-plugin.
The benefit of this change is that calling `npm run build` now works the
same as the `check-built-assets` script.
Bug: T193522
Change-Id: I64f048855ddceb7159279671b2174a7937e169ff
* https://github.com/joakin/mw-node-qunit/blob/master/CHANGELOG.md#400
* Rely on the CLI runner from qunit
* Fix testing require and global mediaWiki not asserting anything
The test numbers is not reported by test, instead of by assertion like
it was before because the official qunit tap reporter does that. But the
numbers are correct.
Change-Id: I38d4b5007902ecbef2e2007966fafc4bb88703f6
40kb seems a good time to pause and reflect on the total size.
The current maximum is impossible to meet without no further
changes to the code.
12kb is also more flexible than 11.5
Change-Id: I5ee8c236d90542afacc0e8de513a45a15ccd529b
In I7395e3438836149becdd576942bdaf6f21b4163f the settings templates
were rewritten so that they no longer displayed an image.
descriptionText and images were dropped from the template but not from
the template provider. These are artifacts from relating to that patch
and are no longer used.
Change-Id: I1be7ef288d37f338e83dab3cf041e628a06608d2
When resources/dist was removed or modified, the diff check erroneously
complained that the resources differed. This could be resolved by simply
running the tests again. This patch fixes the issue by leveraging Git to
do the diffs which eliminates the need for a temporary test-build
directory and has the side-effect of improving the grep experience for
the repo.
Change-Id: Idf33f4d52aab6a2907debf6a7d6c7be5c83d9ee6
Upgrade JSDoc from v3.4.3 to 3.5.5:
- v3.5.0 JSDoc can parse any JavaScript that is supported by Babel
compiler.
- v3.5.1 fixes an incompatibility bug in Node.js < v5.10.0
- v3.5.5 fixes an incompatibility bug in Node.js v8.5.0
Prior to this change, object shorthand caused the following errors:
jsdoc -c jsdoc.json
fs.js:1979
binding.copyFile(src, dest, flags);
^
Error: EISDIR: illegal operation on a directory, copyfile '/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/templates/default/static/fonts/OpenSans-Bold-webfont.eot' -> 'doc/autogenerated/fonts'
at Object.fs.copyFileSync (fs.js:1979:11)
at /home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/templates/default/publish.js:471:12
at Array.forEach (<anonymous>)
at Object.exports.publish (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/templates/default/publish.js:468:17)
at Object.module.exports.cli.generateDocs (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:430:39)
at Object.module.exports.cli.processParseResults (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:383:20)
at module.exports.cli.main (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:227:14)
at Object.module.exports.cli.runCommand (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:180:5)
at /home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/jsdoc.js:103:9
at Object.<anonymous> (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/jsdoc.js:104:3)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)
https://github.com/jsdoc3/jsdoc/releases/tag/3.5.0https://github.com/jsdoc3/jsdoc/releases/tag/3.5.1https://github.com/jsdoc3/jsdoc/releases/tag/3.5.2https://github.com/jsdoc3/jsdoc/releases/tag/3.5.3https://github.com/jsdoc3/jsdoc/releases/tag/3.5.4https://github.com/jsdoc3/jsdoc/releases/tag/3.5.5
Bug: T165036
Change-Id: Ic7a22b6992d45fa0ea3d011a9ad5200d7cc73b80
CI doesn't use a version of NPM that reads package-lock files which
seems to break some build product diff checks.
Bug: T165036
Change-Id: I29383c1a5c1f7f102fe458ac778adc3bf264c9fd
Replace Mustache.js templates with template literals. An effort was made
to minimize additional refactoring, so feel free to ask for more but it
ain't coming in this PS.
Bug: T165036
Change-Id: I4a6a1d93a2922c3a9ef3ae93c47da17a35c644f0
Enable the Babel transpiler so that ES6 template literals,
destructuring, and arrow functions can be used in production.
"last n versions" syntax was not used so that builds are more
reproducible.
Bug: T165036
Change-Id: I553b6d14cc368c7b4366f68d13038c3d505f5429
- Add SVG Inline Loader for Webpack. This allows SVG files to be
imported.
- Update the Webpack and test configurations to use the new loader.
- Scope the ESLint rules down to just JavaScript files so that linting
isn't attempted on the SVG.
Bug: T165036
Change-Id: I00bccff4c3167975c19d577be6343dcaca7ddb2d
Creating a different page preview for disambiguation pages.
This patch:
- modifies the Preview model to accept a new 'type' property
- modifies the Restbase Gateway to pass the 'type' prop to the Preview model
- creates a new template to accept both generic/disambig previews
- modifies the renderer to render the new template
- generates icons for new template through resource loader
- adds new i18n strings
- modifies event-logging "preview seen" event to send new "disambiguation" previewType
- updates event logging schema version
- adds tests for Preview model and renderer for new preview type
- does way too much? yes, yes it does.
Bug: T168392
Change-Id: Idc936cc3eabbdd99a3d98f43c66b4cdbb7d24917
When the diff test fails, don't dump 40k characters to console. Just
report that the failure occurred.
Change-Id: I1cc31fcdebe3e1097ed9e80dfbe3fb6e0dfc34b2
Don't assume that thumbnail URLs contain a dimension delimiter of "px-".
Previously, thumbnail URLs always contained the width. e.g.:
https://upload.wikimedia.org/wikipedia/commons/a/aa/100px-Red_Giant_Earth_warm.jpg
However, thumbnail URLs that actually point to the original are not
sizable:
https://upload.wikimedia.org/wikipedia/commons/a/aa/Red_Giant_Earth_warm.jpg
These are provided, for example, when the thumbnail size requested is
larger than the original. There was code designed to handle this
scenario but it only applies when RESTBase and page preview thumbnail
sizes happen to be in sync. In other words, if RESTBase requests a large
thumbnail on behalf of page previews, and page previews only requested a
small thumbnail, the original may be unexpectedly provided. A
conditional is introduced in this patch to verify that "px-" is actually
detected. If it is not present, the original is used.
Bug: T187955
Change-Id: If4e29dd870aecd6d461cc8203f6576d1bb8844f2
This patch adds a production build output gzipped file size check to the
test script so that any future changes may only introduce known size
differences. Note:
• The initial limit was taken from the present gzipped file size rounded
up to the 10th of a kibibyte.
• JEDEC notation is used. bundlesize internally uses Bytes utility which
only supports base 2 units.
https://github.com/visionmedia/bytes.js
Bug: T176211
Change-Id: Ie95f388673b0b982b105fef9a2917513a3307060
Why: Because they are the approved standard by TC39 and Ecma for
JavaScript modules.
Changes:
* Wrap mw-node-qunit in run.js to register babel to transpile modules
for node v6
* Change all sources in src/ to use ES modules
* Change constants.js to be able to run without
jQuery.bracketedDevicePixelRatio given ES modules are hoisted to
the top by spec so we can't patch globals before importing it
* Change all tests in tests/node-qunit/ to use ES modules
* Drop usage of mock-require given ES modules are easy to stub with
sinon
Additional changes:
* Rename tests/node-qunit/renderer.js to renderer.test.js to follow
the convention of all the other files
* Make npm run test:node run only .test.js test files so that it
doesn't run the stubs.js or run.js file.
Bug: T171951
Change-Id: I17a0b76041d5e2fd18e2d54950d9d7c0db99a941
Version 2.1.0 had a bug because of using console.err, obfuscating error
messages when the cli runner errored out.
Bug: T171951
Change-Id: I263c3e4e13f55cf67630448119ff335e26085197
To get cross-shell and OS glob support and fix some of the sinon
deprecation warnings regarding getConfig.
Bug: T168054
Change-Id: Idd6d47c1e63836c8429156cd9030ef9fda4479b1
npm scripts are run under sh. globstar support is only available in bash
> 4 with globstar enabled, so **/*.js was actually being resolved to
*/*.js only running tests 2 directories deep.
This made the test mediawiki.test.js not run since it was moved to the
3rd level deep folder (and actually broke), resulting in:
208 tests
403 passed
With this change, it fixes getting the test files, and fixes the
mediawiki.test.js, resulting in:
215 tests
413 passed
instead.
This makes it work everywhere and as nested as it will get for now. Will
consider adding glob support to mw-node-qunit later for easier use in
other projects too.
Bug: T165018
Change-Id: Id0164b2673c8afe8a24fd0eb4aa255c134253862
The benefit of this is if there are any problems with the
documentation they will not enter our codebase.
We do a similar thing in MobileFrontend
Bug: T158236
Change-Id: I30329dd868fe596c490f95354c3226c9cd4a2fc7
Like npm run start, npm run doc:start will rebuild the documentation if
any file in the src directory changes.
Supporting changes:
* Use nodemon@1.11.0.
Change-Id: I7b528525874e377533e92c0a80c8aae9f6a18620
JSDoc can handle ES2015 modules whereas JSDuck can't. Regardless of
however many features JSDuck has that JSDoc mightn't [0], we can't
use JSDuck to document this codebase.
[0] T138401
Bug: T158236
Change-Id: I8da712075dd28f6b228c96fa9577ca39eb148fb5
That way before commits it will run tests and add compiled sources
automatically removing some of the pain of having to commit the compiled
assets for now.
Additional changes:
* Extract npm test:dev from npm test to run lint and tests without the
CI check (to be re-used in the pre-commit hook)
Bug: T160061
Change-Id: I6e1201ef7dae5fef34b14cabc0292fb1aa4e5997
It enables certain optimizations, see:
* https://webpack.js.org/guides/production-build/
Code is minified by uglifyjs.
Aditional changes:
* Add banner so that sources are not minified by ResourceLoader
Bug: T160061
Change-Id: I50c9148ebf2d860db42a24225bc128bfcfe56927