Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Running Nightly as root in a regular user's session is not supported. #6500

Closed
Th3S4mur41 opened this issue May 11, 2021 · 13 comments
Closed

Comments

@Th3S4mur41
Copy link
Contributor

Running playwright automation in Github CI using docker image fails for Firefox

Github Actions Workflow looks as follow:

jobs:
  test_e2e:
    runs-on: self-hosted
    container:
      image: mcr.microsoft.com/playwright
      options: '--ipc=host --entrypoint /bin/bash'
    steps:
      - uses: actions/checkout@v2
      - run: npm ci --no-optional --no-audit --prefer-offline --progress=false
      - run: npm run ci:e2e

Output is:

 npm run ci:e2e
  shell: sh -e {0}

> @clap/clap-frontend@0.1.0 ci:e2e /__w/clap-ui/clap-ui
> jest -c jest-e2e.config.js

Protocol error (Browser.enable): Browser closed.
==================== Browser output: ====================
<launching> /ms-playwright/firefox-1250/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-8PNwPz -juggler-pipe -silent
<launched> pid=629
[pid=629][err] Running Nightly as root in a regular user's session is not supported.  ($HOME is /github/home which is owned by pwuser.)Error
    at /__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/ffConnection.js:55:63
    at new Promise (<anonymous>)
    at FFConnection.send (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/ffConnection.js:54:16)
    at Function.connect (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/ffBrowser.js:65:24)
    at Firefox._connectToTransport (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/firefox.js:65:38)
    at Firefox._innerLaunch (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/browserType.js:133:36)
    at async ProgressController.run (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/progress.js:76:28)
    at async Firefox.launch (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/browserType.js:78:25)
    at async BrowserServerLauncherImpl.launchServer (/__w/clap-ui/clap-ui/node_modules/playwright/lib/browserServerImpl.js:35:25)
    at async PlaywrightRunner.launchServer (/__w/clap-ui/clap-ui/node_modules/jest-playwright-preset/lib/PlaywrightRunner.js:68:44)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @clap/clap-frontend@0.1.0 ci:e2e: `jest -c jest-e2e.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @clap/clap-frontend@0.1.0 ci:e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2021-05-11T12_50_21_530Z-debug.log
Error: Process completed with exit code 1.
@JoelEinbinder
Copy link
Contributor

@aslushnikov for help with docker.

The code in firefox is in toolkit/xre/nsAppRunner.cpp, and it checks if the directories $HOME, $XDG_RUNTIME_DIR and $XAUTHORITY are owned by the current user. Could you try running with HOME=/root npm run ci:e2e?

@Th3S4mur41
Copy link
Contributor Author

Thanks @JoelEinbinder that solved the issue 👍

@mxschmitt
Copy link
Member

Update: I raised an issue on GitHub side, since it seems not fixable on our side except using HOME=/root as a workaround as Joel has recommended.

@mxschmitt mxschmitt assigned mxschmitt and unassigned aslushnikov May 25, 2021
@aslushnikov
Copy link
Collaborator

Looks like the workaround is good-enough

@mxschmitt
Copy link
Member

mxschmitt commented May 8, 2023

Reopening since this is still relevant and affects the default configuration.

Repro: https://github.com/mxschmitt/firefox-github-actions-container
Upstream bug which implemented it: https://bugzilla.mozilla.org/show_bug.cgi?id=1323302


Actually while looking at it again, it seems working fine: https://github.com/mxschmitt/firefox-github-actions-container

Waiting for new customer reports.

@thewilkybarkid
Copy link

I saw this occur when using the container as a GitHub Actions step: #23388 (comment).

GitHub Actions passes in a HOME variable of /github/home: #23388 (comment)

I tried to override it at the step level (PREreview/prereview.org@8f7b96e), but it didn't apply (it remained /github/home).

Following #23388 (comment), using env HOME=/root npx playwright [...] worked (PREreview/prereview.org@5e2bf81). (Using env is needed as the contents of the step.with.args is equivalent to a Dockerfile CMD.)

I couldn't recreate this locally with Act, and I haven't seen it when using docker run either locally or in GitHub Actions before.

@mxschmitt
Copy link
Member

@thewilkybarkid could you help me reproducing it at the https://github.com/mxschmitt/firefox-github-actions-container repository? (feel free to create a PR there with what I did wrong)

@aslushnikov
Copy link
Collaborator

@thewilkybarkid could you please try running npx playwright test prefixed with HOME=/root ? Like this: https://github.com/mxschmitt/firefox-github-actions-container/pull/3/files

@thewilkybarkid
Copy link

@aslushnikov Yeah, that does get round the problem:

Following #23388 (comment), using env HOME=/root npx playwright [...] worked (PREreview/prereview.org@5e2bf81). (Using env is needed as the contents of the step.with.args is equivalent to a Dockerfile CMD.)

@aslushnikov
Copy link
Collaborator

@thewilkybarkid that's the way to go then. Supplying env to the docker command won't work since it doesn't get propagated inside the docker image.

I'll close this with the given workaround since it seems to be good-enough!

@taylorkline
Copy link

If possible, it'd be great if someone had a moment to update the docs at the following two locations:

@aslushnikov
Copy link
Collaborator

@taylorkline feel free to send us a pull request!

MrGreenTea added a commit to YoungVision-eV/homepage-sveltekit that referenced this issue Sep 14, 2023
MrGreenTea added a commit to YoungVision-eV/homepage-sveltekit that referenced this issue Sep 14, 2023
* Add playwright workflow
* Add html reporter to test workflow
* use playwright image for Github action
* Use selected fonts for consistency and reproducability
* Update playwright
* Workaround for root issue microsoft/playwright#6500
nix6839 added a commit to nix6839/vote-it that referenced this issue Sep 24, 2023
dineshUmasankar added a commit to IEEE-PSH/hackpsh-web that referenced this issue Sep 30, 2023
* Setup Playwright with common browsers

* Update gitignore to add trace files

* chore: update deps [next 13.5]

* e2e testing on push/pull playwright

- Testing via containers to run Playwright Tests

* adding pnpm to install dependencies

- Changed install dependencies step to use pnpm actions

* fix missing dependencies and change to pnpm

- Attempt to fix missing msedge
- Change all npm commands to execute via pnpm

* fix: nightly cannot be run from root

- attempting solution from https://github.com/mxschmitt/firefox-github-actions-container/pull/3/files
- thread: microsoft/playwright#6500

* feat: On Deploy Playwright Testing & Modify Push/pull for Main Only

- On Deploy (Preview and Production), Run Playwright E2E Tests
- Modify Push/Pull to run Playwright E2E Tests only on main/master

* fix: Improve Job Names in Worflow Runs

- Changed Job Names under each playwright testing environment

* fix: Deployment URL is not being hit when Playwright E2E Tests are run

- added Deployment URL via env variable in URL attribute of playwright config

* improve: Removed Redundant Testing Stage & Switched TO E2E Tests on Preview Deployments

- Due to the nature of Vercel Preview, it creates preview deployments for all
branches associated to the project. As such, the E2E tests run on all branches for which
Vercel releases a deployment for (including preview) which applies to every branch.

- We will get stability coverage across all branches on all pushes across the project.
As such, it is not necessary to build and execute a web server on a container to E2E
test again. As the build and execute process is automatically tested and reported by
Vercel.

* Removed WebServer from Playwright

- Running into an issue where WebServer causes issues on workflow run
after deployment with "reuseExistingServer" & URL / Port Already active

- Decided to change local E2E Testing policy to run `pnpm run dev` on a
separate terminal & run pnpm exec playwright test on a separate terminal

* attempt: determining if pnpm commands can execute playwright tests on deploy

* attempt: Playwright Package Missing Fix

* attempt: fix yaml syntax

* fix: Update test to use baseURL

* improve: Added Type Documentation for PLAYWRIGHT_TEST_BASE_URL
j2ghz added a commit to j2ghz/playwright that referenced this issue Oct 27, 2023
microsoft#6500

Signed-off-by: Jozef Hollý <1708197+j2ghz@users.noreply.github.com>
dgozman pushed a commit that referenced this issue Nov 13, 2023
Reference: #6500
(#6500 (comment))

It seems that this is now required, so this PR applies that to the docs.

Signed-off-by: Jozef Hollý <1708197+j2ghz@users.noreply.github.com>
ships added a commit to Docmaps-Project/docmaps that referenced this issue Nov 13, 2023
* use pre-installed playwritght container for widget-tests

* use HOME=root workaround for firefox

-> see microsoft/playwright#6500 (thanks, @thewilkybarkid !)
tajdeluca added a commit to tajdeluca/portfolio that referenced this issue Jan 1, 2024
tajdeluca added a commit to tajdeluca/portfolio that referenced this issue Jan 2, 2024
* Refactor project structure

* Update to nuxt v3

* Fix build

* Fix categorization and links

* Remove file that should be ignored

* Fix build

* Fix test run

* Update CI tasks
- Increment versions to improve performance and upload the right directory

* Fix dependency tree

* Allow optional dependencies to be installed

* Regenerate package lock

* Fix artifact download version

* Fix feature test step

* Add workaround for browser...
- See: microsoft/playwright#6500

* Ensure we don't build twice for tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants