android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
15.91k stars 2.81k forks source link

[Bug]: `generateModuleGraphs.sh` seems to be not working #1503

Closed Jaehwa-Noh closed 20 hours ago

Jaehwa-Noh commented 2 weeks ago

Is there an existing issue for this?

Is there a StackOverflow question about this issue?

What happened?

When I run the generateModuleGraphs.sh, build was failed and gave merely blank text output. I don't know Is this error just on me? Nobody get same errors and blank outputs?

image

Relevant logcat output

BUILD FAILED in 1s
6 actionable tasks: 2 executed, 4 up-to-date
Configuration cache entry stored.
Error: dot: can't open /tmp/dep_graph_ui_test_hilt_manifest.gv: No such file or directory
-:1: parser error : Document is empty

^
rm: /tmp/dep_graph_ui_test_hilt_manifest.gv: No such file or directory

Code of Conduct

SimonMarquis commented 2 weeks ago

@Jaehwa-Noh can you run these commands step-by-step for the :ui-test-hilt-manifest module and see what does not work?

(don't forget to replace the variables)

https://github.com/android/nowinandroid/blob/85129e4660f7a27c7081f4ac21169d19db89fbb6/generateModuleGraphs.sh#L110-L120

Jaehwa-Noh commented 2 weeks ago

@SimonMarquis

  1. ran this

    gradlew generateModulesGraphvizText -Pmodules.graph.output.gv="/tmp/feature_bookmarks.gv" -Pmodules.graph.of.module=":feature:bookmarks" --rerun

1-1. output

digraph G { ":feature:bookmarks" -> ":core:ui" ":feature:bookmarks" -> ":core:designsystem" ":feature:bookmarks" -> ":core:data" [color=red style=bold] ":core:ui" -> ":core:analytics" ":core:ui" -> ":core:designsystem" ":core:ui" -> ":core:model" ":core:data" -> ":core:common" ":core:data" -> ":core:database" [color=red style=bold] ":core:data" -> ":core:datastore" ":core:data" -> ":core:network" ":core:data" -> ":core:analytics" ":core:data" -> ":core:notifications" ":core:database" -> ":core:model" [color=red style=bold] ":core:datastore" -> ":core:datastore-proto" ":core:datastore" -> ":core:model" ":core:datastore" -> ":core:common" ":core:network" -> ":core:common" ":core:network" -> ":core:model" ":core:notifications" -> ":core:model" ":core:notifications" -> ":core:common" }

  1. ran this

    dot -Tsvg "/tmp/feature_bookmarks.gv" | sed 's/<!--/\x0/-->\x0/g' | grep -zv '^<!--' | tr -d '\0' | xmllint --format - \ "docs/images/graphs/feature_bookmarks.svg"

2-1. output

dot -Tsvg "/tmp/feature_bookmarks.gv" | sed 's/<!--/\x0/-->\x0/g' | grep -zv '^<!--' | tr -d '\0' | xmllint --format - \ "docs/images/graphs/feature_bookmarks.svg" -:4: parser error : Start tag expected, '<' not found Generated by graphviz version 11.0.0 (20240428.1522) ^

I found the problem and fixed it. #1505 the problem is the sed just remove "<!--" from .svg files.

Thank you.

SimonMarquis commented 2 weeks ago

Comments are removed on purpose from the SVG files.

The issue is certainly related to the grep version you are running not being able to handle nul characters. Someone already reported that a few weeks ago, but I don't find the comment anymore.

SimonMarquis commented 2 weeks ago

I think the best option would be to simply use a dedicated tool for that, like https://github.com/svg/svgo

Jaehwa-Noh commented 2 weeks ago

If the problem is grep version, I can remove grep from the command line. https://github.com/android/nowinandroid/pull/1505/commits/040c05b96cb9d6231485294bad93ba865d6962a4

Your approach, using dedicated tool, and my plain sed command both are good to solve this issue.

You can see the plain sed result in here. https://sed.js.org/?snippet=zq7kBo

JackEblan commented 2 weeks ago

Would you mind making the generation of module graphs in general and not just on specific platform?

Jaehwa-Noh commented 2 weeks ago

@JackEblan Good suggestion. Maybe we should put this on CI for SSOT like screenshot tests.

@SimonMarquis How did you command Dependabot takes a graph? https://github.com/android/nowinandroid/pull/1506/commits/c514b9b94bb89696b593330032e79d5fbeac28e1

SimonMarquis commented 2 weeks ago

If the problem is grep version, I can remove grep from the command line. Your approach, using dedicated tool, and my plain sed command both are good to solve this issue.

@Jaehwa-Noh You can't remove a command like that and still expect it to work 😅

Maybe we should put this on CI for SSOT like screenshot tests.

This would indeed be a solution, but I'll let the maintainers decide if it's worth adding an extra CI step. (This would obviously require more work, and even more specific CI scenarios to handle).

How did you command Dependabot takes a graph?

I did not. I simply forgot I had the dependabot's git config locally 🙈