Page MenuHomePhabricator

Running `cypress` in Wikimedia CI requires unusual env variables
Open, Needs TriagePublic

Description

As we discovered in T361520, running cypress in Wikimedia CI requires unusual env variables: https://codesearch.wmcloud.org/search/?q=CYPRESS_CACHE_FOLDER. A workaround has been applied in Cite and EntitySchema, but I feel like this should somehow be configured in CI itself, especially as those are not needed for local development. They were also apparently not needed until recently (see that task), what changed?

Event Timeline

hashar subscribed.

Here is some context about CI:

  • the Docker images have the environment variables:
    • XDG_CACHE_HOME=/cache , that is a bind mount from the host and anything in that path ends up being saved in the central cache (nicknamed Castor)
    • XDG_CONFIG_HOME=/tmp/xdg-config-home
  • containers run as user nobody which has the home directory set to the directory /nonexistent which is intentionally not existent

At a quick glance, Cypress invokes return cachedir('Cypress') which is cachedir which does:

const cacheHome = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache')

The binary should thus be somewhere under /cache/Cypress. Some possibilities to assist debug is to hack your npm script to add:

  • finding the path find /cache -type f -name Cypress || : : will show the file if it exists
  • use DEBUG=cypress:cli which enables its debug log and would output something such as:
cypress:cli checking if executable exists /cache/Cypress/13.6.1/Cypress/Cypress +2ms
cypress:cli Binary is executable? : true +2ms
cypress:cli binaryDir is  /cache/Cypress/13.6.1/Cypress +0ms
cypress:cli Reading binary package.json from: /cache/Cypress/13.6.1/Cypress/resources/app/package.json +0ms
cypress:cli Found binary version 13.6.1 installed in: /cache/Cypress/13.6.1/Cypress +4ms
cypress:cli { verified: true } +5ms
cypress:cli is Verified ? true +2ms

Maybe Cypress uses XDG_CONFIG_HOME which is under /tmp and indeed is not saved/restored.

Change #1016618 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/extensions/Cite@master] [DO NOT SUBMIT] Cypress with debugging

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

Tried it with find / -type f -name Cypress || : and that yields nothing. Thus essentially npm ci does not install the Cypress binary blob. Cypress thus fails later when searching it:

checking if executable exists /cache/Cypress/13.6.1/Cypress/Cypress
The cypress npm package is installed, but the Cypress binary is missing.

Who knows? That is a mystery, I don't know anything about Cypress or why it would not install the binary.

Change #1016618 abandoned by Hashar:

[mediawiki/extensions/Cite@master] [DO NOT SUBMIT] Cypress with debugging

Reason:

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