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

chore: add better-sqlite3 dependency #26168

Merged
merged 14 commits into from
Mar 23, 2023

Conversation

ryanthemanuel
Copy link
Collaborator

@ryanthemanuel ryanthemanuel commented Mar 21, 2023

Additional details

This PR coincides with the services PR here: https://github.com/cypress-io/cypress-services/pull/5467

This PR adds better-sqlite3 as a dependency.

The dependency needs to be built for the proper version of electron that Cypress uses, so we set up the rebuild process on post install and binary build.

Steps to test

  • Clone the cypress-services repo and checkout ryanm/chore/better-sqlite3
    • Run yarn
    • Run yarn watch in packages/app-capture-protocol
  • Set CYPRESS_LOCAL_PROTOCOL_PATH to the path to cypress-services/packages/app-capture-protocol/dist/index.js
  • Clone the cypress repo and checkout ryanm/chore/better-sqlite3
    • Run yarn
    • Execute cypress run on a project in record mode with DEBUG set to cypress:*protocol* and ensure you can see the lifecycle events

How has the user experience changed?

n/a

PR Tasks

@ryanthemanuel ryanthemanuel marked this pull request as ready for review March 21, 2023 17:03
@ryanthemanuel ryanthemanuel requested a review from mschile March 21, 2023 17:14
@cypress
Copy link

cypress bot commented Mar 21, 2023

29 flaky tests on run #44926 ↗︎

0 26890 1281 0 Flakiness 29

Details:

chore: add linting to the scripts directory
Project: cypress Commit: 9bc2904995
Status: Passed Duration: 18:54 💡
Started: Mar 23, 2023 4:30 PM Ended: Mar 23, 2023 4:49 PM
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-firefox

View Output Video

Test Artifacts
network stubbing > intercepting request > can delay and throttle a StaticResponse Output
Flakiness  cypress/cypress.cy.js • 3 flaky tests • 5x-driver-firefox

View Output Video

Test Artifacts
... > correctly returns currentRetry Output
... > correctly returns currentRetry Output
... > correctly returns currentRetry Output
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-electron

View Output Video

Test Artifacts
... > stops waiting when an fetch request is canceled Output Video
Flakiness  cypress/cypress.cy.js • 3 flaky tests • 5x-driver-electron

View Output Video

Test Artifacts
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video
Flakiness  create-from-component.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
... > runs generated spec Output Screenshots Video

The first 5 flaky specs are shown, see all 17 specs in Cypress Cloud.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@@ -19,9 +20,12 @@ const setupProtocol = async (url?: string): Promise<AppCaptureProtocolInterface
}

if (script) {
const cypressProtocolDirectory = path.join(os.tmpdir(), 'cypress', 'protocol')

await fs.ensureDir(cypressProtocolDirectory)
Copy link
Member

Choose a reason for hiding this comment

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

I feel like I've seen file permissions issues before (maybe just docker? worth adding a try-catch to safely bail if we fail here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this path will have several errors associated with it that we will be handling later (it's being caught one level higher right now). I'll add a TODO here to make sure this gets addressed when we dig into error handling for initializing the protocol.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed here: 74784cd (#26168)

@@ -37,6 +38,7 @@
"ansi_up": "5.0.0",
"ast-types": "0.13.3",
"base64url": "^3.0.1",
"better-sqlite3": "8.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

typically we document dependency bumps. Should this have a changelog entry to mention we added this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed here: 74784cd (#26168)

@@ -4,6 +4,7 @@
"private": true,
"main": "index.js",
"scripts": {
"build": "electron-rebuild -o better-sqlite3",
Copy link
Member

@emilyrohrbough emilyrohrbough Mar 22, 2023

Choose a reason for hiding this comment

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

How come you didn't update the build-prod script to call yarn build? It seems this would remove the need to update the scripts/binary/build.ts script. Is there a reason to do it as a post-install when building the production binary? If there is a reason, can we add a comment in the scripts/binary/build.ts file?

Copy link
Collaborator Author

@ryanthemanuel ryanthemanuel Mar 22, 2023

Choose a reason for hiding this comment

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

I tried what you suggested first and unfortunately that didn't work. In the binary build we actually do a fresh yarn install with a very minimal postinstall step that does not run build or build-prod so anything we would have done in build-prod earlier would be overridden at that point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems like the rule might be: anything we do to the node_modules dependencies themselves needs to be done here. This includes patching packages and rebuilding native bindings.

Copy link
Member

Choose a reason for hiding this comment

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

👍🏻 Makes sense. I assume you've found that via trial and error 😅

ryanthemanuel and others added 3 commits March 22, 2023 16:53
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
Comment on lines 121 to 126
fs.writeJsonSync(meta.distDir('package.json'), {
...packageJsonContents,
scripts: {
postinstall: 'patch-package',
postinstall: 'patch-package && yarn workspace @packages/server build',
},
}, { spaces: 2 })
Copy link
Member

Choose a reason for hiding this comment

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

add comment that this ensure a correct post-install and the native bindings are re-built for the machine per https://github.com/cypress-io/cypress/pull/26168/files#r1144897619

@ryanthemanuel ryanthemanuel merged commit bbe90ab into feat/protocol Mar 23, 2023
@ryanthemanuel ryanthemanuel deleted the ryanm/chore/better-sqlite3 branch March 23, 2023 17:01
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 29, 2023

Released in 13.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants