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

feat: auto ubuntu packages download for local browsers #1036

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KuznetsovRoman
Copy link
Member

@KuznetsovRoman KuznetsovRoman commented Nov 29, 2024

CI side (collect-ubuntu-browser-dependencies, is not being built):

  • Download browsers, if necessary
  • Resolve direct shared objects dependencies to apt package names per each ubuntu release
  • Save direct dependencies into "src/browser-installer/ubuntu-packages/autogenerated" (which is being packed)
  • Also saves its cache into "collect-ubuntu-browser-dependencies" in order to speed up next launches

Cache is stored in VCS and is splitted to 2 files:

  • Mutual cache. Ubuntu version independent (processed-browsers-linux.json). Removes the need to download browsers each time
  • Release specific cache. Could be different on different ubuntu versions (shared-objects-map-ubuntu-%.json). Removes the need to run "apt-file search" each time

image

Client side (src/browser-installer/ubuntu-packages, being packed):

  • Resolve direct dependencies to full list of apt packages
  • Download and extract them
  • Set LD_LIBRARY_PATH when launching webdriver so it could populate to browser, so browser would use downloaded packages

@@ -8,7 +8,6 @@ export default {
79: 707231,
80: 722374,
81: 737198,
82: 750023,
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed as API is not responding to request "which version of chromedriver should i use with this version of chrome": https://chromedriver.storage.googleapis.com/LATEST_RELEASE_82

name: Collect ubuntu browser dependencies
on:
schedule:
- cron: 0 0 1 * *
Copy link
Member Author

Choose a reason for hiding this comment

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

once per month

@@ -9,10 +9,11 @@
],
"scripts": {
"build": "tsc --build && npm run copy-static && npm run build-bundles",
"copy-static": "copyfiles 'src/browser/client-scripts/*' build",
"copy-static": "copyfiles 'src/browser/client-scripts/*' 'src/**/*.json' build",
Copy link
Member Author

Choose a reason for hiding this comment

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

Also copy these autogenerated json

const [chromeDriverPath] = await Promise.all([
installChromeDriver(chromeVersion),
installChrome(chromeVersion),
shouldInstallUbuntuPackageDependencies ? installUbuntuPackageDependencies() : null,
Copy link
Member Author

Choose a reason for hiding this comment

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

Ensure ubuntu packages are ready before spawning child process

return await Promise.all([
installChrome(browserVersion, { force }),
shouldInstallWebDriver && installChromeDriver(browserVersion, { force }),
needToInstallUbuntuPackages && installUbuntuPackageDependencies(),
Copy link
Member Author

Choose a reason for hiding this comment

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

Ensure ubuntu package are ready (e.g. for devtools)

Comment on lines +84 to +85
await fs.outputJSON(this._sharedObjectsMapPath, sortObject(sharedObjectsMap), { spaces: 4 });
await fs.outputJSON(this._processedBrowsersCachePath, sortObject(processedBrowsers), { spaces: 4 });
Copy link
Member Author

Choose a reason for hiding this comment

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

Using 4 spaces because the linter wants it

Comment on lines +4 to +5
// Those are couldn't be seen with readelf -d
export const EXTRA_FIREFOX_SHARED_OBJECTS = ["libdbus-glib-1.so.2", "libXt.so.6"];
Copy link
Member Author

Choose a reason for hiding this comment

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

Usually there is a note in dynamic section of an elf file "which libraries does it load", but for a long time, starting from the very first versions, firefox needs these 2 shared objects, and they are not recorded in dynamic section of an elf file


logger.log(`Fetched ${browserVersions.length} browser milestones`);

const browsersToDownload = cache.filterProcessedBrowsers(browserVersions);
Copy link
Member Author

Choose a reason for hiding this comment

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

Browsers are only downloaded once
If we would like to add new ubuntu release, we would not need to download any browser

return "libc6";
}

const relevantPackageName = _.minBy(packages, packageName => calcLevenshtein(sharedObject, packageName)) as string;
Copy link
Member Author

Choose a reason for hiding this comment

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

Using levenshtein in order to resolve shared objects to their main packages, and not just to some package, which is more popular (in example, if libnss3.so is used in firefox, it would return "libnss3" even if firefox is more popular)

Copy link
Member Author

Choose a reason for hiding this comment

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

Directory with ubuntu binaries call wrappers

@@ -0,0 +1,43 @@
name: Collect ubuntu browser dependencies
Copy link
Member Author

Choose a reason for hiding this comment

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

Scheduled action:

  • Collects ubuntu dependencies for new browser versions
  • Creates a PR to add dependency if there is any new library
  • If there are no extra dependencies, do nothing.
  • If there is extra browser, but no new dependencies, creates PR to update cache, so it would not need to download the browser later

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-352.ubuntu_deps branch 3 times, most recently from 64a1db9 to dbacdc9 Compare December 1, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant