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

playwright-driver: init at 1.30.1 #223382

Merged
merged 1 commit into from
Apr 18, 2023
Merged

playwright-driver: init at 1.30.1 #223382

merged 1 commit into from
Apr 18, 2023

Conversation

teto
Copy link
Member

@teto teto commented Mar 27, 2023

it was actually moved from
pkgs/development/python-modules/playwright/default.nix to its own pkgs/development/web/playwright/driver.nix .

I am trying to package the typescript version of playwright and the browsers are needed there, it's more convenient to split them away from the python module.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@teto teto force-pushed the playwright-browsers branch 4 times, most recently from 63fa8ba to b4d5fc3 Compare March 27, 2023 14:07
@teto teto marked this pull request as ready for review March 27, 2023 14:15
@teto
Copy link
Member Author

teto commented Mar 27, 2023

I wanted to override the driver version to get newer browsers but that was not easy without this.

@teto teto requested a review from mguentner March 27, 2023 14:21
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Mar 27, 2023
@teto teto requested review from yrd and techknowlogick April 9, 2023 11:51
@teto
Copy link
Member Author

teto commented Apr 9, 2023

I've added some reveiwers so we can get this into nixos-23-05

@mguentner
Copy link
Contributor

The split into dedicated packages makes sense to me, however playwright-driver is still not functional regarding firefox and maybe even darwin as a whole as this seems untested 🤷.
Please see my explanation.
Does playwright ff https://nixos.org for you?

There is also #197899 which attempts to fix firefox so that it can be used with playwright.

Copy link
Member

@yrd yrd left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell. Package seems to build as well.

pkgs/development/web/playwright/driver.nix Outdated Show resolved Hide resolved
pkgs/development/web/playwright/driver.nix Outdated Show resolved Hide resolved
@mguentner
Copy link
Contributor

@yrd Unfortunately building says not much here because of the behavior of the original derivation.
The upstream playwright structure is highly complex: On a FHS linux system, playwright will download (at least) a patched chromium, a patched firefox and a custom webkit browser - all as binaries.
The original derivation masks that by forcefully replacing these binaries with unpatched ones from nixpkgs.
This results in the browsers being unusable by playwright as the necessary features are missing.
Luckily chromium from nixpkgs works for simple tests, but of course the patches from playwright are also missing there, some advanced usage might also break.

@yrd
Copy link
Member

yrd commented Apr 10, 2023

Yeah… At the time of writing the original derivation patching up a directory structure that matches what Playwright expects worked okay for both browsers, if I'm remembering correctly. I haven't been keeping up with Playwright development recently, so I'm not sure if something fundamental changed upstream that now actually requires their browser patches for regular operation…

@mguentner
Copy link
Contributor

@yrd: on which system? NixOS / Linux or darwin?

Does playwright ff https://nixos.org work for you in this shell?

{ pkgs ? import <nixpkgs> {}
}:
pkgs.mkShell {
  name = "playwright-environment";
  buildInputs = [
    pkgs.playwright
  ];
  shellHook = ''
    export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true"
    export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright-driver.browsers}"
    export PLAYWRIGHT_BROWSERS_VERSION="${pkgs.playwright-driver.version}"
  '';
}

playwright cr https://nixos.org does work for me

Comment on lines 85 to 87
driver = playwright-driver;
tests = {
inherit driver browsers;
driver = playwright-driver;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
driver = playwright-driver;
tests = {
inherit driver browsers;
driver = playwright-driver;
inherit driver;
tests = {
inherit driver browsers;

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 38 to 41
sha256 = {
x86_64-linux = "0x71b4kb8hlyacixipgfbgjgrbmhckxpbmrs2xk8iis7n5kg7539";
aarch64-linux = "125lih7g2gj91k7j196wy5a5746wyfr8idj3ng369yh5wl7lfcfv";
x86_64-darwin = "0z2kww4iby1izkwn6z2ai94y87bkjvwak8awdmjm8sgg00pa9l1a";
aarch64-darwin = "0qajh4ac5lr1sznb2c471r5c5g2r0dk2pyqz8vhvnbk36r524h1h";
}.${system} or throwSystem;
Copy link
Member

Choose a reason for hiding this comment

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

If we are using finalAttrs above, how is the hash overwriting supposed to work 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.

as usual with overrideAttrs(...: src = ) ? maybe i dont understand

}.${system} or throwSystem;
} ''
export PLAYWRIGHT_BROWSERS_PATH=$out
${driver}/bin/playwright install
Copy link
Member

Choose a reason for hiding this comment

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

I doubt that we are cross friendly right now but we should put driver into nativeBuildInputs to be more ready for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is just code moving around, if someone wants to do cross compilation he can do it in a follow up PR

jq
];
} (''
BROWSERS_JSON=${driver}/package/browsers.json
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be an env? Otherwise we should put it into a nix 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.

this was just copy/pasted from the current derivation

@teto
Copy link
Member Author

teto commented Apr 12, 2023

so I've adopted most of the recommendations but just for context: this is mostly refactoring, moving code from one file to another.
Why did I do that ? I was asked to help with playwright in nix by colleagues and I found the whole thing confusing. from my understanding the top-level package called playwright is not the "standard" one but the python module, which also packages browsers but not exactly as playwright expects them. My colleagues work with chrome so I haven't tested firefox. Basic tests with chrome worked fine but I stilly worry that this may fail in some cornercase without playwright's custom patches. In which case I will have a look again (and https://github.com/NixOS/nixpkgs/pull/197899/files is interesting in that regard).
To sum up, moving this part of the code out of the python package makes it clearer that it is not tied to the python package (rather the opposite) and it made it easier for me to experience with the original @playwright/test node package (as the version is tied to the node package version too).
I would have liked to update @playwright/test too but it takes 5 or 6 hours regenerating the node package set while node2nix works out of the box on it.

@teto teto changed the title playwright-driver: init at 1.27.1 playwright-driver: init at 1.30.1 Apr 17, 2023
--set SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \
--set FONTCONFIG_FILE ${fontconfig}
'' + lib.optionalString withFirefox ''
FIREFOX_REVISION=$(jq -r '.browsers[] | select(.name == "firefox").revision' $BROWSERS_JSON)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove as this is broken (playwright ff https://nixos.org) or integrate this PR #197899 - however it will be easier to review if this is contributed separately.

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 saw it was removed on master, I hesitated to remove it because I preferred to have firefox even if faulty but I followed your advice. I've let some (useless) nix code like withChromium as it may be reused again once we fix+reintroduce firefox

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me know if you approve the PR in which case I'll merge and submit the node "playwright test" package.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. LGTM!

it was actually moved from
pkgs/development/python-modules/playwright/default.nix to its own
pkgs/development/web/playwright/driver.nix .

I am trying to package the typescript version of playwright and the
browsers are needed there, it's more convenient to split them away from the python module.

Careful playwright.browsers is not accessible anymore.

Apply suggestions from code review

Co-authored-by: Yannik Rödel <hey@yannik.info>
@teto teto merged commit 6d9b879 into NixOS:master Apr 18, 2023
@teto teto deleted the playwright-browsers branch April 18, 2023 21:18
@yrd
Copy link
Member

yrd commented Apr 19, 2023

Awesome, thank you @teto !

@teto teto mentioned this pull request Apr 19, 2023
13 tasks
@kalekseev kalekseev mentioned this pull request Jun 4, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants