-
Notifications
You must be signed in to change notification settings - Fork 186
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
Add caching #179
Add caching #179
Conversation
@gladyshcodes is attempting to deploy a commit to the Antiwork Team on Vercel. A member of the Team first needs to authorize it. |
One challenge is:
The function above retrieves normalized component string given X and Y coordinates. The reason it's implemented this way is that currently, Playwright does not support selecting DOM elements using coordinates (see this closed issue). The only way I have found was to use native document func. If you have any other ideas in mind, please suggest 👍 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Would be nice to resolve the conflicts and then I can test your branch locally. |
@m2rads I have resolved conflicts now. You can check it out. |
Refinements / Improvements:
|
@gladyshcodes sorry we made some more changes. Please resolve the conflicts again and I will test soon. Thank you :) |
Hi there @m2rads. Those conflicts actually do not interfere with functionality added. I resolved them 👍 . |
export type BrowserAction = | ||
| "mouse_move" | ||
| "left_click" | ||
| "left_click_drag" | ||
| "right_click" | ||
| "middle_click" | ||
| "double_click" | ||
| "screenshot" | ||
| "cursor_position" | ||
| "github_login" | ||
| "clear_session" | ||
| "type" | ||
| "key" | ||
| "run_callback" | ||
| "navigate" | ||
| "sleep" | ||
| "check_email"; | ||
export enum BrowserActionEnum { | ||
MouseMove = "mouse_move", | ||
LeftClick = "left_click", | ||
LeftClickDrag = "left_click_drag", | ||
RightClick = "right_click", | ||
MiddleClick = "middle_click", | ||
DoubleClick = "double_click", | ||
Screenshot = "screenshot", | ||
CursorPosition = "cursor_position", | ||
GithubLogin = "github_login", | ||
ClearSession = "clear_session", | ||
Type = "type", | ||
Key = "key", | ||
RunCallback = "run_callback", | ||
Navigate = "navigate", | ||
Sleep = "sleep", | ||
CheckMail = "check_mail", | ||
} | ||
|
||
export type BrowserAction = `${BrowserActionEnum}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to use screenshot
browser action and founded it no good to make hard code comparison. That's why I created enum from interface, not touching the interface itself. Now we can do: BrowserActionEnum.Screenshot
@m2rads Build issue resolved, but Vercel pipeline does not re-run. I guess your approval is needed |
packages/shortest/src/cache/cache.ts
Outdated
this.cacheFile = path.join(process.cwd(), ".cache", "cache.json"); | ||
this.lockFile = path.join(process.cwd(), ".cache", "cache.lock"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to put this inside .shortest
folder. Also does this only cache passing test cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to put this inside .shortest folder.
Good point. I will rename it
Also does this only cache passing test cases?
Not entirely sure what you mean. If you are asking whether test file only contains tests that succeeded, then yes
Thanks the build issue is resolved now but I think there might be another issue. When running a test, it caches the steps successfully, but on a consecutive run, it deletes the cache and does the same process. It doesn't seem like the consecutive test is being executed from the cache as it takes the same amount of time to run. cache.mp4 |
@m2rads Hmm that's weird. I have just tried running several tests and it worked fine for me. I didn't try it with new
|
I see. The new test needs setup with Mailosaur. Maybe try a more complicated test that has multiple steps and see if this issue happens. |
@m2rads I have tried with this test, it works:
|
Hhhm seems like this happens when you have multiple test cases. Can you try with more than one test case? |
@m2rads Thank you for caching the bug! I've realized the problem was caused by several factors:
I ran several tests and they pass now: Perf boost: 5.6x @slavingia If you have time, take a look as well, maybe any suggestions? |
Merged in auto fix which led to some new failures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, looks great otherwise!
Bug report:
You can see the video here: https://x.com/madarco/status/1874141497404363128 I guess there needs to be some logic to destroy the cache, so that the spec starts to fail. We'll need to think more on the best way to do that dynamically; we can start by making it very easy (one command) to nuke the cache? |
Issue #124
This PR introduces basic caching mechanism to reduce costs and increase effectiveness of running test suites.
Performance Boost: Achieves an average speedup of 400%-600%, automations like "Find Lionel Messi Wikipedia page" now completing about 5x faster
Flow diagram
Benchmarks
No caching
With caching
Perf boost: 6x