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

Add repo filtering functionality #9

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

bxffour
Copy link
Contributor

@bxffour bxffour commented Jun 17, 2023

Description

This pull request introduces a new feature that allows users to filter the repositories when generating GitHub Actions usage statistics using the CLI tool.

Related Issue:

Before:

Prior to this change, the CLI tool provided general usage statistics for all repositories associated with the target GitHub organization/user. There was no built-in capability to filter the repositories and focus on a select few.

After:

With this enhancement, users can now specify a set of repositories to filter when generating GitHub Actions usage statistics. This enables them to focus on the specific repositories they care about and obtain more targeted insights.

Changes Made:

  1. Added support for filtering repositories by specifying a comma-separated list of repository names through the -include flag or by providing a file containing repository names with the -include-file flag.
  2. Implemented parsing of repository names from both command-line input and file input.
  3. Implemented filtering capability

Examples

Before this change

./actions-usage -user bxffour -token-file pat.txt

Output:

Generated by: https://github.com/self-actuated/actions-usage
Report for bxffour - last: 180 days.

Total repos: 22
Total private repos: 0
Total public repos: 22

Total workflow runs: 26
Total workflow jobs: 56

Total users: 1

Success: 34/56
Failure: 4/56
Cancelled: 0/56
Skipped: 18/56

Longest build: 1m19s
Average build time: 21s


Total usage: 19m55s (20 mins)

After this change

./actions-usage -user bxffour -token-file pat.txt -by-repo \
	--include bxffour/geoinfo,bxffour/bxffour.github.io

Output:

Total repos: 2
Total private repos: 0
Total public repos: 2

Total workflow runs: 26
Total workflow jobs: 56

Total users: 1

Success: 34/56
Failure: 4/56
Cancelled: 0/56
Skipped: 18/56

Longest build: 1m19s
Average build time: 21s


Repo                      Builds         Success        Failure        Cancelled      Skipped        Total          Average        Longest
bxffour/geoinfo           44             22             4              0              18             17m33s         24s            1m19s
bxffour/bxffour.github.io 12             12             0              0              0              2m22s          12s            29s

Total usage: 19m55s (20 mins)

Providing the repo list through a file

repos.txt
-------------------------
bxffour/geoinfo
bxffour/namespaces-go
./actions-usage -user bxffour -token-file pat.txt -by-repo \
	--include-file repos.txt
  • It is possible to send stdin as a file
cat repos.txt | ./actions-usage -user bxffour -token-file pat.txt -by-repo  --include-file -
  • it is also possible to use both the --include and the include-file options. The filter will include both options
./actions-usage -user bxffour -token-file pat.txt -by-repo \
	--include-file repos.txt --include bxffour/bxffour.github.io

Output:
The output still includes both bxffour.github.io and bxffour/geoinfo even though they were provided through different flags.

Repo                      Builds         Success        Failure        Cancelled      Skipped        Total          Average        Longest
bxffour/geoinfo           44             22             4              0              18             17m33s         24s            1m19s
bxffour/bxffour.github.io 12             12             0              0              0              2m22s          12s            29s

Total usage: 19m55s (20 mins)

Benefits

  • Users can now obtain GitHub Actions usage statistics specifically for the repositories they are interested in, leading to more targeted analysis and insights.
  • Provides flexibility and customization by allowing users to filter repositories based on their needs.

main.go Show resolved Hide resolved
@alexellis
Copy link
Member

I like this @bxffour I think we just need the ability to send stdin as a file instead.

cat file | command.... --include-file -

faas-cli has code for this in its invoke command that you can copy from for inspiration.

https://github.com/openfaas/faas-cli/blob/master/commands/invoke.go#L93

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@alexellis
Copy link
Member

@bxffour we'll need an example in the README for this too

@bxffour bxffour reopened this Jun 25, 2023
Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

Approved

@alexellis alexellis merged commit 0245cdc into self-actuated:master Jun 27, 2023
@yermulnik
Copy link

Can there be a release baked that includes this functionality please?

@alexellis
Copy link
Member

Yes it's been released today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offer a way to filter repos for large organisations / users
4 participants