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

Only run CI e2e tests on approved PRs #6080

Merged
merged 1 commit into from
May 13, 2024
Merged

Conversation

necolas
Copy link
Contributor

@necolas necolas commented May 10, 2024

Avoid running the entire suite of (expensive) e2e tests on every PR that is opened or updated. Only run if PR is approved.

Reference: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-when-a-pull-request-is-approved

Copy link

vercel bot commented May 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2024 10:18pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2024 10:18pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 10, 2024
@etrepum
Copy link
Collaborator

etrepum commented May 10, 2024

It might be nicer to move the e2e tests to a separate workflow file, and maybe also do a single run of e2e tests in the test.yml workflow and a more comprehensive matrix on approval

@necolas
Copy link
Contributor Author

necolas commented May 10, 2024

Yes, I floated some similar ideas as well. At the moment it's assumed that all the e2e tests are being run every time a PR is updated, and every time a merge to main happens. Lexical is way over its CI budget. As a first step, I'd like to validate that a relatively small and quick change can demonstrate reduction in CI costs. If we can do that, I think further organization and optimization sounds great.

ivailop7
ivailop7 previously approved these changes May 10, 2024
@etrepum
Copy link
Collaborator

etrepum commented May 10, 2024

I suggested the separate workflow file because it would be a smaller logical change since the approval stuff could be floated out to one place instead of N different places

@etrepum
Copy link
Collaborator

etrepum commented May 10, 2024

but maybe my understanding of the schema is a bit off, I haven't tried to do it. looks good either way!

@necolas
Copy link
Contributor Author

necolas commented May 10, 2024

Haven't seen this before; cool feature.

image

It looks like some open PRs haven't run the e2e tests. Hard to tell why some open PR have or haven't run all tests.

I suggested the separate workflow file because it would be a smaller logical change since the approval stuff could be floated out to one place instead of N different places

For sure. Same goes for the github.repository_owner == 'facebook' condition

@acywatson
Copy link
Contributor

I agree with this in spirit, but in practice it's gonna slow us down significantly to have to get a stamp before we can see the CI run outcome.

Is there a way to make an exception for codeowners or specific users? (i.e., something like: if it's a maintainer, run on submit, otherwise, run on approve.)

@acywatson
Copy link
Contributor

It looks like some open PRs haven't run the e2e tests. Hard to tell why some open PR have or haven't run all tests.

I believe this is because of the budget issue

@etrepum
Copy link
Collaborator

etrepum commented May 10, 2024

I think what would be budget and velocity friendly would be to run a very limited matrix of e2e before approval (but not in draft), e.g. mac chromium or whatever is cheapest, and then do the full suite later on approval or some other condition that doesn't happen on every commit for every contributor. If there was some parameters around how much these things cost and what the budget are the scope could be widened a bit to cover more combinations (e.g. mac+chromium and mac+chromium+collab). We could even consider ditching some things like legacy events altogether unless that's still important enough to worry about.

Breaking the build merely by contributing too much isn't something I anticipated 😆

@necolas
Copy link
Contributor Author

necolas commented May 10, 2024

Is there a way to make an exception for codeowners or specific users?

There is a way to do that. I looked through recent commits and PRs, and it looks like most of them are created by Meta employees or Lexical collaborators - it would limit the budget impact to exclude maintainers.

I think what @etrepum suggested could be a good balance, e.g., you decide one or two e2e suites to run always, and the rest are deferred until PR approval. Later we could try to exclude more PRs (like this one) from running e2e tests at all; that would help allocate more budget to the PRs that benefit most.

@acywatson
Copy link
Contributor

I think what @etrepum suggested could be a good balance

Yea, this is a good idea.

@necolas
Copy link
Contributor Author

necolas commented May 10, 2024

Once the existing CI workflow is back up and running, I'm happy to keep iterating on feedback until you're happy it doesn't negatively impact development.

.github/workflows/test.yml Outdated Show resolved Hide resolved
Copy link

github-actions bot commented May 10, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 23.93 KB (0%) 479 ms (0%) 344 ms (+27.46% 🔺) 823 ms
packages/lexical-rich-text/dist/LexicalRichText.js 34.56 KB (0%) 692 ms (0%) 1.2 s (+18.6% 🔺) 1.9 s
packages/lexical-plain-text/dist/LexicalPlainText.js 34.51 KB (0%) 691 ms (0%) 1.1 s (+5.2% 🔺) 1.8 s

@necolas
Copy link
Contributor Author

necolas commented May 12, 2024

I mocked the e2e test workflow to make iterating / reviewing faster and cheaper.

PR skips extended tests by default:

image

Added approved "extended-tests" label (name TBD) and extended tests run:

image

Removed label and updated diff, extended tests don't run:

image

Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

This looks like a great approach to me, I think it makes sense (as a follow-up) to add a workflow that automatically adds the label so reviewers don't have to remember to do a second action after approving a PR


jobs:
e2e-tests:
if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'approved')
Copy link
Collaborator

Choose a reason for hiding this comment

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

To bike-shed slightly on the name I would recommend changing the allow label to something like 'extended-tests' or 'e2e-tests' instead of 'approved'. My reasoning behind this is:

  • We may also want to have a deny label like 'no-extended-tests' or 'no-e2e-tests' for PRs that a reviewer knows won't benefit from the full suite
  • A contributor with sufficient privileges working on something that they know would benefit from the full suite could self-label without looking like they are rubber-stamping their own PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Renamed to 'extended-tests'.

An alternative / addition to a "deny label" would be to expand on the paths-ignore to help automatically exclude PRs that only change files like READMEs, etc., which don't need functional testing.

I was also looking at the patch Dominic introduced to run e2e tests with beforeinput disabled - those of you more familiar with the status of "legacy events" will be better placed to determine if they still need as much testing.

with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Mock e2e test
Copy link
Collaborator

Choose a reason for hiding this comment

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

We of course need to un-mock before merge but great idea to make this quick, cheap and easy to verify!

Avoid running the entire suite of (expensive) e2e tests on every PR that
is opened or updated. Only run if PR is approved.

Reference: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-when-a-pull-request-is-approved
acywatson
acywatson previously approved these changes May 12, 2024
Copy link
Contributor

@acywatson acywatson left a comment

Choose a reason for hiding this comment

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

I think it makes sense (as a follow-up) to add a workflow that automatically adds the label so reviewers don't have to remember to do a second action after approving a PR

Makes sense. This lgtm now.

Thanks for working on this, @necolas

@acywatson
Copy link
Contributor

We're waiting on a commit to unmock before we merge, right?

@necolas
Copy link
Contributor Author

necolas commented May 12, 2024

We're waiting on a commit to unmock before we merge, right?

Mock removed.

Thanks for working on this, @necolas

No worries. The Lexical OSS project has some cool features I learnt about too. Very impressed with what you've all done here

Copy link
Contributor

@Sahejkm Sahejkm 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 @necolas for optimising the workflows for budget control.

@acywatson acywatson added the extended-tests Run extended e2e tests on a PR label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants