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 screenshot tests, coverage and publishing GH flows #5

Merged
merged 15 commits into from
Feb 12, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Feb 9, 2024

Changes:

  • Icons now have the ic_compound_ prefix instead of ic_ to avoid collisions with app or library resources.
  • CompoundIcons vector icon helpers are now functions (needed to get better coverage with Kover).
  • Add screenshot tests using Roborazzi to the project, so they act as regression tests.
  • Add Kover to get coverage data.
  • Add Git LFS support, needed to store the golden screenshots.
  • Add GH actions:
    • Validate Git LFS.
    • Unit and regression tests.
    • Record screenshots.
    • Test and publish coverage in a nightly fashion.
    • Publishing.

Copy link

codecov bot commented Feb 9, 2024

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

@jmartinesp jmartinesp changed the title Add screenshot tests and coverage Add screenshot tests, coverage and publishing GH flows Feb 12, 2024
@jmartinesp jmartinesp added the Record-Screenshots Record new golden screenshots for the PR label Feb 12, 2024
@github-actions github-actions bot removed the Record-Screenshots Record new golden screenshots for the PR label Feb 12, 2024
@jmartinesp jmartinesp marked this pull request as ready for review February 12, 2024 08:07
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks, this looks correct!
Just adding some ignorable comments!

testImplementation(libs.test.roborazzi)
testImplementation(libs.test.roborazzi.compose)
testImplementation(libs.test.roborazzi.junit)
testImplementation(libs.test.roborazzi.junit)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there is a duplicated line here.

minValue = 80
// Setting a max value, so that if coverage is bigger, it means that we have to change minValue.
// For instance if we have minValue = 20 and maxValue = 30, and current code coverage is now 31.32%, update
// minValue to 25 and maxValue to 35.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe remove this comment, since there is no maxValue here.

@@ -54,6 +60,7 @@ fun ColorPreview(
Box(
modifier = Modifier
.padding(1.dp)
.background(Color.White)
Copy link
Member

Choose a reason for hiding this comment

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

Does it have an effect? There is line 64 which set a background as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes: without this, the colors that have an alpha value are overlayed directly above this component's parent background, which is a gradient, and it's difficult to really understand what the color looks like unless you take a look at both extremes of each item (the pure white/black colors).

Although it might be that what we wanted when using the gradient, I'm not sure. I found it quite confusing myself.

Copy link
Member

Choose a reason for hiding this comment

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

The gradient idea was to add a border with "several" colors. So it's fine to set a White bg, I did not think about colors with alpha. Thanks!

@Composable
internal fun AvatarColorsDarkPreview() {
val chunks = avatarColorsDark.chunked(4)
ElementTheme {
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to force a dark theme here.

Suggested change
ElementTheme {
ElementTheme(darkTheme = true) {

but the generated screenshots are correct since avatarColorsDark is used here. So just ignore me!

ui-tooling-preview-android = "1.5.4"
ui-tooling-preview-android = "1.6.1"
kover = "0.7.5"
roborazzi = "1.9.0"
Copy link
Member

Choose a reason for hiding this comment

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

We will probably need to setup Renovate on this repo to handle the upgrades

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me know if it's something I can do.

Copy link
Member

Choose a reason for hiding this comment

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

I take the point.

Copy link
Member

Choose a reason for hiding this comment

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

Done in #7

@jmartinesp jmartinesp merged commit e57649f into main Feb 12, 2024
2 checks passed
@jmartinesp jmartinesp deleted the misc/jme/add-screenshot-tests-and-coverage branch February 12, 2024 10:18
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