Allow downloading chromium in a directory outside node_modules
The problem
I am running percy snapshot in my CI pipeline and it currently downloads chromium everytime. I have tried setting PERCY_BROWSER_EXECUTABLE=true but that doesn't help because npm ci deletes node_modules at the start and for yarn we don't cache node_modules but the yarn cache folder (.yarn/cache for berry).
Environment
- Node version: 16
@percy/cliversion: 1.0.0-beta.76- Version of Percy SDK you’re using:
- If needed, a build or snapshot ID:
- OS version: ubuntu
- Type of shell command-line [interface]: bash
Details
There should be a global directory for caching/downloading chromium for percy. Similar to how Cypress stores it's binaries in ~/.cache/Cypress and we can cache that separately from node_modules.
See cypress docs for more details: https://docs.cypress.io/guides/continuous-integration/introduction#Caching
Debug logs
First Build: https://github.com/rohit-gohri/redocusaurus/actions/runs/1975488916/attempts/1 Second Build: https://github.com/rohit-gohri/redocusaurus/runs/5526059529?check_suite_focus=true
Both of them have the logs
YN0000: │ @percy/core@npm:1.0.0-beta.76 STDOUT [percy] Downloading Chromium 885264...
➤ YN0000: │ @percy/core@npm:1.0.0-beta.76 STDOUT [percy] Successfully downloaded Chromium 885264
Code to reproduce issue
Github Workflow: https://github.com/rohit-gohri/redocusaurus/blob/56b2e916f385cdff14c5466f045370952c1f75d2/.github/workflows/e2e.yml
For context, the Puppeteer v19.00 update moved the Chromium binary download location to ~/.cache/puppeteer (global) from the previous Puppeteer node_modules .local-chromium (local) location
Looks like Percy uses the previous .local-chromium location
https://github.com/percy/cli/blob/bf551295a8a618502bb2db92ff302e19dc956b51/packages/core/src/install.js#L129
You might see incompatibilities between expected Chromium versions but you can let Percy use the new location:
Config file .percy.js
const { executablePath } = require('puppeteer')
module.exports = {
discovery: {
launchOptions: {
executable: executablePath()
}
},
version: 2
}