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

Remove deprecated actions and Playwright API usage #13491

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

planger
Copy link
Contributor

@planger planger commented Mar 14, 2024

What it does

  • Replace usage of deprecated GabrielBB/xvfb-action@v1
  • Replace usage of deprecated <obj>.type(...)

Contributed on behalf of STMicroelectronics.

How to test

Ensure workflows and Playwright tests still work as before.

Follow-ups

We should update https://github.com/eclipse-theia/theia-playwright-template and https://github.com/eclipse-theia/theia-e2e-test-suite accordingly to avoid using the deprecated GH action.

Review checklist

Reminder for reviewers

uses: GabrielBB/xvfb-action@v1
with:
run: yarn performance:startup:electron
shell: bash
Copy link
Contributor Author

@planger planger Mar 14, 2024

Choose a reason for hiding this comment

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

@xai Do you think omitting xvfb will be a problem for Electron? If yes, we'd need to switch to setup-xvfb as gabrielbb-xvfb-action is deprecated. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

We need xvfb because we cannot run Electron headless. So yes, we should switch to the maintained action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, no problem! I updated this PR. Can you please test if this works now? Thank you!

Copy link
Contributor

@xai xai Mar 14, 2024

Choose a reason for hiding this comment

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

I think we need to test by running the workflow, right?
Edit: I am of course testing the code change ;)

@planger planger force-pushed the fix-deprecated-actions branch 2 times, most recently from 75a29ae to a49b209 Compare March 14, 2024 10:43
@planger planger changed the title WIP: Try removing deprecated actions Remove deprecated actions and Playwright API usage Mar 14, 2024
* Replace usage of deprecated GabrielBB/xvfb-action@v1
* Replace usage of deprecated <obj>.type(...)
@planger planger marked this pull request as ready for review March 14, 2024 12:33
@planger planger requested a review from xai March 14, 2024 12:34
@planger planger added the playwright issues related to playwright tests label Mar 14, 2024
@planger planger mentioned this pull request Mar 14, 2024
1 task
Copy link
Contributor

@xai xai 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 very much, @planger, for spotting the unmaintained action we are consuming and for fixing our API calls!

Tested fine locally, i.e., the electron tests are still flaky, but no more flaky than before.

I agree that in the Electron case, we need to replace the unmaintained xvbf-action which had its last real commit in 2021-11.

The replacement used in this PR matches the recommendation in the discontinued xvbf-action and it seems to be actively maintained. It also seems to be used frequently (1/10 of the usage that the discontinued action has, which sounds reasonable to me). In the end, by executing the action, we end up executing this file: https://github.com/coactions/setup-xvfb/blob/main/dist/index.js

I very briefly scanned what it does and I have to mention that it includes odd-looking stuff such as this, which is explained with performance optimization. I did not spot any obvious red flags or outright harmful code, but keep in mind that this is a 4K lines javascript file and I looked at it for 3 minutes, which is not much, especially when considering that I am trying to limit my coffee input this week (read: I feel dumb and slow).

I assume that we need to establish a process for vetting third-party actions anyway at some point, and this workflow currently does not even seem to be executed by schedule or dispatch, so I will approve.

Edit: lol, my approval is, of course, not counting, because I am not a committer. If the actual reviewer finds the time, please also consider checking the 4K lines of javascript of the consumed action linked above.

@marcdumais-work
Copy link
Contributor

The replacement used in this PR matches the recommendation in the discontinued xvbf-action and it seems to be actively maintained. It also seems to be used frequently (1/10 of the usage that the discontinued action has, which sounds reasonable to me). In the end, by executing the action, we end up executing this file: https://github.com/coactions/setup-xvfb/blob/main/dist/index.js

Good catch @xai - indeed it's hard to know for sure that this code is not doing anything we would not want it to. I looked at their issue tracker and noticed this issue, that claims that xvfb is now part of the Ubuntu 22.04 GitHub runner image, and that in consequence using the action is not longer needed, for that OS. It seems that we only use the action on Ubuntu, so maybe we can forego using that action and still be able to run Electron tests?

with:
run: yarn performance:startup:browser

