depstat is a dependency analyzer for Go modules enabled projects.

depstat

depstat is a command-line tool for analyzing dependencies of Go modules enabled projects.

depstat demo with k8s repo

Installation

To install depstat you can run

go get github.com/kubernetes-sigs/depstat@latest

Usage

  • depstat can be used as a standalone command-line application. You can use depstat to produce metrics about the dependencies of your Go modules enabled project.

  • Another common way to run depstat is in the CI pipeline of your project. This would help you analyze the dependency changes which come with PRs. You can look at how this is done for the kubernetes/kubernetes repo using prow here.

Commands

To see the list of commands depstat offers you can run depstat help. depstat currently supports the following commands:

cycles

depstat cycles shows all the cycles present in the dependencies of the project.

An example of a cycle in project dependenies is: golang.org/x/net -> golang.org/x/crypto -> golang.org/x/net

--json prints the output of the cycles command in JSON format. For the above example the JSON output would look like this:

{
  "cycles": [
    [
      "golang.org/x/net",
      "golang.org/x/crypto",
      "golang.org/x/net"
    ]
  ]
}

graph

depstat graph will generate a graph.dot file which can be used with Graphviz's dot command to visualize the dependencies of a project.

For example, after running depstat graph, an SVG can be created using: twopi -Tsvg -o dag.svg graph.dot

By default, the graph would be created around the main module (first module in the go mod graph output), but you can choose to create a graph around a particular dependency using the --dep flag.

list

depstat list shows a sorted list of all project dependencies. These include both direct and transitive dependencies.

  1. Direct dependencies: Dependencies that are directly used in the code of the project. These do not include standard go packages like fmt, etc. These are dependencies that appear on the right side of the main module in the go mod graph output.

  2. Transitive dependencies: These are dependencies that get imported because they are needed by some direct dependency of the project. These are dependencies that appear on the right side of a dependency that isn't the main module in the go mod graph output.

stats

depstat stats will provide the following metrics about the dependencies of the project:

  1. Direct Dependencies: Total number of dependencies required by the main module(s) directly.

  2. Transitive Dependencies: Total number of transitive dependencies (dependencies which are further needed by direct dependencies of the project).

  3. Total Dependencies: Total number of dependencies of the main module(s).

  4. Max Depth of Dependencies: Length of the longest chain starting from the first main module; defaults to length from the first module encountered in "go mod graph" output.

  • The --json flag gives this output in a JSON format.
  • --verbose mode will help provide you with the list of all the dependencies and will also print the longest dependency chain.

main module

By default, the first module encountered in "go mod graph" output is treated as the main module by depstat. Depstat uses this main module to determine the direct and transitive dependencies. This behavior can be changed by specifying the main module manually using the --mainModules flag with the stats command. The flag takes a list of modules names, for example:

depstat stats --mainModules="k8s.io/kubernetes,k8s.io/kubectl"

Project Goals

depstat is being developed under the code organization sub-project under SIG Architecture. The goal is to make it easy to evaluate dependency updates to Kubernetes. This is done by running depstat as part of the Kubernetes CI pipeline.

Community Contact Information

You can reach the maintainers of this project at:

#k8s-code-organization on the Kubernetes slack.

Code of conduct

Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.

Owner
Kubernetes SIGs
Org for Kubernetes SIG-related work
Kubernetes SIGs
Comments
  • Automate release with goreleaser and GitHub Actions

    Automate release with goreleaser and GitHub Actions

    • Update build command in RELEASE.md
    • Adds goreleaser config yaml
    • Ignore goreleaser's dist directory which is used as the build / distribution directory
    • Adds GitHub Action workflow config yaml for automatic release using goreleaser on push of git tag

    Fixes #37

    Should I also update the RELEASE.md with the information about goreleaser and GitHub Actions workflow for automatic release once the repo has a git tag for a given version? I think step 3 and 4 would need some changes - https://github.com/kubernetes-sigs/depstat/blob/main/RELEASE.md to mention that release (building and creating GitHub release) is automated but yeah, the owner can change the changelog for the GitHub release if it's needed

    You can look at a sample of the GitHub Actions workflow here - https://github.com/karuppiah7890/depstat/runs/3424475399?check_suite_focus=true

    and a sample release here - https://github.com/karuppiah7890/depstat/releases . Particularly - https://github.com/karuppiah7890/depstat/releases/tag/v0.7.0-rc.1 , a dummy RC release

    Let me know if we want to split the single commit automate release process using goreleaser and github actions into two commits like - add goreleaser config yaml for automated release and add github action workflow config yaml for automated release using goreleaser

    Some things to note

    • I'm using most of the defaults of goreleaser config yaml, for example things like snapshot config. We can remove it if we think we never need it
      • changelog includes commits, due to the changelog config and feature of goreleaser
    • I'm using go v1.16 as that's what is being used in go.mod and also in the existing GitHub Action workflow. But we can change it if needed to v1.17 as it's already out https://golang.org/dl/
    • The build targets are - OSes - Linux, MacOS, Windows. Architectures - arm64 (Not on Windows), x86_64, i386 (Not on Mac) . This comes by default and if we use go v1.17, we will get Windows arm64 too as go v1.17 supports it. Let me know if these targets are good / if they are too much and we can reduce it

    Since we have goreleaser config now, with this we can also have a install.sh script with the help of godownloader for automated install. Let me know if we want to add that too, in this PR or separate PR with separate issue for installer script

    Also, do we want to publish Docker images? Something to discuss, in case we want to use it in containers. I noticed mention of prow jobs, those run in containers? We can discuss that too in a separate issue or here. GoReleaser supports releasing Docker images it seems

  • add tests for getDepInfo function

    add tests for getDepInfo function

    Currently in all the tests we generate the dependency graph manually. We need to have some tests which check the getDepInfo function so that we are able to catch errors like we faced here.

    EDIT: fixed links

  • investigate long time taken for some projects

    investigate long time taken for some projects

    For some projects like minikube and test-infra depstat takes too much time (20 mins+) and memory to produce the stats.

    This bit of code is probably responsible for this.

    We also currently are not sure if it will eventually produce the output or not but after trying various things out, it seems likely that at some point it will. The reason it takes so much time is because of a large number of edges in the dependency graphs of those repos.

    Number of edges = go mod graph | wc -l

    Link to the relevant discussion on Slack.

  • command to show all NEW dependencies in a PR

    command to show all NEW dependencies in a PR

    A command which will show all the new dependencies which are present in the PR, that is, all dependencies minus the ones already present.

    @alenkacz we could maybe take this a step further and show not only the additions but also any removals in dependencies that happen. This would be a good way of knowing if some PR actually has a positive impact on the project dependencies :)

  • Added Issue and Pull Request templates

    Added Issue and Pull Request templates

    Changes

    Add Issue and Pull Request Template

    Issue reference

    We strive to have all PR being opened based on an issue where the problem or feature has been discussed before implementation.

    Please reference the issue this PR will close: #[issue number]

    Submitter Checklist

    Documentation PR Code Review not required.

    These are the criteria that every PR should meet, please check them off as you review them:

    • [ ] Code compiles correctly
    • [ ] Created/updated tests
    • [ ] Extended the documentation
    • [ ] Includes tests (if functionality changed/added)
    • [ ] Run the code checkers with make check
    • [ ] Regenerate the manpages, docs and go formatting with make generated
    • [ ] Commit messages follow commit message best practices

    See the contribution guide for more details.

    Release Notes

    NONE
    
  • Add error message feature for cycles.go file,if the command depstat  cycles run with any arguments

    Add error message feature for cycles.go file,if the command depstat cycles run with any arguments

    Add error message feature for cycles.go file,if the command depstat cycles run with any arguments

    depstat cycles command doesn't take any arguments, if it receives It will throws an error message "cycles does not take arguments"

    Signed-off-by: Srinivas Pokala [email protected]

    Fixes(partially) #38

  • Move graph Generation Logic to a separate helper func

    Move graph Generation Logic to a separate helper func

    • Refactor and move the graph generation logic out of getDepInfo method to a separate helper func
    • Add test case for the helper based on a dummy go mod output
  • add a bot for depstat

    add a bot for depstat

    Right now we run depstat in a prow job. Another good idea would be to have a bot run it and comment on the PR with the stats.

    cc @navidshaikh @BenTheElder since you folks suggested it :)

  • adding CI jobs: build, test, lint

    adding CI jobs: build, test, lint

    Signed-off-by: RinkiyaKeDad [email protected]

    Fixes #30

    The build and test CI jobs are the default ones which GitHub suggests. Please take a look at them too and let me know in case they need to be changed.

    Dims suggested golangci-lint and its implementation in klog. I've added that but I'm not sure if that's the way to go about it since the docs suggest a different way.

  • Renaming the default branch (master) to main

    Renaming the default branch (master) to main

    Renaming the default branch (master) to main in the repo. GitHub's new practice of main as the default repo name. Learn more.

    Checklist

    • [ ] Documentation update
    • [ ] Updating the guides (wiki, .md files, etc.)
    • [ ] Communicating it (Slack)
  • Wrap main graph properties into a struct

    Wrap main graph properties into a struct

    also fix a bug, where we did not add the first dependency into the dep list. It actually did not matter if the dep was not a leaf but I think this way it's more correct :)

A Simple and Clear CLI library. Dependency free.
A Simple and Clear CLI library. Dependency free.

A Simple and Clear CLI library. Dependency free. Features Nested Subcommands Uses the standard library flag package Auto-generated help Custom banners

Jan 1, 2023
Dependency-free replacement for GNU parallel, perfect fit for usage in an initramfs.

coshell v0.2.5 A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage. Licensed under GNU/GPL v2. How it works An sh -c

Dec 19, 2022
Just a simple CLI tool to group dependabot PRs by dependency and merge them.
Just a simple CLI tool to group dependabot PRs by dependency and merge them.

Dependabotbot Have you been the victim of a lodash update? Has your notification page in Github been assaulted by needing to update a patch version of

Jun 30, 2022
Dependency-Free Bencode Editor

rbEdit A statically compiled and dependency-free Bencode editor in Go, useful for command line use and scripts. Quick Start # Compile for linux arch:

Dec 28, 2022
Architecture checks for Go projects

Arch-Go Architecture checks for Go projects Supported rules Dependencies Checks Supports defining import rules Allowed dependencies Not allowed depend

Dec 20, 2022
General purpose reloader for all projects.

leaf General purpose reloader for all projects. Command leaf watches for changes in the working directory and runs the specified set of commands whene

Nov 8, 2022
Handy commands to run in Go projects

Handy commands to run in Go projects

Jan 3, 2023
Contextual information about your git projects, right on the command-line
Contextual information about your git projects, right on the command-line

gitty gitty is a smart little CLI helper for git projects, that shows you all the relevant issues, pull requests and changes at a quick glance. It cur

Jan 8, 2023
Libraries and CLIs for my personal all-in-one productivity system including components like bookmarks, notes, todos, projects, etc.

bntp.go Libraries and CLIs for my personal all-in-one productivity system including components like bookmarks, notes, todos, projects, etc. Neovim int

Sep 13, 2022
CLI for Setting up projects
CLI for Setting up projects

Lemonade CLI for setting up projects Installation Install lemonade into your local machine. Prerequisites: Go v1.16+ Download Go from golang.org Clone

Jan 8, 2022
Powerful CLI written in GO to generate projects in various technologies
Powerful CLI written in GO to generate projects in various technologies

Barca CLI is a project generator written in GO and its purpose is to build and configure HTTP servers, web proxy, SPA/PWA, Blog and custom landing page. It's easy, fast and productive.

Aug 26, 2022
A tool to automate the setup and running of projects

Project CLI This project is still a work in progress but the mvp is working Are you tired of forgetting which commands to run or are you annoyed by th

Nov 30, 2021
Softsuite - Start from gofiber boilerplate and plan to build large projects

Softsuite Thanks to Cozy (ItsCosmas) to build gofiber boilerplate. I start learn

Apr 25, 2022
Godzillacli - Create, Run Godzilla Projects Using Godzilla CLI

godzillacli Create, Run Godzilla Projects Using Godzilla CLI About: godzillacli

Jan 23, 2022
Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer for Nginx.
Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer for Nginx.

Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer, used to analyze Nginx access logs for myself.

Nov 29, 2022
Log-analyzer - Log analyzer with golang

Log Analyzer what do we have here? Objective Installation and Running Applicatio

Jan 27, 2022
This example implements a basic example of how to create your own modules, and how to call them from other modules

This example implements a basic example of how to create your own modules, and how to call them from other modules. In addition, an example of how to do unit tests is developed.

Feb 1, 2022
Dependency management solution for Hashicorp Terraform modules

TERRADEP This is the module dependency solution for implementing terraform's modules dependency. Using this, users can now manage dependencies both fr

Dec 21, 2021
A code generator that turns plain old Go services into RPC-enabled (micro)services with robust HTTP APIs.

Frodo Frodo is a code generator and runtime library that helps you write RPC-enabled (micro) services and APIs. It parses the interfaces/structs/comme

Dec 16, 2022
A code generator that turns plain old Go services into RPC-enabled (micro)services with robust HTTP APIs.

Frodo is a code generator and runtime library that helps you write RPC-enabled (micro) services and APIs.

Dec 16, 2022