Commit graph

133 commits

Author SHA1 Message Date
Timo Tijhof
0b4e24c995 build: Merge doc linting into 'npm test'
Whether JSDuck or JSDoc3, it's good to verify that there are no
regressions in the doc syntax. This has been enforced by WMF CI
for many years with a dedicated Jenkins job.

However, both 'grunt lint' and 'npm run doc' take a relatively
small amount of time in CI:

* grunt lint: ~ 35s (not incl 'npm install')
* npm run doc: ~ 10s (not incl 'npm install')

Bug: T225730
Change-Id: If22b7bc64266e43088c7dec8138d81c938687fb9
2020-03-18 18:40:57 +00:00
Željko Filipin
a43fd95e14 Selenium: fix Illegal option -o pipefail
47cc31d changed running selenium.sh using sh instead of bash. This
commit reverts back to bash, since sh does not support pipefail.

Bug: T247983
Change-Id: Ia2706051d40a6c26156fef77744cf5dff3a8cf95
2020-03-18 16:07:13 +01:00
AronDemian
47cc31de95 tests: Enable 'npm run selenium' on Windows
Run the script explictly via sh, the default is cmd.exe on Windows.
Also ported from bash to sh per Jforrester's request.

Change-Id: I96b66c6ae01a1761619955be2e8a3dbc64edff18
2020-03-15 21:46:50 +00:00
Timo Tijhof
4029fbf38a build: Remove unused 'jpeg-js' npm dev dependency
Follows-up 7d9e117d91, which added this for use in WikibaseMediaInfo,
which should have been added there instead of here.

This has since been fixed.

Change-Id: I6d5b0c93c3de457da0bf54859f05b1836eccc84f
2020-03-02 02:22:43 +00:00
James D. Forrester
0461692f45 build: Updating npm dependencies
* grunt-stylelint: 0.12.0 → 0.14.0
* stylelint-config-wikimedia: 0.7.0 → 0.9.0

Change-Id: Ia055fbfd75e1d3a8b771e08a6b0dbd7de61c7a98
2020-02-18 17:23:11 -08: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
Clara Andrew-Wani
f07d7ba699 Move tests from api-testing repo into Core
Except for Search & Watchlist, which need fixes in gated extensions first.

Change-Id: I88d24dda4bc047868de3ff9dd4a5753b9c7b0f64
2020-02-05 16:07:54 -08:00
James D. Forrester
8c3f6440e4 build: Update qunit and all karma-related tools to latest
karma                   3.1.4  →  4.4.1
 karma-chrome-launcher   2.2.0  →  3.1.0
 karma-firefox-launcher  1.1.0  →  1.3.0
 karma-qunit             2.1.0  →  4.0.0
 qunit                   2.9.1  →  2.9.3

Bug: T222293
Change-Id: I76d9fe8b6b189a9a334411f3b62014c234002edc
2020-02-03 13:28:24 -08:00
Timo Tijhof
6143f757ea selenium: Replace wdio-chromedriver with ./selenium.sh script
This package was serving two purposes:

* Install chromedriver automatically.
* Start chromedriver automatically when using the
  'npm run selenium' entry point (e.g. for local development).

For the CI entry points (selenium-test, selenium-daily) the
chromedriver is skipped. For those, we expect the CI runner to
have started a chromedriver server already, which allows the
server to continue running between different the test suites
of different extensions etc.

By letting WDIO start the chromedriver for local development,
we had the benefit of 'npm run selenium' directly being an alias
to the 'wdio' command. This made it easy to pass additional
arguments like --spec or --mochaOpts for running specific tests
only and overall makes things easier to reason about from a
developer perspective with fewer (required) layers of
indirection you see and need to understand when debugging.

But, this has also caused problems. Specifically, it means
developers have to use the same version of Chrome locally
as we specify in package.json which isn't very flexible. While
we could try to keep this up-to-date roughly, that too isn't
an option because the secure environments we recommend for local
use (Quibble and Fresh-node) both use a Debian distro with
typically older versions of Chromium than your local auto-updating
Google Chrome.

For now, let's go back to moving the responsibility of installing
chromedriver together with the responsibility to install Chrome
itself.

== Changes ==

For CI, nothing changes (it already installs both).

For developers using Quibble, Vagrant or Fresh nothing changes
(already installs both).

For developers who make their own secure environment, they will
need to make sure chromedriver is installed, just as we required
between 2017 and Aug 2019 before my commit 1955a8aa56.

== How ==

wdio-chromedriver cannot start a foreign install because the
protocol can change between versions, so unfortunately together
with not using chromedriver from npm, we also can't use
the wdio-chromedriver autostart mechanism. Instead, I'm bringing
back Antoine's shell script that did this prior to ebda397c54.
But, with a few tweaks so that it forwards shell arguments,
this way developers continue to enjoy the benefit of 1955a8aa56,
which is that 'npm run selenium -- --spec foo.js' works.

Bug: T234610
Change-Id: I03ca94315d0611d2b6abccc12cf9076d41b2c00e
2020-01-17 17:03:54 +00:00
Clara Andrew-Wani
ac4dec907b Add API-testing to core
Bug: T236680
Depends-On: I0110de1539e4d6d9d6a58d1a645c1a1c02d8127f
Change-Id: I827dc895719cc68738ebb425f8471ac38caa49aa
2019-12-19 13:20:12 -05:00
Ed Sanders
a7227221af Remove unnecessary devDependency
Change-Id: I490e29b8aeefbd54d7ebeb3ac16a918495bfe4ec
2019-10-29 11:13:59 +00:00
Ed Sanders
3c2cea4559 build: Update linters and fix errors
Change-Id: Ieb1eff174f5168bf6c9e9aaeb58ec1a1bcd33538
2019-10-23 11:22:41 +01:00
Ed Sanders
7b9bb6f7d6 Use plugin to ensure all message keys are documented
Bug: T235502
Change-Id: If77ddf2caf667504bd0f7e0150649745ae31c4e2
2019-10-21 17:05:40 +01:00
Ed Sanders
00b2315132 Build: Update eslint-config-wikimedia and fix errors
Change-Id: I9459dcee08ea7f5b54c41a2cfde965b011099f57
2019-10-03 08:33:21 -07:00
Timo Tijhof
1955a8aa56 selenium: Upgrade from webdriver v4 to v5
* Options no longer needed or no longer exist in wdio v5:
  - coloredLogs: Now always on. The underlying 'chalk' library can still
    be influenced via the FORCE_COLOR environment variable.
  - screenshotPath: Removed. Was already disabled in our config.
  - deprecationWarnings: Meh.
  - 'sync: true' – On by default when `@wdio/sync` is installed.
    The wdio v5 config generator doesn't recommend setting manually.

* The selenium.sh script was removed. It existed to start and stop
  chromedriver for local use by developers. This is now done by
  the wdio-chromedriver-service. In WMF CI, Quibble starts its own
  chromedriver (as optimisation, reused across gated repos),
  which is why the 'selenium-test' entry points remains and skips
  this.

* The wdio-mediawiki package now requires wdio v5 and Node 10.
  This doesn't affect extension repos because versions are pinned.
  Upgrade may happen at the earliest convenience.

* Several WDIO methods changed names or signature. Full list at:
  <https://github.com/webdriverio/webdriverio/blob/v5.13.2/CHANGELOG.md#v500-2018-12-20>
  Highlights:
  - browser.element() is now browser.findElement() with "$()" as alias.
  - browser.localStorage replaced by browser.setLocalStorage.
  - browser.deleteCookie() requires `name` param. To delete all at once,
    there is a new method browser.deleteAllCookies().
  - Commands that return data no longer wrapped in `{ value: … }`.
    Values are now returned directly.
  - Custom config keys are now under browser.config instead of browser.options.
    Renamed our username/password keys to be mw-prefixed, to avoid clashes
    and reduce confusion with similar config keys.
  - browser.click(selector) and browser.getText(selector) no longer exist.
    Use $(selector).click() or .getText() instead.

* Fix "no such alert" warning from specs/page.js by removing the apparently
  redundant code.

Bug: T234002
Bug: T213268
Change-Id: I908997569ca8457997af30cb29e98ac41fae3b64
2019-09-29 02:59:44 +01:00
James D. Forrester
aa7133ce86 wdio: Switch to dots reporter for brevity
Change-Id: Ica6cc3e4fc445f39ba911db14c58a486f32f7f89
2019-08-23 20:51:00 +00:00
Željko Filipin
5a78d326a7 build: use the latest webdriverio 4.x related packages
Updating packages removes dependency on cryptiles. We were using
version 3.1.4 that had a vulnerability.

Bug: T226586
Change-Id: Idccc7f418ed6fce7452a6f0d403477953448a541
2019-07-08 15:33:44 +00:00
Ed Sanders
689d07b81d build: Update eslint-config-wikimedia to 0.13.0
Change-Id: I7df5840bc97f8bbcd8cfc875c2b48b3061ef2c9e
2019-07-05 13:32:26 -07:00
James D. Forrester
6b1e651255 build: Upgrade stylelint-config-wikimedia from 0.5.0 to 0.6.0 and make pass
Change-Id: I062bed7889cdfcc48eab9594200fc1d4767dda8c
2019-06-10 14:49:49 -07:00
James D. Forrester
effb830977 selenium: Re-add all tests and wdio-mocha-framework, now v0.6.4
This reverts commit c3878c08b5.

Now that we're running on node10, this will fail until we fix
things.

Bug: T213268
Bug: T222406
Change-Id: I5935fc5d5bc23978e50275d3c99ac870b3b82f49
2019-06-03 12:56:07 -07:00
James D. Forrester
c3878c08b5 selenium: Temporarily drop all tests and wdio-mocha-framework
This is so that we can migrate to node 10 in CI. It should only land
for an hour or so, and is to be reverted as soon as we get CI up to
node 10 and working, lest our suites of selenium tests become
subject to bitrot.

Bug: T222406
Change-Id: I9473e0213c070a0e963913fd81062c6bbf9ec2f2
2019-06-03 14:33:42 +00:00
Michael Holloway
6a75d6e473 npm: bump grunt-karma to 3.0.2
`npm install` currently fails due to an unsatisfied peer dependency.
See full output here:

https://phabricator.wikimedia.org/P8552

Bumping the required grunt-karma version to the latest (3.0.2) fixes
this.

Change-Id: I5b7f2deba2d766b809a964f53cb22f47f0617bd6
2019-05-21 17:28:48 -04:00
Željko Filipin
7d9e117d91 selenium: Add jpeg-js to devDependencies
It is needed for I92739d84947ac146e in WikibaseMediaInfo Selenium tests.
It can not be added there because of T199116.

Bug: T219815
Bug: T199116
Change-Id: Ib7c3b1b49c280bdc38c40c6aef900a605c1e3cbe
2019-05-10 16:08:46 +00: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
James D. Forrester
83c5805c2e build: Upgrade grunt from 1.0.3 to 1.0.4
Change-Id: I9bfada10337dbab4cb5c77348f5f0df6cfab40a7
2019-04-30 13:25:38 -07:00
Ed Sanders
9097f95ecc build: Update eslint-config-wikimedia to 0.11.0
Change-Id: Iee025a518962e68c5ec2c07d952f402cd2a7f69b
2019-02-20 23:36:03 +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
Timo Tijhof
bce938566d build: Update karma to 3.1.4
This fixes the bug where HeadlessChrome was always shown as
version 0.0.0 in the console output, which makes it rather
difficult to debug which Chrome version is installed.

Upstream https://github.com/karma-runner/karma/issues/2762,
which updates the ua-parser library to a version that fixes
that bug.

Change-Id: I0b7fe7f8a90649592c4d31fb3055cdc9e8d34814
2019-02-10 04:10:32 +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
Ed Sanders
b685292d82 build: Update eslint-config-wikimedia to 0.10.1
Change-Id: Id98af16c1ec1c6c4a790948a35e96e2fe925ebb5
2019-02-02 11:05:04 -08:00
Timo Tijhof
8d4b218ee7 build: Remove unused 'deepmerge' package
Was added for wdio-related code, but not used in the end.
The only reference to this module anywhere in Wikimedia Git is
mediawiki/extensions/CirrusSearch, which doesn't use it for
its regular or daily tests, but rather the integration test,
which already has its own copy of this module in package.json.

Change-Id: Ifdf4362077f4684a2866363e35d0aca2f89f48b5
2019-01-21 15:13:42 -08:00
Volker E
0a2ac54ba3 build: Remove 'stylelint' package as it gets pulled-in by 'stylelint-config-wikimedia'
Change-Id: I734ebf6c18a3266bec2d9c9e38e827c3ec412586
2019-01-10 13:23:33 -08:00
jenkins-bot
41a744cba7 Merge "build: Update qunitjs to 2.9.1" 2019-01-08 19:00:37 +00:00
Ed Sanders
b3e490bba6 build: Update eslint-config-wikimedia to 0.10.0
Change-Id: I2930bcabeeb7b7b2eb36063e77b26e664a691b43
2019-01-08 17:40:11 +00:00
Timo Tijhof
9cd3b52723 build: Update qunitjs to 2.9.1
Code and integrity from <https://code.jquery.com/qunit/>.
Release notes at <https://github.com/qunitjs/qunit/releases>.

Highlights for the browser version:

- [2.7.0] Reporter: Remove cost of DOM size when
  using "hidepassed=true".
- [2.7.0] Reporter: Use perf.now() for improved accurracy
  of unit test durations.
- [2.7.0] Reporter: Make debugging tests in a browser
  easier by adding timeline markers for DevTools.

Highlights for the npm package / CLI version:

- [2.9.0] CLI: Reduce dependency tree size
               from 143 packages to 9 packages.

Change-Id: I38408d90765cd18d5dd6952b8b6b30cbfa0c7ed5
2019-01-07 21:05:36 -08:00
Volker E
d939ca58a4 build: Upgrade stylelint-config-wikimedia to 0.5.0 and make pass
Change-Id: I648375927bace5fc21bd842268c645570759ce85
2018-11-28 16:30:32 -08:00
Ed Sanders
3e4e0a5774 build: Use eslint-config-wikimedia v0.9.0 and make pass
Change-Id: I7b5d228a3de4b3006751a427dec907a5bebf2f51
2018-11-23 14:20:24 +00:00
Ed Sanders
d4a2191957 build: Update eslint-config-wikimedia
Change-Id: I5a8768e1a7e3960d2c822c5f842c0ffa29e2f08b
2018-09-11 23:25:26 +01:00
James D. Forrester
a6242eff16 Bump qunit from 2.6.0 to 2.6.2
Change-Id: Id7f47eee423c2fc1289f468c6622b952814d8912
2018-09-10 13:37:48 -07:00
James D. Forrester
b0df641d31 build: Update grunt-karma from 2.0.0 to 3.0.0
Bug: T194280
Change-Id: Iba043c036c06bebd961896f390063ca9a0129eb2
2018-09-10 09:46:17 -07:00
jenkins-bot
0cbccb51b4 Merge "build: Bump most devDependencies to latest" 2018-09-07 21:54:47 +00:00
James D. Forrester
3f767b2468 build: Bump most devDependencies to latest
grunt-stylelint         0.10.0  →  0.10.1
 karma                    2.0.2  →   3.0.0
 karma-firefox-launcher   1.0.1  →   1.1.0
 karma-qunit              2.0.1  →   2.1.0
 postcss-less             1.1.5  →   2.0.0

This reduces our `npm audit` alerts down to just those from grunt-karma.

Bug: T194280
Change-Id: I7d321dd715db9d214e65ed7197e917cb7c6b14f3
2018-09-06 17:01:45 +00:00
Željko Filipin
e552e95f71 Selenium: Daily Jenkins job targeting beta cluster should run only tests that pass
Selenium tests run fine when targeting MediaWiki installation in
MediaWiki-Vagrant and in Jenkins, but fail when targeting beta cluster.
Until tests are refactored to run without failure for beta cluster, let's disable
failing tests.

Bug: T185011
Change-Id: I12da893e7d624d4ebe478bccf0706aa07c965796
2018-09-04 12:47:07 +02:00
Željko Filipin
0a56fd356d Selenium: selenium-daily NPM script
selenium-daily just calls selenium-test. It's needed for daily Jenkins job targeting
beta cluster. The script 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 the script.

Bug: T188742
Change-Id: Idf86f94cc31abda4bfcdc1ac4eba29206d9c91f9
2018-08-29 13:00:16 +00:00
Ed Sanders
606f2783c1 build: Update eslint-config-wikimedia to 0.7.2
Change-Id: Ibdf9cc013e1265ef461169ec2227652eaf917900
2018-08-14 19:24:51 +01:00
James D. Forrester
6450fc980b build: Upgrade eslint to 5.x
Add two exceptions for max-len and no-prototype-builtins.

Change-Id: I5d3f7a3e282a237fb5de9f0eb29b579a08c32652
2018-07-05 16:58:14 -07:00
Željko Filipin
9029425a8a Update grunt and grunt-contrib-watch to resolve vulnerabilities
`npm audit` found 27 vulnerabilities (11 low, 12 moderate, 4 high).
`npm audit fix` fixed most of them.
There are 8 vulnerabilities remaining (2 low, 6 moderate).

Bug: T194280
Change-Id: I05d80bc38d16be8249a27d94dad8e13c65139545
2018-06-15 13:46:46 +02:00
addshore
0f472c4bc1 npm selenium command, use bash
On Windows this seems to complain unless bash is specified

Change-Id: I4515c851ffea143d4c1c6d111ffdd64b62f9f304
2018-06-11 07:31:02 +00:00
Ed Sanders
5e18d925e7 build: Introduce eslint-plugin-qunit and enforce
Change-Id: Iefe06cc865c458000ca5350c2d9205f5b768bac8
2018-06-05 21:58:25 +01:00