Commit graph

80 commits

Author SHA1 Message Date
jenkins-bot
cdfdbfb1c9 Merge "codex: Provide i18n function and messages" 2024-07-03 07:06:47 +00:00
Anne Tomasevich
3286f6fcca codex: Provide i18n function and messages
- In Vue.createMwApp, provide `mw.msg` as the CdxI18nFunction,
  which will be used inside Codex components to get translated
  messages for certain strings
- Include Codex messages in CodexModules that use Vue components
- Add the codex i18n dir to the LocalisationCache message dirs
  and to the banana config in the Gruntfile

Bug: T368449
Change-Id: I24477f5f6dcb34ad1c0959d60cdf221e859db5ce
2024-07-02 22:30:06 +00:00
Timo Tijhof
7de55c9f16 build: Switch "npm run qunit" from chrome to firefox
Chrome breaks on Apple ARM (e.g. Mac M1 or M2) when run from within
Docker (such as fresh-node), because Chrome is incompatible with
Rosetta emulation for Intel, thus making it hard to run tests locally.

Firefox works fine in this regard.

Depends-On: I6f8546e6e604cbb41e11bd2b59f8b5f19350c676
Change-Id: I6ecbd5743f3ed0d639b79cb08c8ff279e6ad9ff6
2024-07-02 00:39:14 +00:00
Ed Sanders
2af1c3c901 build: Update eslint-config-wikimedia to 0.28.1 and autofix
Also remove temporary explicit dependency on eslint-plugin-vue
introduced in Ibd616750f046a.

Change-Id: Ic6330fcb116e99d5827b4877e094e3073e2b7b72
2024-06-11 19:03:53 +01:00
Winston Sung
629ccda2c4 i18n: Move preferences messages to a separate i18n file
Bug: T167762
Change-Id: Ice0b4c07857344b4ae6b2558d823ea6311e61101
2024-05-04 01:07:11 +00:00
Timo Tijhof
4d7244a466 build: Simplify --qunit-watch logic
* Remove limitation to `.js` files, so that edits to Resources.php
  and any .json files are considered as well.

* Add watching of the skin.json and extension.json file itself.

* Allow `--qunit-watch` to work without `--qunit-component`,
  defaulting to watching MediaWiki core.

I would have liked to widen this to simply watch `extensions/**` and
`skins/**` by default (and when component != MediaWiki core), because
that way it will also re-run automatically after changes in an
extension dependency (e.g. from core to an extension, or
from a dependency like EventLogging to NavigationTiming). However,
Karma uses the popular "chokadir" which ironically chokes and runs out
of available operating system file handles in an attempt to crawl and
watch every file recursively. This unlike qunit-cli which uses
node-watch and the Node.js 12+ native file watcher API. Perhaps for
something to revisit in the future.

Change-Id: I2bb7f0df510f84872a2381bdebe3f2b59cc80705
2024-03-27 02:08:08 +00:00
Timo Tijhof
d999dc7ac5 build: Update karma-qunit to 4.2.0 and remove old __karma__ hack
Made redundant by https://github.com/karma-runner/karma-qunit/pull/184.

Change-Id: If636ec52826c2bdcf1b6809e8ff18e34179cd71d
2024-03-02 20:11:36 +00:00
Timo Tijhof
eb637c51a5 build: Update karma-firefox-launcher to fix bug on macOS
Mozilla has stopped shipping the `Firefox.app/Contents/MacOS/firefox-bin`
entrypoint for macOS, instead favouring `Firefox.app/Contents/MacOS/firefox`.
This broke the launcher and requires a minor patch.

Pending an upstream release, use our fork for now. We can transition
this to a simpler setup without Karma (i.e. launch browser directly),
but for now we can patch it in this way.

Change-Id: If99f030b1b23be6b906a15bfdb72590fc249cb0c
2024-02-09 13:46:06 +00:00
Roan Kattouw
78175b0695 Gruntfile: Remove now-unused copy:jsdoc command
This was needed for jsduck, but isn't needed now that we use jsdoc
instead.