- name: Performance (Electron)
uses: GabrielBB/xvfb-action@v1
uses: coactions/setup-xvfb@v1
with:
run: yarn performance:startup:electron
Copy link
Contributor

Choose a reason for hiding this comment

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

ATM this test suite does not seem to work - however it's the same on master, so it's not a problem caused by this PR.

I added trace "analyseTrace(): profilePath ..." - it seems that the trace files, that we attempt to parse using JSON.parse(), are binary files not json...

$ yarn -s electron rebuild && cd scripts/performance && node electron-performance.js --name 'Electron Frontend Startup' --folder electron --runs 10
native node modules are already rebuilt for electron
analyseTrace(): profilePath: /home/user/theia/scripts/performance/profiles/electron/1.json
[Performance][Electron Frontend Startup][1] Largest Contentful Paint (LCP) failed to obtain a measurement: Unexpected token o in JSON at position 1
Failed to obtain a measurement. The most likely cause is that the performance trace file was incomplete because the script did not wait long enough for "Largest Contentful Paint (LCP)".
SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at analyzeTrace (/home/user/theia/scripts/performance/common-performance.js:151:26)
    at measure (/home/user/theia/scripts/performance/common-performance.js:86:26)
analyseTrace(): profilePath: /home/user/theia/scripts/performance/profiles/electron/2.json
[Performance][Electron Frontend Startup][2] Largest Contentful Paint (LCP) failed to obtain a measurement: Unexpected token o in JSON at position 1
Failed to obtain a measurement. The most likely cause is that the performance trace file was incomplete because the script did not wait long enough for "Largest Contentful Paint (LCP)".
SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at analyzeTrace (/home/user/theia/scripts/performance/common-performance.js:151:26)
    at measure (/home/user/theia/scripts/performance/common-performance.js:86:26)

[...]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you very much for looking into this!
I get the same error (in this PR and on master). I think this workflow file has not been used for a long time, also I don't see any runs of this workflow on GH. I just updated it to avoid leaving the deprecated action there.

@xai
Copy link
Contributor

xai commented Mar 15, 2024

I looked at their issue tracker and noticed this issue, that claims that xvfb is now part of the Ubuntu 22.04 GitHub runner image, and that in consequence using the action is not longer needed, for that OS. It seems that we only use the action on Ubuntu, so maybe we can forego using that action and still be able to run Electron tests?

Wow, nice! Thanks for checking this! This is really great news! If we have the xvfb-run binary in the image, we can save ourselves a lot of trouble.

As it turns out (see coactions/setup-xvfb#21), it is available in our container anyway.
Also pin the Python version to 3.11.

Change-Id: Id8d2416996ea489675ca7e50da59286af1965777
@planger
Copy link
Contributor Author

planger commented Mar 15, 2024

Thank you @xai and @marcdumais-work for your thorough review. I've updated the performance-tests.yml accordingly. However, as you also say, it doesn't work anyway (also on master) and I just updated it to get rid of the deprecated action and close the security risk, once someone picks up the work on this workflow again.

Change-Id: I56905c171081f0e73688d58d670748285cab251c
@marcdumais-work
Copy link
Contributor

marcdumais-work commented Mar 15, 2024

I just updated it to get rid of the deprecated action and close the security risk, once someone picks up the work on this workflow again.

I think that's fair. I was curious to confirm whether the image-built-in xvfb would work - I think we can trigger a manual run once the PR is merged, to confirm that it's at least present.

Copy link
Contributor

@marcdumais-work marcdumais-work left a comment

Choose a reason for hiding this comment

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

LGTM - thanks @planger !

@planger planger merged commit 2c0c211 into eclipse-theia:master Mar 15, 2024
14 checks passed
@planger planger deleted the fix-deprecated-actions branch March 15, 2024 13:02
@planger planger added this to the 1.48.0 milestone Mar 15, 2024
@marcdumais-work
Copy link
Contributor

I think we can trigger a manual run once the PR is merged, to confirm that it's at least present.

Confirmed, I think: we get the same parsing error I noticed locally, that we briefly discussed :

https://github.com/eclipse-theia/theia/actions/runs/8296738478/job/22706349277#step:7:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
playwright issues related to playwright tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants