Page MenuHomePhabricator

GrowthExperiments cypress setup assumes fixed LocalSettings path
Closed, ResolvedPublic

Description

My local MediaWiki setup mirrors the Gerrit repository structure, which means I have the following folders:

  • gerrit/mediawiki/core with a checkout of mediawiki/core
  • gerrit/mediawiki/extensions with checkouts of various repositories under mediawiki/extensions/* in Gerrit
  • gerrit/mediawiki/skins with checkouts of various repositories under mediawiki/skins/* in Gerrit

Using the Dockerfile, I map the extensions/skins to the place where MediaWiki expects them to be:

services:
    mediawiki:
        volumes:
            -  ./:/var/www/html/w:cached
            - ../skins:/var/www/html/w/skins:cached
            - ../extensions:/var/www/html/w/extensions:cached

I have npm installed directly on the host computer (eg. not via any Docker image). This works fine for running MediaWiki itself. However, it turns out npm run cy:open assumes LocalSettings is at ../../LocalSettings.php (relative to the GrowthExperiments checkout). In my setup, that holds true within the Docker containers (but npm is not available there). On the host computer, LocalSettings can be found at ../../core/LocalSettings.php instead.

As a result, if I execute npm run cy:open, I receive the following error message:

Your configFile is invalid: /Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress.config.ts

Error: ENOENT: no such file or directory, open '/Users/urbanecm/unsynced/gerrit/mediawiki/LocalSettings.php'
    at Object.readFileSync (node:fs:455:20)
    at Object. (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/support/LocalSettingsSetup.ts:10:34)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module.m._compile (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:857:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Object.require.extensions. [as .ts] (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object. (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress.config.ts:5:1)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module.m._compile (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:857:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Object.require.extensions. [as .ts] (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at /Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:89:14
    at step (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:44:23)
    at Object.next (/Users/urbanecm/unsynced/gerrit/mediawiki/extensions/GrowthExperiments/cypress/.cache/13.15.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:25:53)

This can be fixed by making the location of LocalSettings configurable.

Event Timeline

Change #1109392 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] cypress: Make location of LocalSettings.php configurable

https://gerrit.wikimedia.org/r/1109392

@Michael The same problem exists in the Selenium tests. I don't run Selenium locally, so it is not a problem for me, and we are apparently (slowly) migrating to Cypress anyway, so maybe we can leave that unresolved? Curious to hear what you think about this!

@Michael The same problem exists in the Selenium tests. I don't run Selenium locally, so it is not a problem for me, and we are apparently (slowly) migrating to Cypress anyway, so maybe we can leave that unresolved? Curious to hear what you think about this!

That sounds fine to me. Thank you for creating a change for Cypress!

Change #1109392 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] cypress: Make location of LocalSettings.php configurable

https://gerrit.wikimedia.org/r/1109392

QA Note: This includes no production code changes.

If so desired, running Cypress locally is supposed to work with little adjustments basically out of the box on most local dev environments. See cypress/README.md for details.