Bug: T352308
Change-Id: Iade0bf72d74328d8e88f15ee54dd064b526a7c05
2023-12-21 10:37:30 -05:00
James D. Forrester
c71e0ffbd6 Gruntfile: Split stylelint runs for ease of reasoning
Given that we can't use RL, we can simplify the glob a lot too.

Change-Id: I7cd721640c697eacd230dc22fb9478458ee0452b
2023-12-12 10:55:22 -05:00
Jon Robson
dfea3e8e5a Add jsdoc with jsdoc-wmf-theme
jsduck is preventing us from using ES6 syntax and has not
been supported for some time. It is also difficult to setup
locally due its use of Ruby.

Introduce jsdoc and remove jsduck per T138401#9335987
Link to static copy of jsduck explaining the state

This does the bare minimum - the docs are built to the folder
docs/js/index.html and only one module is ported over to allow
us to provide feedback on the end result.

Bug: T138401
Change-Id: I1a351ac5aec731bb79a877023ac10988ec3ec786
2023-11-28 00:37:48 +00:00
Umherirrender
7ebeb84d20 build: Fix file name for stylelintrc.json in grunt-watch
Follow-Up: I19e00ca6503b0212642bdb3a4735e0a52e43d670
Change-Id: I89e69042db78f68b1af74e3f123d2cbfebd17a3e
2023-07-04 21:32:23 +02:00
Ed Sanders
13e0a7cc58 Update eslint-config-wikimedia to 0.25.0
Change-Id: I70d4e311d369bd160e0cb9411d1b074e22104006
2023-05-05 15:03:43 +01:00
Timo Tijhof
0e116f3101 build: Avoid extra space in Chromium command via CHROMIUM_FLAGS
When CHROMIUM_FLAGS is unset, as it is if you're running Chromium
outside any container (like fresh-node or Quibble), the splitting of
the empty string results not in an empty array but in an array with
an empty string. In other words `[ '' ]` insteadf of `[]`.

This means when Karma formats the browser launch command, and joins it
with a space, it runs `chromium --foo --bar   http://localhost`
notice the three spaces between "bar" and "http".

This was fine in Chromium for ten years but Chromium 110 changes the
way it parsers the command-line arguments such that it will interpret
this as launching Chromium with two URLs, of which one is the empty
space. While regular Chromium supports starting the browser with
multiple tabs at once, HeadlessChrome does not.

Bug: T335329
Change-Id: Ie8a1ee7a0b16ca6dfd7a8293e0bf686a48141c8c
2023-04-25 18:15:15 +01:00
jenkins-bot
a9530060fd Merge "tests: Improve --qunit-watch handling in Gruntfile" 2023-02-20 19:52:21 +00:00
Timo Tijhof
a277c206c6 tests: Improve --qunit-watch handling in Gruntfile
Follows-up I39f5d84504783c91d54b3d309064b546cd40e311.

* Fix bug where qunitWatchSourceFiles was assigned instead
  of qunitWatchSourcePattern.

* Use array push and spread instead of needing filters. Alternatively
  could use undefined vs object for a slightly simpler filter.

* Use separate let statements instead of legacy one-var style.

* Move vars to the inner-most block that needs them.

Bug: T250045
Change-Id: I6c63788d07fc27c31db63dce6da1bf1e9a661806
2023-02-20 17:58:19 +00:00
jenkins-bot
8a7ee85cdf Merge "QUnit: CLI option for watching test and source files" 2023-02-20 17:49:29 +00:00
Umherirrender
fefb27b037 build: Run eslint for /docs/ and make pass
The doc folder contains (committed) json files with schema definition
for json files
That should be linted as well to spot syntax errors easier

Change-Id: I20ff7abf6b98d2247ee52e2d2b43af88c062f779
2022-07-27 00:43:02 +02:00
Kosta Harlan
b33aab145a
QUnit: CLI option for watching test and source files
Add a --qunit-watch option to the Gruntfile, when used with
--qunit-component, the test and source files for the comopnent
will be watched and tests re-run on file change. Chrome headless
browser stays open as well, which results in faster overall
test execution time.

Bug: T250045
Change-Id: I39f5d84504783c91d54b3d309064b546cd40e311
2022-04-06 14:09:05 +02:00
Kosta Harlan
891cad8a1b QUnit: Set default file type to js
This silences the "Unable to determine file type from the file
extension, defaulting to js" warning shown when running `grunt qunit`.

Bug: T250045
Change-Id: Ife62c53d1e2ff6121774552c7d0793784aea6d6b
2022-02-09 04:08:42 +00:00
Kosta Harlan
588a67af05 QUnit: Allow running tests for core or single skin/extension
Usage:

* DiscussionTools tests: `grunt qunit --qunit-component=DiscussionTools`
* MediaWiki core tests only: `grunt qunit --qunit-component=MediaWiki`

It might be nice to have this more granular, to run tests for a single
file, or a single ResourceLoaderModule, but will leave that to another
time; it is already fast.

Note that some projects may fail, e.g. GrowthExperiments has a test
failure due to not mocking all of the dependencies needed for the
test code; that can be worked around by adjusting the application code
or the test registration to include all needed dependencies.

Example fixes:
* GrowthExperiments: Iea3a89a902cd17dd91696d2a37144baa9e452077
* MinervaNeue: I8f747e3df196055361d53d00fea833fb9de892f0

The only other extension I see that has one broken test when run
this way is VisualEditor.

Bug: T250045
Change-Id: I977150ece26f5878a0ccc42d39bed6c7e74e9602
2022-02-09 04:07:49 +00:00
Ed Sanders
9e234e6a37 eslint: Only apply client rules to client files
Change-Id: I757b9616ce69b6020e9f0e556e006d39de59eb01
2022-02-09 02:40:11 +00:00
Volker E
3f6ab130e6 build: Update SVGO to latest v2.3.0 and re-crush SVGs
SVGO v2.x changed configuration to JS, amending configuration.
Adding new 'minify-svg' npm script.
Also re-crushing SVGs.

Bug: T278656
Change-Id: I1d746fca051cbc00900a05c33e8a401f95848930
2021-05-18 05:50:18 -07:00
Ed Sanders
5dece5b27b Update stylelint-config-wikimedia to 0.10.3
Remove needless disables.

Change-Id: I324ab9d23a354cb0298a0714df2535f8e8850261
2020-11-19 23:13:37 +00:00
Ed Sanders
8b720e9bd6 eslint: Update to eslint-config-wikimedia 0.16.0
* valid-jsdoc replaced with jsdoc plugin
* New /selenium config

Change-Id: I471eebac0312cb25c539c3f6a3ecfc7cfd4ed8d6
2020-06-02 21:32:56 +01:00
Timo Tijhof
85d57d4bbf build: Move eslint ignores to .eslintignore
Note that node_modules is excluded by default.

Bug: T249858
Change-Id: Iaa69092b11e49ebf9cc5f2ec8a695894cda31b83
2020-04-22 19:17:08 +01:00
jenkins-bot
fbf4346a10 Merge "build: Provide linting for .vue files from upstream" 2020-04-16 01:11:55 +00:00
Roan Kattouw
bed84e3281 build: Provide linting for .vue files from upstream
Was first attempted in f1eaa06d5e,
and reverted in 0b3fe4fe8c. Now this
is done in eslint-config-wikimedia for all repos.

Change-Id: I9ee735eef40085b6373b565838d67e186e438657
2020-04-15 17:40:31 -07:00
James D. Forrester
269cbdbdd4 resources: Provide an ES6-style Promises library with a skip function
Using https://github.com/taylorhakes/promise-polyfill via a skipFunction.

Bug: T237688
Change-Id: Ib0ffb5d9821e7b734c3f7533cc99e5fdd2c8da3a
2020-04-14 16:51:43 -07:00
Catrope
0b3fe4fe8c Revert "build: Linting for .vue files"
This reverts commit f1eaa06d5e.

Reason for revert: accidentally allowed ES6 syntax.
Looking for a way to redo this that doesn't break our linting as badly.

Change-Id: I78974b97001bdbea9aff5717c69d71b8a2582ade
2020-03-30 18:08:22 -07:00
Timo Tijhof
031a91e9ff build: Remove old ZUUL_PROJECT hack from Gruntfile.js
This was here from a year ago when we added CHROMIUM_FLAGS, which
has since rolled out.

Also make the assert-mw-env less fragile by checking the
env variables in one place each instead of two places. Before this,
it was relatively easy to accidentally add a warning for one, without
the shell exit code changing.

Change-Id: I6b85483981b415fe251b3760d5f282433e7fc4e9
2020-03-29 20:02:25 +00:00
Roan Kattouw
f1eaa06d5e build: Linting for .vue files
Install eslint-plugin-vue, which lints JS inside <script> blocks in
.vue files, and also lints Vue templates. Configure eslint and stylelint
to run on .vue files. stylelint automatically picks up on CSS in <style>
tags.

You may have to change a setting in your text editor or IDE to make it
run eslint and stylelint in .vue files. For eslint, see
https://eslint.vuejs.org/user-guide/#editor-integrations ; for
stylelint, I had to install the linter-stylelint-plus Atom plugin then
add source.css.embedded.html to the "Base Scopes" setting for that
plugin.

Change-Id: I7e6a13317792fc25c29106739b0c24864fd8d301
2020-02-05 18:51:39 -08:00
Ed Sanders
50f2f248e4 Remove unnecessary reportUnusedDisableDirectives
This is enabled in eslint-config-wikimedia by default.

Change-Id: I4b79025c3b9a130d9e0f0af6282d769bd5ba0044
2019-11-15 16:21:22 +00:00
Brad Jorsch
aa0720d37c ParamValidator: Use MessageValue!
Trying to get away with returning a single code and parameter-list that
was supposed to represent both human-readable and machine-readable data
was a mistake.

This patch converts it to use DataMessageValue, which represents the two
separately and also provides guidance for supplying translations of all
the error codes.

This also eliminates the "describeSettings()" method that was trying to
serve multiple use cases (in terms of the Action API, action=paraminfo
and action=help). It's replaced by two methods that each serve one of
the use cases. Also some of the functionality was moved out of the
TypeDef base class into ParamValidator, to better match where the
constants themselves live.

Also I wound up creating a NumericDef base class so FloatDef can share
the same range-checking logic that IntegerDef has. I probably should
have done that as a separate patch, but untangling it now would be too
much work.

Bug: T235801
Change-Id: Iea6d4a1d05bb4b92d60415b0f03ff9d3dc99a80b
2019-11-01 15:49:31 -04:00
Amir Aharoni
64e2d73f5c Split rest messages from the main en.json
Bug: T233192
Change-Id: I3990ae4e34a51e7648f74a05a4b7ac744fa9b9c4
2019-10-22 03:07:42 +00:00
Timo Tijhof
519739b4a8 build: Lower default Karma logLevel during local development
Follows-up fa63a70ae9 which enabled this for CI to investigate
a Jenkins-specific issue, but it makes for a very noisy and visually
unpleasant local experience because these Karma lines interweave
with the structural output from the qunit/karma reporter.

With this change applied, the local experience from 'npm run qunit'
has clean output again like so:

```
…
  mediawiki.storage
    ✔ set/get(Object) with storage support
    ✔ set/get(Object) with storage methods disabled
    ✔ set/get(Object) with storage object disabled
  mediawiki.template
    ✔ add
    ✔ compile
    ✔ get

Finished in 13 secs

SUMMARY:
✔ 440 tests completed
```

Change-Id: I21555468ed30ca3a2220eba1d8a78cc140a13399
2019-09-24 17:46:53 +01:00
Ed Sanders
f801b85099 Grunt: Expand js{,on} for readability
Change-Id: Ib3bfb1a9d6547e1062ea3ad08de7ea721c111586
2019-08-28 16:40:08 +01:00
James D. Forrester
7fdc5220f2 build: Upgrade eslint-config-wikimedia 0.12.0, drop grunt-jsonlint
Bug: T220036
Change-Id: I7088f9eeb9468b14efb2773fde5f55fd5c95a489
2019-05-06 13:48:40 -07:00
James D. Forrester
92b090e9e3 build: Upgrade grunt-banana-checker from 0.6.0 to 0.7.0 and make pass
Change-Id: I4c604ab50caeffc5738c719c17f19e769082376f
2019-04-30 13:26:02 -07:00
Ed Sanders
591cb30581 eslint: Enable caching
Makes re-running eslint faster on dev environments.

Change-Id: I3bd7932b49de35022898cdc8add1934633e6dacb
2019-02-19 19:57:08 +00:00
Timo Tijhof
d056d4c273 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
2019-02-10 06:26:10 +00:00
Volker E
c0e967ebab build: Add 'svgmin' Grunt task and crush SVGs
Adding 'grunt-svgmin' package and corresponding 'svgmin' task and
also crush SVGs. Several of them are featuring bad UX and are not optimal
in many different angles (a.o. clarity, universality, recognizablity etc.).
Specifically the 'mediawiki.skinning' ones.
But while they are here, let's make them suck less.

Change-Id: I8191ceac14565ae31d941982fab1586fa9b6bbdd
2019-02-06 22:03:48 -08:00
Amir Aharoni
9dc4ff216b Move exif messages to a separate i18n file
Bug: T167762
Change-Id: I17900ff07cd9b15f00c7118b4206cf1cdc074469
2018-12-27 17:05:55 +02:00
Ed Sanders
b61faa75a9 eslint: Turn on reportUnusedDisableDirectives
Change-Id: I3fb88324ba5a46e44041c13eb6447c8e33f4e79b
2018-12-14 14:22:26 +00:00
Timo Tijhof
828f6d6ac9 skins: Remove redundant mediawiki.hidpi script
This is an internal script automatically loaded by Skin.php to
activate the 'jquery.hidpi' polyfill for all images on the current
page in browsers that don't natively support the 'srcset' attribute
on the HTML img element.

This script is loaded via ResourceLoader for which Grade A currently
requires:
> IE11+/Edge, Chr 65+, Ff 52+, Saf 5+, Op 15+, iOS 6+, Android 4+.

According to MDN and CanIUse, the basic 'x' syntax of srcset is supported, and
enabled by default, in:
> Edge, Chr 34+, Ff 38+, Saf 7+, Op 21+, iOS 8+, Android 5+.

This means in the following browsers, MediaWiki will no longer attempt to
replace images in articles with their hidpi versions.

| Browser                | analytics.wikimedia.org (22 May - 22 June)
| ---------------------- | -----------------------
| IE 11 on Windows <= 7  | 3.4% (OS does not support HiDPI)
| IE 11 on Windows 8+    | 1.1%
| Safari 5 & 6 (desktop) | <0.1%
| Opera 15-20 (desktop)  | <0.1%
| iOS 6 & 7 (mobile)     | 0.1%
| Android 4 (mobile)     | 0.5%

While the total of 1.7% is higher than our usual point where we decide
to remove support, I think we should consider dropping the hidpi polyfill
still for several reasons:

* MobileFrontend no longer uses 'srcset' attributes. As such, these browsers
  don't actually change their behaviour based on the polyfill.

* For IE 11/Win8 in particular, most users don't have an HiDPI monitor,
  but we still download the polyfill. HiDPI on Win8 is primarily tablets.

* In all cases where the polyfill activates, we download the HiDPI images
  in addition to the standard resolution (which downloads and renders first).
  This is because client-side JavaScript is not able to replace it sooner.
  This could be considered a waste of bandwidth, as it can double or tripple
  the bandwidth cost for end users.
  This also means pages complete their loading much later because the browser
  first renders the page nearly to completion with standard resolution images,
  and only at the end our polyfill activates to restarts all image loading.

The experience gracefully falls back to normal web rendering, where the standard
resolution of the image is used. This would match what users of these devices
see on other websites, given client-side emulation of srcset is fairly rare.

== Modules

The 'mediawiki.hidpi' module was removed, and considered internal to Skin.php.
It contained no public methods. I confirmed there were no matches in Codesearch,
and no matches in mwgrep on Wikimedia wikis.

I did not remove 'jquery.hidpi', which is what contains the actual polyfill
and the jQuery.fn.hidpi() public method. (Codesearch shows 2 extenisons using
it, and mwgrep returned 1 unused gadget on Meta-Wiki referencing it).
It has been kept, but marked as deprecated. To be removed in a future release.

Bug: T127328
Change-Id: I42ce0feea1fbfe534f00e05a7cd8d81df0c33d8f
2018-06-25 17:17:16 +00:00
Timo Tijhof
5bf64e7f72 Remove the unused 'jquery.farbtastic' module
This was added in (r99923; 4d8c7e96ed) while reviewing the
'gadget-preferences' branch in SVN of the Gadgets extension during
development of MediaWiki 1.18, intended for use in a color picker
on Special:Gadgets as part of an experimental feature that was
never completed (r94051).

The module has no usage anywhere in Wikimedia Git, nor in any
third-party hosted repos indexed by MediaWiki Codesearch, nor
anywhere on-wiki at WMF in site scripts (per mwgrep).

Bug: T193826
Bug: T192623
Change-Id: I8ed6c09dc7efd750ad4688b895b2e3f808a0e52b
2018-05-23 16:42:32 +00:00
Timo Tijhof
16c8d89357 resources: Move the remaining src/mediawiki/ files
Single-file modules to src/, the remaining as sub directories.

A few highlights:
* mediawiki.Upload.BookletLayout. (stylesheet: no image references)
* mediawiki.feedback - Also move the image to its own images/ subdir.
* mediawiki.searchSuggest. (stylesheet: no image references)
* mediawiki.toc. (stylesheet: no image references)

Also updated any other references to 'src/mediawiki/' that I could find
in core:
* Fixed references in docs/uidesign/*.html
* Remove redundant exclude from jsduck.json.

After this, there are 4 files remaining in src/mediawiki,
which are the 4 files used by the actual 'mediawiki' base module.

Bug: T193826
Change-Id: I8058652892a78b3f5976397bd850741dd5c92427
2018-05-09 23:44:22 +01:00
Timo Tijhof
d199ce5856 jsjpegmeta: Move export patch to a separate file
Keep the main file in src/ for now, because it's got some whitespace
changes and a closure-wrap that make it differ from upstream's
version. Those changes are hard to review both for diffing and for
functional differences due to its odd-looking scope assignments that
I'd rather not change as part of this.

Change-Id: I248831cfa984432d0a30aa923a9bcd98029b05c4
2018-05-04 15:37:41 +00:00
Timo Tijhof
810afd33e0 selenium: Run wdio directly without grunt
Doesn't seem to add anything, except complexity.

This has the benefit of matching more closely the way the README
recommends running individual tests.

Also add a check for 'chromedriver' before running it.
Normally the -e and pipefail would suffice, but because
it runs in the background, the error can be buried,
hard to find, or even not cause exit code to be set
properly. Thus, do a simple 'hash' check that will
print a useful command and exit cleanly.

Before:
> $ something &
> [1] 57922
> -bash: something: command not found
> [1]+  Exit 127                something
> $ echo $?
> 0

After:
> $ hash something
> -bash: hash: something: not found
> (exit: 1) $ echo $?
> 1

Change-Id: Id95f18927b5443defe679a77a82c5cbdd127c716
2018-04-30 21:54:15 +00:00
Željko Filipin
4cbd36db87 selenium: Remove Jenkins configuration file
Both Mocha and Cucumber tests should run. Since WebdriverIO supports only
running one test framework, the only way to do it is to have a generic
configuration file and two framework-specific files (Mocha, Cucumber). Having
Jenkins configuration file complicates things, and there is no need for
it.

Bug: T179190
Change-Id: I710066f7b5479dcad27aa57cd61007c1c2d88931
2018-04-13 20:54:43 +00:00