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 new improved ./scripts/bors-stats.rb #2707

Merged
merged 3 commits into from
Jun 16, 2021
Merged

Conversation

Anviking
Copy link
Member

@Anviking Anviking commented Jun 11, 2021

Issue Number

ADP-988 / ADP-970

Overview

  • Add new ./bors-stats.rb to replace ./bors-stats.sh

Comments

Commands:
  bors-stats.rb cause           # List failures and merged PRs to determine causes
  bors-stats.rb help [COMMAND]  # Describe available commands or one specific command
  bors-stats.rb list            # list all failures with optional filter (e.g. list 2292)
Usage:
  bors-stats.rb list

Options:
  [--count=N]                                          # How many PRs to fetch
                                                       # Default: 100
  [--details=DETAILS]                                  # Show details (true/false/auto)
                                                       # Default: auto
  [--search=SEARCH]                                    # Only show failures containing this string
  [--annotate=one two three]                           # Convert matches into tags
  [--auto-annotate], [--no-auto-annotate]              # Look for hspec failures and add as tags
  [--auto-annotate-fuzzy], [--no-auto-annotate-fuzzy]  # Look for hspec failures and add as tags (fuzzily)
  [--fetch-system], [--no-fetch-system]                # Scrape and add mac or linux as tag
  [--force-refetch], [--no-force-refetch]              # Fetch new data even if recent cache exists.

list all failures with optional filter (e.g. list 2292)

Skärmavbild 2021-06-11 kl  17 49 10

  • Not sure how easy this will run on other systems than mine yet, so I'm leaving the original bors-stats.sh with a notice.
  • I compared the outputs of the two yesterday, and they matched (but by default the new script fetches more data)

@Anviking Anviking changed the title Anviking/ruby bors stats Add new improved ./scripts/bors-stats.rb Jun 11, 2021
@Anviking Anviking self-assigned this Jun 11, 2021
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

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

This looks helpful but I had problems running it.
First it said the ansi package was missing, so I removed the require, and all the ANSI calls.
Then it said thor was missing...
Couldn't this work with just the basic packages that come with ruby 2.6?

@Anviking
Copy link
Member Author

Anviking commented Jun 14, 2021

Thanks for trying!

I switched to using nix:

#! /usr/bin/env nix-shell
#! nix-shell -i ruby -p "ruby.withPackages (ps: with ps; [ thor ])"

I didn't find the ansi package using nix, but it was easy to remove.

thor would take a bit more time to remove (I've never written ruby CLI tools), so I didn't. (But now it uses nix)

@Anviking Anviking force-pushed the anviking/ruby-bors-stats branch from da1009e to 33a35dd Compare June 14, 2021 13:43
@Anviking
Copy link
Member Author

Idea for future: Maybe one could add some more general and flexible way of filtering like:

./scripts/bors-stats.rb list | jq '<some jq filter>' | ./scripts/bors-stats.rb view

Or:

./scripts/bors-stats.rb list --jq-filter "<some jq filter>"

@Anviking Anviking force-pushed the anviking/ruby-bors-stats branch from 33a35dd to 182fc7e Compare June 14, 2021 17:11
@rvl
Copy link
Contributor

rvl commented Jun 15, 2021

I had another try...
Looks like the ruby package brotli isn't packaged in nixpkgs, so we would need a Gemfile or something.
But we can just use curl for fetching, and it handles redirects, compression, etc.
I pushed a change to do that, but I'm not sure if it works fully.
Ruby is hard.

@piotr-iohk
Copy link
Contributor

It seems that logs fetched from hydra are in binary format 🤔 :

$ ./bors-stats.rb download-logs --dir logs2 --tag '#timeout'
https://hydra.iohk.io/build/6463832
https://hydra.iohk.io/build/6467483
https://hydra.iohk.io/build/6468421
https://hydra.iohk.io/build/6599026

$ cat logs2/6599026.log 
QT�bt���'�1�9�*U��3��n�Ӥ��S�E��4����ˤ�x�8e��0��(������;������U�����*S����pun�8~6��!�"+z3]I`

@rvl
Copy link
Contributor

rvl commented Jun 15, 2021

Fixing now... stand by. I forgot to add the curl --compressed which enables decompression.

@rvl rvl force-pushed the anviking/ruby-bors-stats branch from 5a1a36f to 4e51c50 Compare June 15, 2021 09:42
@rvl
Copy link
Contributor

rvl commented Jun 15, 2021

Try now. Check curl -V for brotli support - most distros should have it by now. Otherwise use:

$ nix-shell --run "./scripts/bors-stats.rb download-logs ..."

@piotr-iohk
Copy link
Contributor

nix-shell --run "./scripts/bors-stats.rb download-logs ..."

Ok, well. It doesn't work for me from nix-shell:

$ nix-shell --run "./scripts/bors-stats.rb download-logs --dir logs_b"
warning: dumping very large path (> 256 MiB); this may run out of memory
curl: (61) Unrecognized content encoding type. libcurl understands deflate, gzip content encodings.
curl exited with status pid 113191 exit 61

But works fine while running as script:

$ ./scripts/bors-stats.rb download-logs --dir logs_b

https://hydra.iohk.io/build/5925989
https://buildkite.com/input-output-hk/cardano-wallet/builds/14064
https://hydra.iohk.io/build/5925989
https://buildkite.com/input-output-hk/cardano-wallet/builds/14064
https://buildkite.com/input-output-hk/cardano-wallet/builds/14075
...

(I'm wondering why it downloads 5925989 and 14064) twice... anyway, both: logs from hydra and buildkite are in the text format now.

@rvl
Copy link
Contributor

rvl commented Jun 15, 2021

@piotr-iohk Make sure you're on revision 4e51c50

git fetch && git checkout anviking/ruby-bors-stats && git stash && git reset --hard origin/anviking/ruby-bors-stats

@rvl
Copy link
Contributor

rvl commented Jun 15, 2021

It probably downloads the same hydra build logs twice because it's a cached failure.

@Anviking Anviking force-pushed the anviking/ruby-bors-stats branch from 2b18827 to ee1c1ca Compare June 15, 2021 20:03
rvl and others added 2 commits June 16, 2021 11:53
Supports:
- Ruby
- Customizable showing of per-failure details (true/false/auto)
- Supports pagination for more historical data (--count N_PRS)
- Correlate failures with merged PRs (show both in a list)
- Filter by issue/tag (list 2040)
- Filter by comment bodyText (--search API)
- Filter by date with --before and --after options
- Scrape hydra builds for os type (--fetch-system)
- Auto-tag hspec output using regexes (--auto-annotate, --auto-annotate-fuzzy)
- Cause breakdown stats don't break on multiple tags in same failure
- Add --annotate option
- download-logs command
- Automatic caching
- Add --force-refetch option to disable caching
- Get API tokens from a command instead of environment variables

Co-authored-by: Rodney Lorrimar <[email protected]>
@rvl rvl force-pushed the anviking/ruby-bors-stats branch from ee1c1ca to 303f130 Compare June 16, 2021 01:54
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

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

I made more improvements

  • Nicer log messages
  • Added some source comments
  • Password command
  • Reordered functions in approximate order of most interesting to least interesting
  • Added caching (and --force-refetch override) to most fetches
  • Tweaked log filenames and cache path
  • Squashed and rebased

I retested the bits that I understand how to use, so hopefully haven't broken anything again.

@rvl rvl merged commit 6007796 into master Jun 16, 2021
@rvl rvl deleted the anviking/ruby-bors-stats branch June 16, 2021 02:42
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.

3 participants