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

✨ Use @percy/cli #306

Merged
merged 4 commits into from
Mar 29, 2021
Merged

✨ Use @percy/cli #306

merged 4 commits into from
Mar 29, 2021

Conversation

wwilsman
Copy link
Contributor

What is this?

There is a new kid on the block, @percy/cli, that takes what @percy/agent has done and makes it more robust, more modular, more extensible, and more feature-rich than @percy/agent can ever be in its current state. This PR brings @percy/cli to this SDK by refactoring the entire SDK from the ground up, including new tests, new CI config, and other niceties. The new @percy/cli has many benefits over @percy/agent, so I won't list all of them here. But importantly, there are a few necessary breaking changes.

Breaking Changes

  • @percy/agent is no longer a dependency, obviously, but neither is @percy/cli. This enables users to install the SDK as a development dependency without requiring the entire SDK umbrella on install (including a lengthy chromium download). When using npx, users will have to use npx @percy/cli ... rather than npx percy, as the latter refers to@percy/agent and has gaps in its version history that would prevent some future releases.

  • To enable normal package script behavior with percy <command>, users will have to install the CLI alongside the SDK – npm install @percy/cli @percy/cypress. The new CLI does not download Chromium on install, and instead does so the first time asset discovery is started. So even when choosing to install the CLI as a development dependency, it has a much smaller footprint than its predecessor.

  • The format of Percy configuration files has changed. Common options can be viewed in the @percy/core package, and previous configuration options can be migrated to the new format using percy config:migrate.

  • The @percy/cypress/task no longer exists. Its previous purpose was so the cy.percySnapshot() command could run a health check without CSP issues. We could utilize the cy.request() command, however it does not return a promise which means request errors cannot be caught for graceful health check failures. However, the cy.request() command internally uses Cypress.backend('http:request', options) which does return a promise. By using this directly, we can not only avoid features we do not want from cy.request() such as retries, logging, and error handling, but also remove the need for registering a health check task altogether.

Repo Changes:

  • Tests were re-written to be functional. The previous tests were visual only and in reality were testing the behavior of @percy/agent using the SDK rather than testing the SDK itself. Coverage reporting has also been added and is a requirement for tests to pass to have complete coverage.

  • GitHub Actions are now the default CI and other CIs do not need to be tested within since this repo should be testing the SDK and not CI integrations. Separate workflows exist for linting and tests so their failures can be reported separately (rather than having tests be cancelled due to failed linting).

  • The changelog and release processes have also been updated to fully utilize GitHub features such as tags and releases. The semantic release bot and several semantic release packages were replaced with release-drafter which utilizes PRs and labels to create changelogs found alongside each release on the releases page.

  • Automatic package releasing is now a semi-manual process due to bots not always being able to correctly guess the proper version number and sometimes releasing the incorrect version. To release, the version number should be bumped appropriately and then the automatically created draft release can be published from the releases page. In the future, we can automate the version bump to reflect the release version to make this process smoother, while still requiring a human to approve the release.

@wwilsman wwilsman added ✨ enhancement New feature or request 💥 breaking Breaking change labels Mar 26, 2021
@wwilsman wwilsman requested a review from Robdel12 March 26, 2021 21:18
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

Excited to see one of the most popular SDKs finally make it to CLI!

However, the cy.request() command internally uses Cypress.backend('http:request', options) which does return a promise. By using this directly, we can not only avoid features we do not want from cy.request() such as retries, logging, and error handling, but also remove the need for registering a health check task altogether.

Love love love dropping that whole thing. All of it existed just for that. Nice work.


No README update? 👀

// Use Cypress's http:request backend task
utils.request.fetch = async function fetch(url, options) {
options = { url, retryOnNetworkFailure: false, ...options };
return Cypress.backend('http:request', options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Slick 🔥

"url": "git+https://github.com/percy/percy-cypress.git"
},
"description": "Cypress client library for visual testing with Percy",
"version": "3.0.0-beta.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

0 or 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're programmers, we start at 0

Copy link
Contributor

Choose a reason for hiding this comment

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

off by one

},
"peerDependencies": {
"cypress": "^3 || ^4 || ^5 || ^6"
"cypress": ">=3"
Copy link
Contributor

Choose a reason for hiding this comment

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

lol duh 🤦🏼

Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

🏁

@wwilsman wwilsman merged commit 65bb189 into master Mar 29, 2021
@wwilsman wwilsman deleted the ww/new-cli branch March 29, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💥 breaking Breaking change ✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants