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

Use puppeteer-core with custom chromium instead of puppeteer #222

Merged
merged 12 commits into from
Nov 30, 2020
Merged

Use puppeteer-core with custom chromium instead of puppeteer #222

merged 12 commits into from
Nov 30, 2020

Conversation

joshuali925
Copy link
Contributor

@joshuali925 joshuali925 commented Nov 25, 2020

Issue #, if available:

Description of changes:

  • remove puppeteer dependency, use puppeteer-core with custom chromium binary instead
  • change plugin id from opendistroKibanaReports to opendistroReportsKibana for consistency
  • add chromium path parameter to createVisualReport for jest testing
  • update github workflows to build artifacts for windows and linux
  • add s3 bucket path in release workflow
  • use path.posix.normalize instead of path.normalize when verifying URL to accommodate Windows

Caveats

  • Chromium binary has to be downloaded separately if running from source, but will be packed by github actions in the zip artifact
  • Chromium path defaults to ./plugins/opendistroReportsKibana/.chromium/headless_shell which works for the zip artifact, but if running from source it should be ./plugins/kibana-reports/.chromium/headless_shell (Fixed by Use chromium path relative to constant file #236 )
  • Ubuntu needs additional dependencies to run chromium
sudo apt install -y libnss3-dev fonts-liberation libfontconfig1
  • RedHat/CentOS needs additional dependencies to run chromium
sudo yum install -y libnss3.so xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc fontconfig freetype

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment on lines -36 to +38
cookie?: SetCookie
cookie?: SetCookie,
chromiumPath = CHROMIUM_PATH
Copy link
Member

Choose a reason for hiding this comment

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

can you put the optional parameter as the last parameter? So that in the test file, I don't think you need to pass in undefined anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know where the cookie parameter is used, if I swap them whenever you pass in cookie you'll have to pass undefined or chromium path before cookie

Copy link
Member

Choose a reason for hiding this comment

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

In your code, the chromium parameter already has an initializer which uses CHROMIUM_PATH, besides test, I don't think we need to pass in different value for the path

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 your point, that won't work. Never mind, ignore my comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW I tried to mock CHROMIUM_PATH and used jest.requireActual to import other constants in the test file. The constants are correct in the test file, but in visualReportHelper.ts only CHROMIUM_PATH is correct.

That's why I used the optional parameter workaround, if you are more familiar with jest you can try to mock the constant which would be a better solution

@zhongnansu
Copy link
Member

Should we provide the different chromium version somewhere for developers? mac, windows and linux?

@joshuali925
Copy link
Contributor Author

Should we provide the different chromium version somewhere for developers? mac, windows and linux?

they are currently in a release under reporting https://github.com/opendistro-for-elasticsearch/kibana-reports/releases/tag/chromium-1.12.0.0

Copy link
Contributor

@davidcui1225 davidcui1225 left a comment

Choose a reason for hiding this comment

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

LGTM

@joshuali925 joshuali925 marked this pull request as ready for review November 27, 2020 23:01
@joshuali925 joshuali925 merged commit 8b6241e into opendistro-for-elasticsearch:dev Nov 30, 2020
zhongnansu pushed a commit to zhongnansu/kibana-reports that referenced this pull request Dec 4, 2020
…tro-for-elasticsearch#222)

* Use custom chrome binary

* Update chromium path

* Test workflow for al2

* Disable tests temporarily

* Fix workflow

Fix workflow

* Rename opendistroKibanaReports to opendistroReportsKibana

* Update workflows

Fix workflow

Update workflows

Update workflows

* Enable tests in workflows

* Add windows chromium to workflows

* Fix tests

* Use path.posix.normalize to accomondate windows

* Use @types/puppeteer-core
zhongnansu pushed a commit to zhongnansu/kibana-reports that referenced this pull request Dec 7, 2020
…tro-for-elasticsearch#222)

* Use custom chrome binary

* Update chromium path

* Test workflow for al2

* Disable tests temporarily

* Fix workflow

Fix workflow

* Rename opendistroKibanaReports to opendistroReportsKibana

* Update workflows

Fix workflow

Update workflows

Update workflows

* Enable tests in workflows

* Add windows chromium to workflows

* Fix tests

* Use path.posix.normalize to accomondate windows

* Use @types/puppeteer-core
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants