Page MenuHomePhabricator

[CI] Replace npm-test job with npm-test + MediaWiki Core
Open, MediumPublic

Description

This task tracks the work add Core as a dependency of the npm test job for Vector.

Vector runs a growing number of tests via it's NPM test script. Some of these tests have relative references to various files in Core. For example, here's the current Storybook setup script at time of writing:

Storybook script
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

mkdir -p .storybook/resolve-less-imports/mediawiki.ui
mkdir -p docs/ui/assets/

curl -sS "https://en.wikipedia.org/w/load.php?only=styles&skin=vector&debug=true&modules=ext.echo.styles.badge|ext.uls.pt|wikibase.client.init|mediawiki.skinning.interface" -o .storybook/integration.less
curl -sSL "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/resources/src/mediawiki.less/mediawiki.mixins.less?format=TEXT" | base64 --decode > .storybook/resolve-less-imports/mediawiki.mixins.less
curl -sSL "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/resources/src/mediawiki.less/mediawiki.ui/variables.less?format=TEXT" | base64 --decode > .storybook/resolve-less-imports/mediawiki.ui/variables.less
curl -sSL "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/resources/src/mediawiki.less/mediawiki.mixins.rotation.less?format=TEXT" | base64 --decode > .storybook/resolve-less-imports/mediawiki.mixins.rotation.less
curl -sSL "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/resources/src/mediawiki.less/mediawiki.mixins.animation.less?format=TEXT" | base64 --decode > .storybook/resolve-less-imports/mediawiki.mixins.animation.less
curl -sS "https://en.m.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-en.svg" -o "docs/ui/assets/wordmark.svg"
curl -sS "https://en.m.wikipedia.org/static/images/mobile/copyright/wikipedia.png" -o "docs/ui/assets/icon.png"
curl -sS "https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-tagline-en.svg" -o "docs/ui/assets/tagline.svg"

These curl commands could be replaced with symlinks, copies, or otherwise local file references if the NPM CI job (currently mwgate-node10-docker) had MediaWiki Core in its environment.

Another use case is for when reference types via Vector's type checker. For example:

Type checking
typeof import( '../../resources/src/mediawiki.page.ready/mediawiki.page.ready/checkboxHack.js' );

References

Acceptance criteria

  • curl file references can be replaced with relative references that work locally in the context of a MediaWiki install in CI.
  • In general, ls ../../resources/src from an NPM script returns all the usual mediawiki.* files.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 14 2020, 1:47 PM
Niedzielski updated the task description. (Show Details)May 14 2020, 1:51 PM
Niedzielski added a subscriber: Krinkle.
Krinkle added a comment.EditedMay 14 2020, 9:37 PM

In general, ls ../../resources/src from an NPM script returns all the usual mediawiki.* files.

The intent behind this is fine, but for avoidance of doubt - this specific pattern of ../ is not supported in any job, test or prod code. Extensions must not assume where MediaWiki core is and always use $IP (php), MW_INSTALL_PATH (process env) or other standard ways to discover MediaWiki core. All our MW-related CI and dev environments set these.

MW_INSTALL_PATH would work well for the shell script, thank you. Unfortunately, it's not possible to inject environment variables for type checking except through Webpack or rewriting the interfaces as distributable definitions AFAIK.

(Unrelated: I meant to link this to T246419 earlier where the issue came up.)

Jdlrobson moved this task from Needs triage to Technical on the Vector board.May 15 2020, 4:57 PM