Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Fix Playwright setup on Gitpod #2261

Merged
merged 18 commits into from
Nov 23, 2022
Merged

Conversation

dan-mba
Copy link
Member

@dan-mba dan-mba commented Nov 22, 2022

Fixes Issue

Closes #2257

Changes proposed

Install playwright dependencies on init.
Set Playwright to not run parallel tests on Gitpod

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

@github-actions github-actions bot added small Pull request with less than 10 changed lines waiting-for-reviewers labels Nov 22, 2022
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great having you contribute to this project

Welcome to the community 🤓

If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord chat and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.

Copy link
Member

@eddiejaoude eddiejaoude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

.gitpod.yml Outdated
- name: Install npm dependencies
init: |
npm ci
npx playwright install --with-deps chromium
Copy link
Member

@eddiejaoude eddiejaoude Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't work for me, I still needed to run this command manually to make the test pass 🤔

I wonder why this command doesn't run correctly when building the project on GitHub

@Cahllagerfeld
Copy link
Member

The scripts need to be executed in a custom-dockerfile.
The init task only persists the data inside the workspace directory.
Depending if the tests should be able to run headed, the base image of the dockerfile needs to be gitpod/workspace-full-vnc

@dan-mba
Copy link
Member Author

dan-mba commented Nov 22, 2022

The scripts need to be executed in a custom-dockerfile. The init task only persists the data inside the workspace directory. Depending if the tests should be able to run headed, the base image of the dockerfile needs to be gitpod/workspace-full-vnc

Would the playwright install be the only command needed in the dockerfile or would the npm ci be needed in there too?
Does it make sense to support headed tests or Gitpod, or would it make more sense to to have people run that elsewhere if needed?

@eddiejaoude
Copy link
Member

How do we do it for the finder project? Could we do it similar
https://github.com/EddieHubCommunity/good-first-issue-finder/blob/main/.gitpod.yml

@github-actions github-actions bot added medium Pull request with changed lines between 10 and 30 and removed small Pull request with less than 10 changed lines labels Nov 22, 2022
@github-actions github-actions bot added large Pull request with more than 30 changed lines and removed medium Pull request with changed lines between 10 and 30 labels Nov 22, 2022
@github-actions github-actions bot added medium Pull request with changed lines between 10 and 30 and removed large Pull request with more than 30 changed lines labels Nov 22, 2022
@dan-mba
Copy link
Member Author

dan-mba commented Nov 22, 2022

I think I have it working now.

I was able to install the OS level browser dependencies in the Dockerfile.
But I had to install Chromium in the gitpod.yml command section in order to make it work consistently.

.gitpod.yml Outdated
command: |
npx playwright install chromium
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running this command in the dockerfile, we shouldn't need it here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command in the Dockerfile is install-deps, which performs an apt-get for all the packages required for chromium to run on the OS. Since this uses an OS level package installer it works fine.

The command in .gitpod.yml only installs the chromium browser. This seems to be done in user space but not in the workspace directory that will get persisted. Thus the need to run it in the command section.

I wish there was a better way to do this. The Playwright docs are a bit light on how their browser install tooling actually works. If there was a way to install chromium at the OS level that would work with Playwright that would be the best solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see 👀
An assumption from my side - I didn't test it. Could we potentially run npx playwright install --with-deps chromium in the dockerfile and it takes care of all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and Playwright installs chromium in /home/gitpod/.cache/ms-playwright/chromium-1028/chrome-linux on gitpod.

Should this directory be persisted through the whole container build process?

I tried the install with deps in a previous commit but it didn't work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a way to install chromium in node_modules via the Playwright docs.

I updated the .gitpod.yml to do this in the init section.

@eddiejaoude
Copy link
Member

eddiejaoude commented Nov 23, 2022

Thank you both for continuing to work through this 💪 I know it will help many people 👍

@eddiejaoude
Copy link
Member

It works 🎉

gitpod /workspace/LinkFree (gitpod) $ npm run test

> linkfree@1.9.0 test
> npx playwright test


Running 19 tests using 1 worker
[WebServer] (node:1331) [DEP0128] DeprecationWarning: Invalid 'main' field in '/workspace/LinkFree/node_modules/react-icons/package.json' of 'lib'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
[WebServer] Warning: data for page "/search" (path "/search?username=_test-profile-does-not-exist") is 492 kB which exceeds the threshold of 128 kB, this amount of data can reduce performance.
See more info here: https://nextjs.org/docs/messages/large-page-data
[WebServer] Warning: data for page "/search" is 492 kB which exceeds the threshold of 128 kB, this amount of data can reduce performance.
See more info here: https://nextjs.org/docs/messages/large-page-data
[19/19] [chromium] › search.spec.js:44:6 › find the profile after providing concise name

  10 skipped
  9 passed (43s)

To open last HTML report run:

  npx playwright show-report

Copy link
Member

@eddiejaoude eddiejaoude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow great work Dan 🔥

Thanks @Cahllagerfeld for supporting with this 👍

Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks. 🚀

@eddiejaoude eddiejaoude merged commit 17cb5cf into EddieHubCommunity:main Nov 23, 2022
@dan-mba dan-mba deleted the gitpod branch November 23, 2022 23:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code undefined 🛠 goal: fix undefined medium Pull request with changed lines between 10 and 30 🟨 priority: medium undefined waiting-for-reviewers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to connect to DB in gitpod - tests failing
4 participants