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: provide repository contributors insights #30

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

cecobask
Copy link
Contributor

@cecobask cecobask commented Aug 20, 2023

Description

This pull request adds the feature to provide repository contributors insights.

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Closes #5

Mobile & Desktop Screenshots/Recordings

File contents:

$ cat repos.yaml

- https://github.com/kubernetes/kubernetes
- https://github.com/cli/cli

Usage with --file / -f flag

$ pizza insights contributors --file repos.yaml

┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Repository URL      ┃ https://github.com/cli/cli ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ New contributors    ┃ 25                         ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Recent contributors ┃ 30                         ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Churn contributors  ┃ 40                         ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Repeat contributors ┃ 5                          ┃
┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Repository URL      ┃ https://github.com/kubernetes/kubernetes ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ New contributors    ┃ 158                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Recent contributors ┃ 280                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Churn contributors  ┃ 197                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Repeat contributors ┃ 122                                      ┃
┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Usage with --repos / -r flag

$ pizza insights contributors --repos "https://github.com/kubernetes/kubernetes,https://github.com/cli/cli"

┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Repository URL      ┃ https://github.com/cli/cli ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ New contributors    ┃ 25                         ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Recent contributors ┃ 30                         ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Churn contributors  ┃ 40                         ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Repeat contributors ┃ 5                          ┃
┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Repository URL      ┃ https://github.com/kubernetes/kubernetes ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ New contributors    ┃ 158                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Recent contributors ┃ 280                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Churn contributors  ┃ 197                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Repeat contributors ┃ 122                                      ┃
┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Ignore non-existent and non-indexed repositories

$ pizza insights contributors --repos "https://github.com/fake-owner/fake-repo,https://github.com/kubernetes/kubernetes"

ignoring repository issue: repository https://github.com/fake-owner/fake-repo is either non-existent or has not been indexed yet
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Repository URL      ┃ https://github.com/kubernetes/kubernetes ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ New contributors    ┃ 158                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Recent contributors ┃ 280                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Churn contributors  ┃ 197                                      ┃
┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Repeat contributors ┃ 122                                      ┃
┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Error when neither --file or --repos flag was provided

$ pizza insights contributors

Error: must pass either --file or --repos flag
Usage:
  pizza insights contributors [flags]

Flags:
  -f, --file string     Path to yaml file containing an array of git repository urls
  -h, --help            help for contributors
  -p, --period int      Number of days, used for query filtering (default 30)
  -r, --repos strings   Comma-separated array of git repository urls

Global Flags:
      --beta              Shorthand for using the beta OpenSauced API endpoint ("https://beta.api.opensauced.pizza/v1"). supercedes the '--endpoint' flag
  -e, --endpoint string   The API endpoint to send requests to (default "https://api.opensauced.pizza/v1")

2023/08/20 19:36:16 must pass either --file or --repos flag

Error when both --file and --repos flags were provided

$ pizza insights contributors --file repos.yaml --repos "https://github.com/kubernetes/kubernetes,https://github.com/cli/cli"

Error: if any flags in the group [file repos] are set none of the others can be; [file repos] were all set
Usage:
  pizza insights contributors [flags]

Flags:
  -f, --file string     Path to yaml file containing an array of git repository urls
  -h, --help            help for contributors
  -p, --period int      Number of days, used for query filtering (default 30)
  -r, --repos strings   Comma-separated array of git repository urls

Global Flags:
      --beta              Shorthand for using the beta OpenSauced API endpoint ("https://beta.api.opensauced.pizza/v1"). supercedes the '--endpoint' flag
  -e, --endpoint string   The API endpoint to send requests to (default "https://api.opensauced.pizza/v1")

2023/08/20 19:36:42 if any flags in the group [file repos] are set none of the others can be; [file repos] were all set

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📜 README.md
  • 📓 docs.opensauced.pizza
  • 🍕 dev.to/opensauced
  • 📕 storybook
  • 🙅 no documentation needed

@cecobask cecobask force-pushed the contributor-insights branch 2 times, most recently from c06f01e to 6e3ea56 Compare August 21, 2023 08:22
Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

I'm realizing this has quite abit of overlap with #24.

We'll want to align the user experience so that there is a clear story for CLI users with each command

This will also be blocked on us getting an API client for Go: #28

@cecobask cecobask force-pushed the contributor-insights branch from e7b0bb5 to 0c02404 Compare August 21, 2023 21:14
@cecobask cecobask requested a review from jpmcb August 21, 2023 21:14
@bdougie
Copy link
Member

bdougie commented Aug 21, 2023

I'm realizing this has quite abit of overlap with #24.

We'll want to align the user experience so that there is a clear story for CLI users with each command

I see the difference being the interactivity you get from the show. I didn't want to increase scope on #24 while we explore the basic interaction, but think we can do some more high level insights from commits and prs as well.

@jpmcb
Copy link
Member

jpmcb commented Aug 22, 2023

@cecobask - the Go API client has landed ✨ https://github.com/open-sauced/go-api !!!! Are you able to give that a try? It likely has some sharp edges so please open issues in that repo as the need arises!

@jpmcb
Copy link
Member

jpmcb commented Aug 22, 2023

Can you change this PR's target branch to be beta? 👀 We recently changed the default branch to beta in support of using the releaser action

For further reading:

@cecobask cecobask changed the base branch from main to beta August 23, 2023 10:16
@cecobask cecobask force-pushed the contributor-insights branch 2 times, most recently from fabf3f5 to eb70fb1 Compare August 23, 2023 10:26
@cecobask
Copy link
Contributor Author

@jpmcb, Done 👍🏻 Another review session is in order 😄

  • Refactored the codebase to make API calls using the go client where possible, the only exception being auth and repo-query commands
  • Consolidated duplicated logic and constants
  • Configured gci linter with default settings
  • Added concurrency to the pizza bake command
  • Updated pizza insights contributors to use https://github.com/charmbracelet/bubbles#table for outputting results

Until open-sauced/go-api#2 is resolved, pizza bake commands will fail with 400 Bad Request.

@cecobask cecobask force-pushed the contributor-insights branch from eb70fb1 to bf539a5 Compare August 26, 2023 17:01
@cecobask
Copy link
Contributor Author

The problems with open-sauced/go-api were resolved.
I believe there are no more changes to be added here.
@jpmcb, can you please take a look when you get a chance?

cmd/root/root.go Outdated
}
return nil
},
SilenceUsage: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every time a command returned an error, the help output was also printed, together with the error.
I think this is cleaner. The help output will still be shown in case the user entered invalid input for commands or passed --help flag.

Copy link
Member

Choose a reason for hiding this comment

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

Every time a command returned an error, the help output was also printed

We should still dump the help message when an error is returned since it's usually due to some misconfiguration of flags or values. The standard approach in Cobra CLIs is to print the help message along with the error so the user can have a quick loop to correcting it.

Copy link
Member

Choose a reason for hiding this comment

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

❯ ./build/pizza insights contributors
Error: must pass either file or repos flag

Hmmm I suppose I could be convinced that this is cleaner and easier to grok. What do others think?

Copy link
Member

Choose a reason for hiding this comment

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

I think we still want some sort of user feedback. For example, in the github CLI, they return some helpful list of available commands:

❯ gh pr woof
unknown command "woof" for "gh pr"

Usage:  gh pr <command> [flags]

Available commands:
  checkout
  checks
  close
  comment
  create
  diff
  edit
  list
  lock
  merge
  ready
  reopen
  review
  status
  unlock
  view

So, for now, until we figure out a better strategy, let's just dump the help message for that command in order to provide some fast feedback for the user.

@cecobask cecobask force-pushed the contributor-insights branch from bf539a5 to 71be66d Compare August 26, 2023 17:17
Copy link
Contributor Author

@cecobask cecobask left a comment

Choose a reason for hiding this comment

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

Thank you for the feedback, @jpmcb!
I've updated the code based on your suggestions.
Please, review at your convenience 👍🏻

@cecobask cecobask requested a review from jpmcb August 29, 2023 12:03
@cecobask cecobask force-pushed the contributor-insights branch 3 times, most recently from bad32a5 to f20fd71 Compare August 31, 2023 16:14
@jpmcb
Copy link
Member

jpmcb commented Aug 31, 2023

Thank you for the feedback, @jpmcb!

Happy to provide the feedback! This is looking good, great work. Huge lift. This is on my docket to dive back into today!

Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

This is getting very close!!!! Nice work!!!

cmd/root/root.go Outdated
}
return nil
},
SilenceUsage: true,
Copy link
Member

Choose a reason for hiding this comment

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

I think we still want some sort of user feedback. For example, in the github CLI, they return some helpful list of available commands:

❯ gh pr woof
unknown command "woof" for "gh pr"

Usage:  gh pr <command> [flags]

Available commands:
  checkout
  checks
  close
  comment
  create
  diff
  edit
  list
  lock
  merge
  ready
  reopen
  review
  status
  unlock
  view

So, for now, until we figure out a better strategy, let's just dump the help message for that command in order to provide some fast feedback for the user.

@cecobask cecobask force-pushed the contributor-insights branch from f20fd71 to 6e95a76 Compare September 2, 2023 16:41
@cecobask
Copy link
Contributor Author

cecobask commented Sep 2, 2023

This is getting very close!!!! Nice work!!!

Thanks, @jpmcb! I've updated the branch with the latest changes 👍🏻
Let me know if something else needs to be done here.

@cecobask cecobask requested a review from jpmcb September 2, 2023 16:43
Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

Great work!! Just one small nit on a regression I noticed in using a custom endpoint for the pizza service (which I typically do for testing local changes). This might be an issue with how the client generates it's endpoints. Otherwise, let's get this in! 💪🏼

Copy link
Member

@bdougie bdougie left a comment

Choose a reason for hiding this comment

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

I have been watching this quietly in the background and can say it works as expected for me.

re: localhost. It might be worth setting up some follow up issues to identify things we can fix and enhance after this is merged.

Something top of mind is making these contributor insights actionable with some context on % and story telling.

Perhaps we get @isabensusan to assist in adding this to the design backlog to assist in representing this in the UI.

@jpmcb jpmcb merged commit d16091f into open-sauced:beta Sep 6, 2023
github-actions bot pushed a commit that referenced this pull request Sep 6, 2023
## [1.0.0-beta.4](v1.0.0-beta.3...v1.0.0-beta.4) (2023-09-06)

### 🍕 Features

* provide repository contributors insights ([#30](#30)) ([d16091f](d16091f))
@cecobask cecobask deleted the contributor-insights branch September 6, 2023 22:55
open-sauced bot pushed a commit that referenced this pull request Oct 11, 2023
## 1.0.0 (2023-10-11)

### 🤖 Build System

* sematic bin release, npm ([7b4607e](7b4607e))

### 🔁 Continuous Integration

* Update @open-sauced/[email protected] and compliance.yaml ([#33](#33)) ([146b6b7](146b6b7))

### 🐛 Bug Fixes

* Uses correct generated token when checking out cli repo in release ([#44](#44)) ([1e0c9f1](1e0c9f1))

### 🍕 Features

* Add install instructions and script for pizza CLI ([#26](#26)) ([421a429](421a429))
* Add posthog telemetry integration ([#37](#37)) ([9829f49](9829f49))
* cli auth ([#21](#21)) ([34728fb](34728fb))
* GitHub action to build and upload Go artifacts after release created ([#22](#22)) ([ad187a9](ad187a9))
* Http Client for accessing OpenSauced API client ([#23](#23)) ([ec2b357](ec2b357))
* Leverage the GITHUB_APP_TOKEN for releases ([#32](#32)) ([e0a25e0](e0a25e0))
* npm i -g pizza ([73291d1](73291d1))
* Pizza show ([#24](#24)) ([72f21ce](72f21ce))
* provide repository contributors insights ([#30](#30)) ([d16091f](d16091f))
* provide repository insights ([#38](#38)) ([dc148d6](dc148d6))
* repo-query support ([199cfd7](199cfd7))
* update bin name release.yaml ([6b21cb8](6b21cb8))
* Version command for CLI based on release builds ([#36](#36)) ([9f3eedc](9f3eedc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: provide contributor insights
5 participants