-
Notifications
You must be signed in to change notification settings - Fork 986
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
Spec checker tool #8722
Spec checker tool #8722
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #8722 +/- ##
===========================================
- Coverage 60.54% 60.54% -0.01%
===========================================
Files 519 519
Lines 36271 36320 +49
===========================================
+ Hits 21961 21989 +28
- Misses 11146 11161 +15
- Partials 3164 3170 +6 |
…to spec-checker-tool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing. Is there any issue filed with rules_go to support embed in go tool library?
if matchesPerfectly { | ||
return true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to check that all refDefs match perfectly or just any of them match perfectly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I loop through all versions of a given definition (say, in altair
we have the function with the same name but different implementation, I want to make sure that both comments in altair-related code and phase0 related code are checked).
So, at the beginning of loop that checks that all definition's lines match our comment, the matchesPerfectly
flag is set to true
. Line checking loop breaks when non-matching line is found, the matchesPerfectly
flag is set to false
. So, a single matching definition is enough for flag to survive, and us be sure that our comment matches at least one known version of spec's function.
NB: Will search rules go for an issue, and if none exists will create my own -- somehow missed that part, thanks for pointing that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing. Is there any issue filed with rules_go to support embed in go tool library?
- I've created an issue: go: go_tool_library support for the //go:embed directive bazelbuild/rules_go#2860
- Btw, while looking whether the issue has already been filed, I found an alternative way to implement embedding (
go_embed_data
is mentioned in go: support go:embed directives in 1.16 bazelbuild/rules_go#2775). So, it seems we can implement the checker as CI static code analyzer with go_embed_data, do you think it is worth implementing it right now, or should we wait for update onrules_go
side?
Turning back to draft, will implement as static code analyzer (using workaround with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. This is great!
What type of PR is this?
What does this PR do? Why is it needed?
go_tool_library
doesn't supportembededsrcs
attribute (whichgo_library
does support), and our tool relies ongo:embed
. Oncerules_go
are updated, we can turn this tool into static analyzer, easily.def func_name():
defined for both phase1 and phase0). As long as one of the definitions matches our comments, we consider comments to be up to date.Which issues(s) does this PR fix?
Fixes #5717
How to update referenced specs?
bazel run //tools/specs-checker download -- --dir=$PWD/tools/specs-checker/data
This will pull the files defined in
specDirs
(seemain.go
), parse them (extract Python code snippets, discarding any other text), and save them to the folder from whichbazel run //tools/specs-checker check
will be able to embed (usinggo:embed
):Note: see included README for more details.
How to run tests?
Or, to check the whole project:
bazel run //tools/specs-checker check -- --dir $PWD
How do results of the check look like?
Why save parsed reference definitions, why not discard them after the check?
There are several reasons for doing that:
git diff
I immediately see what files have changed, to better understand the scope of updates I need to do on our comments.