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

Add Emerge snapshot testing #1785

Conversation

rbro112
Copy link
Contributor

@rbro112 rbro112 commented Jul 18, 2024

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Motivation

Adds Emerge snapshots to purchases UI, as RevenueCat has expressed interest and we figured we'd make the process easier 😄 .

Description

Adds the basic integration necessary for getting up and running with Emerge snapshots:

  • Adds the Emerge gradle plugin to the testpurchasesuiandroidcompatibility module.
    • Worth noting that Emerge requires the plugin to be set on an application module vs a library module. @tonidero had mentioned that the Previews we want to snapshot are in :ui:revenuecatui. Given that this application module depends directly on the :ui:revenuecatui module and snapshots use a debug variant, all code should be present from that module, giving Emerge all @Previews automatically.
  • Adds what I believe is the necessary fastlane/CircleCI setup to invoke snapshots, but my experience here is a bit more limited.
  • Updates Compose BOM from 2023.05.01 to 2024.06.00, as Emerge snapshots rely on compose foundation, which can't be resolved without an update. Happy to help test this!

For the best usage, we recommend running snapshots on every commit - all PR commits and main commits. Emerge will run & snapshot all @Preview annotated functions, storing the generated snapshots based on the sha of that upload.

If the commit has a valid baseSha set and we have snapshots for that baseSha, we'll automatically compare the snapshots and let you know if there's any visual changes directly on the PR. See our snapshot docs for all functionality!

Remaining tasks for RevenueCat to implement to complete this:

  • Connect the Emerge GitHub app (docs). This allows us to post status checks on PRs, letting you know when a visual change has occurred.
  • Add the EMERGE_API_TOKEN as a GitHub secret
  • Wire up CircleCI variables to see the sha & baseSha in the Emerge gradle plugin config block. These are what we use for diffing snapshots.
  • Validate the fastlane/CircleCI setup I added is correct and what is intended.

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Really sorry for the delay! This is looking great! Just some small questions and I think we can get it merged

.circleci/config.yml Show resolved Hide resolved
gradle/libs.versions.toml Outdated Show resolved Hide resolved
sha.set("")
// TODO: RevenueCat to set from CircleCi variables
// Should skip setting for main branch uploads
baseSha.set("")
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to check, this will be the sha for the latest commit in main right? I don't think CircleCI gives us this https://circleci.com/docs/variables/? Though we can calculate it through a script of course

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct, needs to be the commit in the default branch (i.e. main) that the PR is based on. Seems we might be able to get it from GitHub data in CircleCI.

Proposition here: let's add this in a future PR. Most snapshots integrations are best as two steps anyway:

  1. Add uploads from all main branch commits. This way we can ensure everything's running properly and we get snapshots for all base builds.
  2. In follow up PR, we add support for PR commits. That way diffs we can test that diffs are working properly.

So this PR will be step 1 above, and you or I can follow with step 2 where we add the baseSha just for PR commits. Sound good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes a lot of sense thank you!

@tonidero tonidero changed the base branch from main to external/rbro112/add-emerge-snapshot-testing September 5, 2024 09:50
Copy link
Contributor

@tonidero tonidero 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 great! Will get this merged so we will start using this soon. Thank you!

@tonidero tonidero merged commit f7b77f6 into RevenueCat:external/rbro112/add-emerge-snapshot-testing Sep 5, 2024
tonidero added a commit that referenced this pull request Sep 6, 2024
### Checklist
- [ ] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-ios` and
hybrids

### Motivation
Adds Emerge snapshots to purchases UI, as RevenueCat has expressed
interest and we figured we'd make the process easier 😄 .

### Description
Adds the basic integration necessary for getting up and running with
Emerge snapshots:

- Adds the Emerge gradle plugin to the
`testpurchasesuiandroidcompatibility` module.
- Worth noting that Emerge requires the plugin to be set on an
`application` module vs a library module. @tonidero had mentioned that
the Previews we want to snapshot are in `:ui:revenuecatui`. Given that
this application module depends directly on the `:ui:revenuecatui`
module and snapshots use a debug variant, all code should be present
from that module, giving Emerge all `@Previews` automatically.
- Adds what I believe is the necessary fastlane/CircleCI setup to invoke
snapshots, but my experience here is a bit more limited.
- Updates Compose BOM from `2023.05.01` to `2024.06.00`, as Emerge
snapshots rely on compose foundation, which can't be resolved without an
update. Happy to help test this!

For the best usage, we recommend running snapshots on every commit - all
PR commits and main commits. Emerge will run & snapshot all `@Preview`
annotated functions, storing the generated snapshots based on the `sha`
of that upload.

If the commit has a valid `baseSha` set and we have snapshots for that
`baseSha`, we'll automatically compare the snapshots and let you know if
there's any visual changes directly on the PR. See our [snapshot
docs](https://docs.emergetools.com/docs/snapshot-testing) for all
functionality!

Remaining tasks to implement to complete this:
- [ ] Wire up CircleCI variables to see the `sha` & `baseSha` in the
Emerge gradle plugin config block. These are what we use for [diffing
snapshots](https://docs.emergetools.com/docs/continuous-integration).
Will do this in follow up PRs

Contributed by @rbro112 in #1785

---------

Co-authored-by: Ryan Brooks <[email protected]>
tonidero added a commit that referenced this pull request Sep 12, 2024
**This is an automatic release.**

### Bugfixes
* Fixes a Paywall Template 7 crash when none of the tiers have any
available products. (#1834) via JayShortway (@JayShortway)
### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `85e1c83` to `5140dbc`
(#1835) via dependabot[bot] (@dependabot[bot])
### Other Changes
* [EXTERNAL] Add Emerge snapshot testing (#1785) by @rbro112 (#1831) via
Toni Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <[email protected]>
Co-authored-by: Toni Rico <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants