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: Add the stdlib_diff tool to compare gno and go standard libraries #2869

Merged
merged 48 commits into from
Dec 17, 2024

Conversation

Villaquiranm
Copy link
Contributor

@Villaquiranm Villaquiranm commented Sep 29, 2024

continuing the work started on #1425
thanks FloRichardAloeCorp for the great job on this issue 👍
closes #1310

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@Villaquiranm Villaquiranm requested a review from a team as a code owner September 29, 2024 10:54
@Villaquiranm Villaquiranm requested review from ajnavarro and zivkovicmilos and removed request for a team September 29, 2024 10:54
@Villaquiranm Villaquiranm changed the title Feat/stdlib diff feat: Add the stdlib_diff tool to compare gno and go standard libraries #1425 Sep 29, 2024
@Villaquiranm Villaquiranm changed the title feat: Add the stdlib_diff tool to compare gno and go standard libraries #1425 feat: Add the stdlib_diff tool to compare gno and go standard libraries Sep 29, 2024
Copy link

codecov bot commented Sep 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@Villaquiranm
Copy link
Contributor Author

@thehowl I took a look of this, the current status:
1- Not done yet
2- I think it is already done, I can select the code and the + & - are not selected
3- I was thinking on implementing this using semaphores ? like that I could have the entire code on the same file as it is right now. If you think is necessary to use channels I could do that too.

4 and 5 are fixed on eaf6a87
Only for 4 I think there are some folder we should avoid ? For exemple cmd & vendor as they have a lot of files and I think they are not related to standard lib ?

Thank you for your contribution!

Sorry for the wait, this is an initial to improve. Nice work, but you can improve.

Some functionality missing on the generated report:

1- Formatting is still very funky. Use CSS to render tabs correctly; they should render as 4 spaces.

image

2- Ideally, for the added/deleted lines, make the + and - symbols non selectable. This makes it so that if I select the lines in either side of the page I can copy and paste the code without copying the symbols.

3- I believe the report's performance could be improved. Consider using the library I mention in the comments (diffmatchpatch) and parallelizing execution. You can parallelize execution by having a goroutine trying to first of all find all of the directories in the source and destination, and then sending off to a channel individual package names.

4- The tool does not currently perform diffing recursively. Ie. creating the report on my stdlibs it does not generate a diff for package regexp/syntax. Consider searching using something like filepath.WalkDir.

5- On the report, please make the lines which are == greyed out (putting css opacity: 0.75 probably works)

@thehowl
Copy link
Member

thehowl commented Oct 2, 2024

@Villaquiranm

  1. Formatting: you're right, + / - are not selectable. Can you add line numbers as well, and align each column? (line number, + / - / no sign, code line), making sure that only the code is selectable?
  2. For the diff'ing algo and performance, I actually found this library when I was working on a side project some time ago. I believe it's the best for this use case. diffmatchpatch, which I linked in the original PR, is not ideal as it is for "character-by-character" diff (ie. what Google uses for google docs); not for the kind of diffs we use in programming.
    There are also likely some other "easy" performance wins. As you mentioned, we should skip directories which entirely don't exist in their Gno counterpart (in the index, we can just show cmd in red and say missing in gno or missing in go for libs like std).
    Parallelism may not be necessary; let's see what single-thread performance we can get, and if it's still slow after my suggestions use pprof to find out what's taking the most time. I think we can get <5s performance on most machines pretty easily even without it.
  3. Can you make sure the index lists sub-directories as well?

@Kouteki Kouteki added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Oct 3, 2024
@jefft0 jefft0 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Oct 4, 2024
@jefft0
Copy link
Contributor

jefft0 commented Oct 4, 2024

Removed the "review team" label because this is already reviewed by thehowl.

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

There are some more improvements overall, but I think with these few changes we're good to merge and iterate. Thanks, and sorry for the delay in the review!

misc/stdlib_diff/README.md Outdated Show resolved Hide resolved
misc/stdlib_diff/README.md Outdated Show resolved Hide resolved
misc/stdlib_diff/README.md Outdated Show resolved Hide resolved
misc/stdlib_diff/report.go Outdated Show resolved Hide resolved
misc/stdlib_diff/filediff.go Show resolved Hide resolved
misc/stdlib_diff/templates/package_diff_template.html Outdated Show resolved Hide resolved
@thehowl
Copy link
Member

thehowl commented Dec 9, 2024

btw, can you modify the gh-pages workflow? (.github/workflows/gh-pages)

so it creates the report automatically on each push. Maybe put the report in the subdir stdlib_diff, so it eventually shows up on https://gnolang.github.io/gno/stdlib_diff

I suggest you also try it out on a fork and link to a sample output, so we can check the workflow works correctly ahead of the merge.

@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 9, 2024

🛠 PR Checks Summary

🔴 Maintainers must be able to edit this pull request (more info)

Manual Checks (for Reviewers):
  • SKIP: Do not block the CI for this PR
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🔴 Maintainers must be able to edit this pull request (more info)
🟢 The pull request head branch must be up-to-date with its base (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: TERITORI/gno)

Then

🔴 Requirement not satisfied
└── 🔴 Maintainer can modify this pull request

The pull request head branch must be up-to-date with its base (more info)

If

🟢 Condition met
└── 🟢 On every pull request

Then

🟢 Requirement satisfied
└── 🟢 Head branch (TERITORI:feat/stdlib_diff) is up to date with base (master): behind by 0 / ahead by 48

Manual Checks
**SKIP**: Do not block the CI for this PR

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Dec 13, 2024
@Villaquiranm
Copy link
Contributor Author

btw, can you modify the gh-pages workflow? (.github/workflows/gh-pages)

so it creates the report automatically on each push. Maybe put the report in the subdir stdlib_diff, so it eventually shows up on https://gnolang.github.io/gno/stdlib_diff

I suggest you also try it out on a fork and link to a sample output, so we can check the workflow works correctly ahead of the merge.

@thehowl I followed your recommendations, here is the result :) thanks
https://villaquiranm.github.io/gno/stdlib_diff/

@Villaquiranm Villaquiranm requested a review from thehowl December 17, 2024 18:22
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

@Villaquiranm
Copy link
Contributor Author

@thehowl Merged your PR sorry for having this extra step :)
next time Will do it from my personal github account

@thehowl
Copy link
Member

thehowl commented Dec 17, 2024

no worries :)

@thehowl thehowl merged commit b200892 into gnolang:master Dec 17, 2024
106 of 107 checks passed
omarsy pushed a commit to omarsy/gno that referenced this pull request Dec 18, 2024
…es (gnolang#2869)

continuing the work started on gnolang#1425 
thanks FloRichardAloeCorp for the great job on this issue 👍 
closes gnolang#1310 
<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: hthieu1110 <[email protected]>
Co-authored-by: Florian Richard <[email protected]>
Co-authored-by: Morgan Bazalgette <[email protected]>
@Villaquiranm Villaquiranm deleted the feat/stdlib_diff branch December 23, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Tool for comparing source code of standard libaries between Go and Gno
7 participants