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

feat: Enable TurboSnap ⚡ 🤑 (I don't know if this will work.) #4768

Closed
wants to merge 1 commit into from

Conversation

AshCorr
Copy link
Member

@AshCorr AshCorr commented Apr 28, 2022

Update

Reviving as #4891 didn't make any significant dents. This does still mean we can't squash merge, but hopefully as a department, we might be able to feedback to the Chromatic team that this does break workflows and help find a solution.

This can run as a test for a ~week to help us assess whether we have confidence that it does alert us to all changes, and what savings it might make.

This has been recommended by our friends at Chromatic.

What does this change?

Enables TurboSnap https://www.chromatic.com/docs/turbosnap on Chromatic builds.

How?

TurboSnap looks at the Webpack dependency graph to figure out what components have changed between two commits and then uses that information to restrict snapshots to components that have changed.

Why?

It's starting to get fairly costly to run Chromatic tests on every single commit, some quick napkin maths would suggest that we use ~10USD per commit. I think we're all agreed that Chromatic is an amazing tool and that we should keep using it, but we should try and look at ways we can reduce its cost.

Potential Issues

Pull requests

According to the Chromatic docs TurboSnap isn't exactly compatible with PR's due to how it works out changes - BUT, I think this incompatibility won't actually cause us too many issues... As I understand the problem is that Chromatic will ignore approvals on any previous commits and re-request approvals on changes that have already been approved (earlier commits in the PR)

It might be a little annoying to re-approve changes, but maybe its worth it for the cost save?

Sqush & Merge

The "Squash & Merge" merge option that Github provides might cause issues.

@github-actions
Copy link

Size Change: 0 B

Total Size: 1.63 MB

ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/1384.legacy.********************.js 3.31 kB
dotcom-rendering/dist/1490.********************.js 5.29 kB
dotcom-rendering/dist/2270.********************.js 3.94 kB
dotcom-rendering/dist/2270.legacy.********************.js 4.42 kB
dotcom-rendering/dist/2480.********************.js 4.14 kB
dotcom-rendering/dist/2670.********************.js 3.09 kB
dotcom-rendering/dist/2856.legacy.********************.js 7.33 kB
dotcom-rendering/dist/2947.********************.js 2.6 kB
dotcom-rendering/dist/2947.legacy.********************.js 2.68 kB
dotcom-rendering/dist/3178.legacy.********************.js 6.17 kB
dotcom-rendering/dist/3388.legacy.********************.js 5.42 kB
dotcom-rendering/dist/3515.********************.js 22.3 kB
dotcom-rendering/dist/3515.legacy.********************.js 24.7 kB
dotcom-rendering/dist/3584.********************.js 1.8 kB
dotcom-rendering/dist/3584.legacy.********************.js 1.8 kB
dotcom-rendering/dist/3747.legacy.********************.js 31 kB
dotcom-rendering/dist/4043.legacy.********************.js 2.74 kB
dotcom-rendering/dist/5226.********************.js 5.72 kB
dotcom-rendering/dist/5226.legacy.********************.js 6.17 kB
dotcom-rendering/dist/53.********************.js 4.15 kB
dotcom-rendering/dist/53.legacy.********************.js 4.15 kB
dotcom-rendering/dist/5334.********************.js 5.09 kB
dotcom-rendering/dist/5436.legacy.********************.js 2.68 kB
dotcom-rendering/dist/5976.********************.js 4.78 kB
dotcom-rendering/dist/6342.********************.js 2.69 kB
dotcom-rendering/dist/6400.********************.js 21.5 kB
dotcom-rendering/dist/6400.legacy.********************.js 21.5 kB
dotcom-rendering/dist/6995.********************.js 33.3 kB
dotcom-rendering/dist/7576.********************.js 4.62 kB
dotcom-rendering/dist/7576.legacy.********************.js 5.06 kB
dotcom-rendering/dist/7750.legacy.********************.js 4.3 kB
dotcom-rendering/dist/7800.********************.js 11.3 kB
dotcom-rendering/dist/8129.legacy.********************.js 11.8 kB
dotcom-rendering/dist/9439.legacy.********************.js 3.22 kB
dotcom-rendering/dist/9485.legacy.********************.js 2.92 kB
dotcom-rendering/dist/9595.********************.js 7.19 kB
dotcom-rendering/dist/9804.********************.js 2.78 kB
dotcom-rendering/dist/9804.legacy.********************.js 2.89 kB
dotcom-rendering/dist/AlreadyVisited-importable.********************.js 4.52 kB
dotcom-rendering/dist/AlreadyVisited-importable.legacy.********************.js 4.52 kB
dotcom-rendering/dist/atomIframe.********************.js 1.76 kB
dotcom-rendering/dist/atomIframe.legacy.********************.js 2.03 kB
dotcom-rendering/dist/AudioAtomWrapper-importable.********************.js 460 B
dotcom-rendering/dist/AudioAtomWrapper-importable.legacy.********************.js 518 B
dotcom-rendering/dist/bootCmp.********************.js 8.01 kB
dotcom-rendering/dist/bootCmp.legacy.********************.js 11.6 kB
dotcom-rendering/dist/Branding-importable.********************.js 3.99 kB
dotcom-rendering/dist/Branding-importable.legacy.********************.js 4 kB
dotcom-rendering/dist/braze-web-sdk-core.********************.js 36.1 kB
dotcom-rendering/dist/braze-web-sdk-core.legacy.********************.js 36.1 kB
dotcom-rendering/dist/BrazeMessaging-importable.********************.js 9.56 kB
dotcom-rendering/dist/BrazeMessaging-importable.legacy.********************.js 10.3 kB
dotcom-rendering/dist/CalloutBlockComponent-importable.********************.js 7.1 kB
dotcom-rendering/dist/CalloutBlockComponent-importable.legacy.********************.js 7.47 kB
dotcom-rendering/dist/ChartAtomWrapper-importable.********************.js 262 B
dotcom-rendering/dist/ChartAtomWrapper-importable.legacy.********************.js 272 B
dotcom-rendering/dist/CommentCount-importable.********************.js 6.29 kB
dotcom-rendering/dist/CommentCount-importable.legacy.********************.js 6.46 kB
dotcom-rendering/dist/CommercialMetrics-importable.********************.js 7 kB
dotcom-rendering/dist/CommercialMetrics-importable.legacy.********************.js 7.55 kB
dotcom-rendering/dist/CoreVitals-importable.********************.js 6.3 kB
dotcom-rendering/dist/CoreVitals-importable.legacy.********************.js 6.51 kB
dotcom-rendering/dist/DiscussionContainer-importable.********************.js 6.35 kB
dotcom-rendering/dist/DiscussionContainer-importable.legacy.********************.js 6.66 kB
dotcom-rendering/dist/DiscussionMeta-importable.********************.js 6.74 kB
dotcom-rendering/dist/DiscussionMeta-importable.legacy.********************.js 6.91 kB
dotcom-rendering/dist/DocumentBlockComponent-importable.********************.js 2.95 kB
dotcom-rendering/dist/DocumentBlockComponent-importable.legacy.********************.js 3.05 kB
dotcom-rendering/dist/dynamicImport.********************.js 2.9 kB
dotcom-rendering/dist/dynamicImport.legacy.********************.js 3.19 kB
dotcom-rendering/dist/EditionDropdown-importable.********************.js 3.69 kB
dotcom-rendering/dist/EditionDropdown-importable.legacy.********************.js 3.75 kB
dotcom-rendering/dist/EmbedBlockComponent-importable.********************.js 2.84 kB
dotcom-rendering/dist/EmbedBlockComponent-importable.legacy.********************.js 2.92 kB
dotcom-rendering/dist/embedIframe.********************.js 1.76 kB
dotcom-rendering/dist/embedIframe.legacy.********************.js 2.04 kB
dotcom-rendering/dist/EnhancePinnedPost-importable.********************.js 6.14 kB
dotcom-rendering/dist/EnhancePinnedPost-importable.legacy.********************.js 6.72 kB
dotcom-rendering/dist/FilterKeyEventsToggle-importable.********************.js 3.19 kB
dotcom-rendering/dist/FilterKeyEventsToggle-importable.legacy.********************.js 3.25 kB
dotcom-rendering/dist/FocusStyles-importable.********************.js 4.71 kB
dotcom-rendering/dist/FocusStyles-importable.legacy.********************.js 4.77 kB
dotcom-rendering/dist/frontend.server.js 432 kB
dotcom-rendering/dist/ga.********************.js 3.76 kB
dotcom-rendering/dist/ga.legacy.********************.js 4.03 kB
dotcom-rendering/dist/GetMatchNav-importable.********************.js 11.9 kB
dotcom-rendering/dist/GetMatchNav-importable.legacy.********************.js 12.3 kB
dotcom-rendering/dist/GetMatchStats-importable.********************.js 9.08 kB
dotcom-rendering/dist/GetMatchStats-importable.legacy.********************.js 9.93 kB
dotcom-rendering/dist/GetMatchTabs-importable.********************.js 5.89 kB
dotcom-rendering/dist/GetMatchTabs-importable.legacy.********************.js 6.09 kB
dotcom-rendering/dist/guardian-braze-components-banner.********************.js 11.1 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 10.3 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.********************.js 11.1 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.********************.js 10.1 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 8.71 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.********************.js 10.2 kB
dotcom-rendering/dist/GuideAtomWrapper-importable.********************.js 263 B
dotcom-rendering/dist/GuideAtomWrapper-importable.legacy.********************.js 274 B
dotcom-rendering/dist/initDiscussion.********************.js 10.2 kB
dotcom-rendering/dist/initDiscussion.legacy.********************.js 10.5 kB
dotcom-rendering/dist/InstagramBlockComponent-importable.********************.js 2.96 kB
dotcom-rendering/dist/InstagramBlockComponent-importable.legacy.********************.js 3.04 kB
dotcom-rendering/dist/InteractiveBlockComponent-importable.********************.js 7.05 kB
dotcom-rendering/dist/InteractiveBlockComponent-importable.legacy.********************.js 7.29 kB
dotcom-rendering/dist/islands.********************.js 10.4 kB
dotcom-rendering/dist/islands.legacy.********************.js 11.2 kB
dotcom-rendering/dist/KnowledgeQuizAtomWrapper-importable.********************.js 268 B
dotcom-rendering/dist/KnowledgeQuizAtomWrapper-importable.legacy.********************.js 280 B
dotcom-rendering/dist/LabsHeader-importable.********************.js 8.27 kB
dotcom-rendering/dist/LabsHeader-importable.legacy.********************.js 8.42 kB
dotcom-rendering/dist/Links-importable.********************.js 5.6 kB
dotcom-rendering/dist/Links-importable.legacy.********************.js 5.67 kB
dotcom-rendering/dist/LiveBlogEpic-importable.********************.js 5.65 kB
dotcom-rendering/dist/LiveBlogEpic-importable.legacy.********************.js 3.96 kB
dotcom-rendering/dist/Liveness-importable.********************.js 3.31 kB
dotcom-rendering/dist/Liveness-importable.legacy.********************.js 5.81 kB
dotcom-rendering/dist/MapEmbedBlockComponent-importable.********************.js 7.8 kB
dotcom-rendering/dist/MapEmbedBlockComponent-importable.legacy.********************.js 8.1 kB
dotcom-rendering/dist/MostViewedFooterData-importable.********************.js 12.4 kB
dotcom-rendering/dist/MostViewedFooterData-importable.legacy.********************.js 10.3 kB
dotcom-rendering/dist/MostViewedRightWrapper-importable.********************.js 7.19 kB
dotcom-rendering/dist/MostViewedRightWrapper-importable.legacy.********************.js 7.44 kB
dotcom-rendering/dist/newsletterEmbedIframe.********************.js 1.92 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.********************.js 2.18 kB
dotcom-rendering/dist/OnwardsLower-importable.********************.js 14.1 kB
dotcom-rendering/dist/OnwardsLower-importable.legacy.********************.js 14.5 kB
dotcom-rendering/dist/OnwardsUpper-importable.********************.js 18.9 kB
dotcom-rendering/dist/OnwardsUpper-importable.legacy.********************.js 19.4 kB
dotcom-rendering/dist/ophan.********************.js 7.11 kB
dotcom-rendering/dist/ophan.legacy.********************.js 7.33 kB
dotcom-rendering/dist/PersonalityQuizAtomWrapper-importable.********************.js 271 B
dotcom-rendering/dist/PersonalityQuizAtomWrapper-importable.legacy.********************.js 282 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.********************.js 263 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.legacy.********************.js 274 B
dotcom-rendering/dist/PulsingDot-importable.********************.js 1.66 kB
dotcom-rendering/dist/PulsingDot-importable.legacy.********************.js 1.76 kB
dotcom-rendering/dist/QandaAtomWrapper-importable.********************.js 262 B
dotcom-rendering/dist/QandaAtomWrapper-importable.legacy.********************.js 273 B
dotcom-rendering/dist/ReaderRevenueDev-importable.********************.js 4.58 kB
dotcom-rendering/dist/ReaderRevenueDev-importable.legacy.********************.js 4.6 kB
dotcom-rendering/dist/readerRevenueDevUtils.********************.js 3.35 kB
dotcom-rendering/dist/readerRevenueDevUtils.js 2.34 kB
dotcom-rendering/dist/readerRevenueDevUtils.legacy.********************.js 4.4 kB
dotcom-rendering/dist/ReaderRevenueLinks-importable.********************.js 5.08 kB
dotcom-rendering/dist/ReaderRevenueLinks-importable.legacy.********************.js 5.46 kB
dotcom-rendering/dist/relativeTime.********************.js 2.3 kB
dotcom-rendering/dist/relativeTime.legacy.********************.js 2.57 kB
dotcom-rendering/dist/RichLinkComponent-importable.********************.js 8.48 kB
dotcom-rendering/dist/RichLinkComponent-importable.legacy.********************.js 8.65 kB
dotcom-rendering/dist/sentry.********************.js 684 B
dotcom-rendering/dist/sentry.legacy.********************.js 691 B
dotcom-rendering/dist/sentryLoader.********************.js 5.08 kB
dotcom-rendering/dist/sentryLoader.legacy.********************.js 8.02 kB
dotcom-rendering/dist/SetABTests-importable.********************.js 8.65 kB
dotcom-rendering/dist/SetABTests-importable.legacy.********************.js 9.19 kB
dotcom-rendering/dist/ShareCount-importable.********************.js 6.39 kB
dotcom-rendering/dist/ShareCount-importable.legacy.********************.js 6.57 kB
dotcom-rendering/dist/shimport.********************.js 2.78 kB
dotcom-rendering/dist/shimport.legacy.********************.js 2.79 kB
dotcom-rendering/dist/SignInGateMain.********************.js 4.49 kB
dotcom-rendering/dist/SignInGateMain.js 2.87 kB
dotcom-rendering/dist/SignInGateMain.legacy.********************.js 4.59 kB
dotcom-rendering/dist/SignInGateSelector-importable.********************.js 5.43 kB
dotcom-rendering/dist/SignInGateSelector-importable.legacy.********************.js 5.78 kB
dotcom-rendering/dist/SlotBodyEnd-importable.********************.js 9.35 kB
dotcom-rendering/dist/SlotBodyEnd-importable.legacy.********************.js 10.7 kB
dotcom-rendering/dist/SpotifyBlockComponent-importable.********************.js 7.72 kB
dotcom-rendering/dist/SpotifyBlockComponent-importable.legacy.********************.js 8.01 kB
dotcom-rendering/dist/StickyBottomBanner-importable.********************.js 8.99 kB
dotcom-rendering/dist/StickyBottomBanner-importable.legacy.********************.js 11 kB
dotcom-rendering/dist/SubNav-importable.********************.js 6.01 kB
dotcom-rendering/dist/SubNav-importable.legacy.********************.js 6.2 kB
dotcom-rendering/dist/TimelineAtomWrapper-importable.********************.js 264 B
dotcom-rendering/dist/TimelineAtomWrapper-importable.legacy.********************.js 274 B
dotcom-rendering/dist/TopRightAdSlot-importable.********************.js 2.24 kB
dotcom-rendering/dist/TopRightAdSlot-importable.legacy.********************.js 2.27 kB
dotcom-rendering/dist/TweetBlockComponent-importable.********************.js 1.8 kB
dotcom-rendering/dist/TweetBlockComponent-importable.legacy.********************.js 1.79 kB
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.********************.js 2.94 kB
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.legacy.********************.js 3.03 kB
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.********************.js 7.82 kB
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.legacy.********************.js 8.1 kB
dotcom-rendering/dist/VineBlockComponent-importable.********************.js 2.77 kB
dotcom-rendering/dist/VineBlockComponent-importable.legacy.********************.js 2.85 kB
dotcom-rendering/dist/YoutubeBlockComponent-importable.********************.js 8.47 kB
dotcom-rendering/dist/YoutubeBlockComponent-importable.legacy.********************.js 8.82 kB

compressed-size-action

@oliverlloyd
Copy link
Contributor

I'm a bit cautious with this change. My feeling is we probably want to lean more towards spending extra money and having better test coverage/dev ex vs. reduce coverage and saving money.

How much is test coverage worth? It's hard to quantify but I think that it's true that the benefit we gain from having such a wide suite of regression tests would not be possible to replace with one QA engineer.

In theory if this feature delivers on what it offers then we get the best of both worlds but I think we should only add the complexity and risk if we actually think we have a problem here. Maybe the extra cost we're spending is worth it and the business would prefer to have the increased confidence?

@AshCorr
Copy link
Member Author

AshCorr commented Apr 28, 2022

In theory if this feature delivers on what it offers then we get the best of both worlds but I think we should only add the complexity and risk if we actually think we have a problem here. Maybe the extra cost we're spending is worth it and the business would prefer to have the increased confidence?

Ideally we wouldn't have any reduction in test coverage, but I don't really know enough about how this works to know for sure that it won't reduce coverage.

From my perspective, I'm hesitant to add things like breakpoints to any stories I create because I know that by doing that I'm adding a not insignificant cost to every commit for the foreseable future of DCR. Even if its a cost the business is willing to accept I would still personally hesitate to do it because I'm a bit of a scrooge. If I knew that something wasn't going to add any extra cost I'd quite happily add breakpoints to every component and enable cross browser testing.

@OllysCoding
Copy link
Contributor

I find this an incredibly interesting idea, but I also have quite a lot of hesitancy towards it.

First of all I think it's important that as developers we are not worrying about 'cost per commit', or the cost of PRs at all. Commits, PRs, CI, testing, these are all fundamentals of our job and it's the businesses responsibility to provide us with the funds required to operate properly.

I think from that it's important to recognise the value that Chromatic adds to our work as developers. In my opinion the value is unquantifiable, but it's safe to say that in terms of our output as a team, it's worth at least 2-3 additional developers in the safety and confidence it gives us to work quickly and make changes ~ the starting salary for a mid level developer is £49,600.


Ideological stuff out of the way, my technical fear of this change is that we will end up missing changes, especially since our webpack project is quite a complex mix between SSR and client rendering.

The only way to find out how well it works of course would be to test it! The best way to do this would be to open some test PRs based off of this branch, and make some changes in key areas of the site ~ layouts, rendering components, decidePalette, etc.

The above would give us a solid idea of whether this works at all - essential to us considering this as a workable solution for DCR!

If successful, I'd recommend that we then spend some time considering the risk of edge cases, if they can be accounted for another way (such as running a full chromatic check once a PR has been approved, but not on earlier commits?).

@JamieB-gu
Copy link
Contributor

especially since our webpack project is quite a complex mix between SSR and client rendering.

Hold on, which webpack config does it use? I was assuming it would use Storybook's webpack rather than attempt to understand all the different ways a project's own webpack could be set up? The one configured in .storybook/main.js?

@OllysCoding
Copy link
Contributor

The one configured in .storybook/main.js

I would imagine this one too - but this doesn't really help my discomfort, I don't know storybook bundles or interprets islands for example, we'd want to test if it would pick up a change to an island the way we'd expect!

The main.js webpack config is a modified version of storybooks config, which also means its hard for us to get a clear picture of exactly what its doing under the hood, and it also means it could change in ways we might not anticipate

@AshCorr
Copy link
Member Author

AshCorr commented Apr 28, 2022

Worth trialing this for a day or two to see how it reacts to our codebase?

@OllysCoding
Copy link
Contributor

Worth trialing this for a day or two to see how it reacts to our codebase?

I'd prefer if we trialled it in specific use cases by opening PRs with the feature enabled in the github action config for that branch, and looking at the output compared to having it disabled, as this will give us much more explicit data on how it works!

Copy link
Contributor

@jlieb10 jlieb10 left a comment

Choose a reason for hiding this comment

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

LGTM (this is in regards to the code change itself - not the ideological conversation)

@AshCorr
Copy link
Member Author

AshCorr commented Apr 28, 2022

I'd prefer if we trialled it in specific use cases by opening PRs with the feature enabled in the github action config for that branch, and looking at the output compared to having it disabled, as this will give us much more explicit data on how it works!

I can try doing this, I think GHA only runs on the version of the workflow thats on the main branch, not the one thats on the branch. Might be able to setup a condition in the main workflow to change the behaviour based on what branch its on.

(or see if i can get hold of a chromatic key to run all this locally...)

@OllysCoding
Copy link
Contributor

I think GHA only runs on the version of the workflow thats on the main branch

Ah I didn't know this, I assumed it would always use the one in the current branch! My bad sorry

Could you create a new chromatic workflow that targets a specific branch or branches you can use for testing?

e.g

# chromatic-turbo.yaml
on:
  push:
    branches:
      - chromatic-test-1
      -  chromatic-test-2

... chromatic stuff ...

@AshCorr
Copy link
Member Author

AshCorr commented Apr 28, 2022

Could you create a new chromatic workflow that targets a specific branch or branches you can use for testing?

Thats a much better idea than what I came up with, I'll give it a go tomorrow!

@bryophyta
Copy link
Contributor

bryophyta commented Apr 28, 2022

Update: This may or not be relevant now, having just seen the last couple of messages in the thread, but I'll leave it up in case it is of use:

I had also thought that GHA would only use the workflow from the main branch, but our experience testing out #4773 today suggests that it does actually run workflow from the branch being PRed. (Are you able to confirm that @mxdvl ?)

@AshCorr
Copy link
Member Author

AshCorr commented Apr 28, 2022

I had also thought that GHA would only use the workflow from the main branch, but our experience testing out #4773 today suggests that it does actually run workflow from the branch being PRed. (Are you able to confirm that @mxdvl ?)

Ooh, thats a little bit scary! I think it is configurable in the repo settings but I assumed it had been set to always use the main branch (for security)

EDIT: Apparently theres an "Approval" required for Forks to run their version of a workflow, but branches in the main repo itself are apparently not restricted at all.

@AshCorr
Copy link
Member Author

AshCorr commented May 3, 2022

Tested this with a couple of cases, including islands... It seemed to be able to identify storybook files that depend on changed components but had issues identifying Stories generated using storiesOf

Closing this until storybookjs/storybook#9828 is resolved, hopefully that will give us an option to use dynamically generated CSF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants