bugout-dev / locust Goto Github PK
View Code? Open in Web Editor NEW"git diff" over abstract syntax trees
License: MIT License
"git diff" over abstract syntax trees
License: MIT License
This can be a little bit confusing when viewing a locust summary, because it differs from what GitHub says about number of files changed.
locust.git
already contains a lot of this information in its output. That's probably a good starting point for this issue.
Each environment variable should reference the definition it is used inside (if one exists). Otherwise, the reference should be null
.
Code bases with multiple languages (e.g. frontend Javascript and backend Python) should not receive empty Locust summaries for changes in non-Python code.
If the rendered string is empty, we can do an easy check for it in the CI environment (-z
in bash, for example).
This was requested by a user.
In the locust summary, it should be clear to viewers which functions/classes have been added for the first time in the code base, which ones are merely updated, and which were removed.
Right now, we show the total number of lines and changed lines for each definition (functions, async functions, classes) in a Python file.
We should also provide the total_lines
and changed_lines
statistics per file.
As a follow-on bit of work, we should give users the option to order files in a summary:
The setting should cascade down to definitions.
GitHub's PR UI shows the diff of the base branch with a ref in which the base branch has been merged into the head branch.
Locust summaries take the diff of the base branch with the head branch directly.
When the base branch contains changes not in the head branch, the Locust summary shows different modifications than the GitHub diff.
When the Locust summary is generated for GitHub, Locust should:
base=base
, head=base->head
base=base
, head=head
base
with head
.This last change should probably get its own issue, as it's a substantial improvement in the user experience, and seems like a significant chunk of work.
We are getting this error in CI/CD pipelines that comes from not pinning protobuf version:
https://github.com/bugout-dev/moonstream/runs/7560456052?check_suite_focus=true
Is there a way to auto-hide old Locust summaries when a new one is posted to the PR? Here's an example PR.
The Javascript plugin duplicates the data structure definitions (PatchInfo
, HunkInfo
, RawDefinition
, LocustChange
, etc.) from the core Python library.
The fact that each plugin has to define its own data structures creates two kinds of issues:
Protobufs are a great way to give plugins a consistent interface to program against. We can define all of the core Locust data types as proto files and generate data structures for each language using protoc
.
More documentation on protobuf: https://github.com/protocolbuffers/protobuf
locust --depth <n>
should only render the top n
levels of a Locust summary.
locust --depth 1
would be similar to git diff --stat
, where it would show only the files changed.
locust --depth 2
would show files and top-level functions + classes in those files.
And so on.
We need to build GitHub Actions so that whenever a commit is push
ed to main
:
PyPI release: We run python setup.py sdist bdist_wheel
and then twine upload --non-interactive dist/*
(this will need PyPI username and password as secrets)
Docker push: We run LOCUST_DOCKER_PUSH=true docker/build.sh v$(python -m locust.version)
(this will need a DockerHub token as a secret)
Although we are using the proto definitions to generate data containers in the code, we still require conversion to JSON when passing data between pipeline steps (especially through plugins).
locust.git
, locust.parse
, and locust.render
should all accept -i
and -o
arguments in two possible formats json
, pb
.
The logic is simple - we should:
We should add a console_scripts
entry for locust.version
in setup.py
.
What should our approach be in adding Locust support for other languages?
Locust is written in such a way that all parts of the summarization process besides the AST traversal should be programming language invariant.
This question is more about the handoff between run times. For example, how should Locust call out to a Javascript AST walker?
Right now, I am thinking of just:
Some considerations:
These are just some early and woolly thoughts on the topic. I would like to add Javascript support before December, though.
This will allow users to generate a Locust summary for the current revision in their repository (instead of a diff between revisions).
The Locust
in the Locust summary
title for --format html
and --format html-github
outputs should link back to this GitHub repository.
The code in question is here: https://github.com/simiotics/locust/blob/main/locust/render.py#L224
Hello zomglings,
hbt here from https://news.ycombinator.com/item?id=25007701
I'd like to reply to your comment then explain what I'm planning to build
Q:
Would this be a lot easier in go? The case that scares me a bit in Go is implicit imports (e.g. importing a driver for use with
database/sql
). But maybe all that is very clear when doing static analysis?
A:
There are already utilities for golang and existing apis.
Example of usage: guru -json -scope "github.com/hbt/fh/cmd/hbt-cli" callers "hbt-cli/lib/util/git/git.go:#645"
Example of output:
{
"pos": "/home/hassen/workspace/fh/hbt-cli/lib/cmds/devcmd/gw.go:122:63",
"desc": "static function call",
"caller": "(github.com/hbt/fh/hbt-cli/lib/cmds/devcmd.GitWorkDev).handleCustomProjects"
},
{
"pos": "/home/hassen/workspace/fh/hbt-cli/lib/cmds/devcmd/gw.go:123:63",
"desc": "static function call",
"caller": "(github.com/hbt/fh/hbt-cli/lib/cmds/devcmd.GitWorkDev).handleCustomProjects"
},
{
"pos": "/home/hassen/workspace/fh/hbt-cli/lib/util/goutil/mage.go:71:40",
"desc": "static function call",
"caller": "(github.com/hbt/fh/hbt-cli/lib/util/goutil.MageBuild).BuildLocally"
},
{
"pos": "/home/hassen/workspace/fh/hbt-cli/lib/cmds/go/order.go:32:35",
"desc": "static function call",
"caller": "(github.com/hbt/fh/hbt-cli/lib/cmds/go.GoOrderCmd).Run$1"
},
{
"pos": "/home/hassen/workspace/fh/hbt-cli/lib/cmds/go/impl.go:43:38",
"desc": "static function call",
"caller": "(github.com/hbt/fh/hbt-cli/lib/cmds/go.GoImplementInterfaceCmd).Run"
},
{
"pos": "/home/hassen/workspace/fh/hbt-cli/lib/cmds/selfdev/create.go:61:38",
"desc": "static function call",
"caller": "(github.com/hbt/fh/hbt-cli/lib/cmds/selfdev.CreateCmd).getPackagePath"
}
]
The guru tool uses an existing library to do the AST parsing and provides an API for querying go programs.
callees show possible targets of selected function call
callers show possible callers of selected function
callstack show path from callgraph root to selected function
definition show declaration of selected identifier
describe describe selected syntax: definition, methods, etc
freevars show free variables of selection
implements show 'implements' relation for selected type or method
peers show send/receive corresponding to selected channel op
pointsto show variables the selected pointer may point to
referrers show all refs to entity denoted by selected identifier
what show basic information about the selected syntax node
whicherrs show possible values of the selected error variable
This is also pretty good for querying AST across multiple languages
My main goal is:
provide a better "git diff" prior to committing code and detect the following issues
commit metadata and value of a commit: we often say, writing software is about iteration but somehow that doesn't apply to writing a commit and we are expected to get everything right (message, changes within scope etc.)
Anyway, as soon as I find the bandwidth, I will push out something more concrete.
Nested paths are not prefixed by the URL provided by the --github
parameter.
It doesn't stop at definition boundaries at the moment. Sums up the sizes of hunks even if they exceed the boundaries of a function/class definition.
It doesn't correctly count deleted lines.
Right now the link goes directly to the file within the commit, but I was expecting to see the diff.
Right now, if you wanted to store a JSON summary and an HTML summary, you would have to run the summarization process (including AST traversal) twice.
It's much more reasonable to create clearer interfaces between diff-calculation, AST traversal, and rendering. This will allow us to:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.