-
-
Notifications
You must be signed in to change notification settings - Fork 20
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 command, command options and test bot data #437
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,22 @@ def formula_analytics_args | |
description: "Output Homebrew prefixes." | ||
switch "--homebrew-versions", | ||
description: "Output Homebrew versions." | ||
switch "--brew-command-run", | ||
description: "Output `brew` commands run." | ||
switch "--brew-command-run-options", | ||
description: "Output `brew` commands run with options." | ||
switch "--brew-test-bot-test", | ||
description: "Output `brew test-bot` steps run." | ||
switch "--json", | ||
description: "Output JSON. This is required: plain text support has been removed." | ||
switch "--all-core-formulae-json", | ||
description: "Output a different JSON format containing the JSON data for all " \ | ||
"Homebrew/homebrew-core formulae." | ||
switch "--setup", | ||
description: "Install the necessary gems, require them and exit without running a query." | ||
conflicts "--install", "--cask-install", "--install-on-request", "--build-error", "--os-version" | ||
conflicts "--install", "--cask-install", "--install-on-request", "--build-error", "--os-version", | ||
"--homebrew-devcmdrun-developer", "--homebrew-os-arch-ci", "--homebrew-prefixes", | ||
"--homebrew-versions", "--brew-command-run", "--brew-command-run-options", "--brew-test-bot-test" | ||
conflicts "--json", "--all-core-formulae-json", "--setup" | ||
named_args :none | ||
end | ||
|
@@ -113,12 +121,24 @@ def influx_analytics(args) | |
categories << :homebrew_prefixes if args.homebrew_prefixes? | ||
categories << :homebrew_versions if args.homebrew_versions? | ||
categories << :os_versions if args.os_version? | ||
categories << :command_run if args.brew_command_run? | ||
categories << :command_run_options if args.brew_command_run_options? | ||
categories << :test_bot_test if args.brew_test_bot_test? | ||
|
||
category_matching_buckets = [:build_error, :cask_install] | ||
category_matching_buckets = [:build_error, :cask_install, :command_run, :test_bot_test] | ||
|
||
# TODO: we don't seem to get a valid count for these categories, unclear why. | ||
count_being_weird_categories = [:command_run_options, :test_bot_test] | ||
|
||
categories.each do |category| | ||
additional_where = all_core_formulae_json ? " AND tap_name =~ /homebrew\\/(core|cask)/" : "" | ||
bucket = category_matching_buckets.include?(category) ? category : :formula_install | ||
bucket = if category_matching_buckets.include?(category) | ||
category | ||
elsif category == :command_run_options | ||
:command_run | ||
else | ||
:formula_install | ||
end | ||
|
||
case category | ||
when :homebrew_devcmdrun_developer | ||
|
@@ -136,6 +156,16 @@ def influx_analytics(args) | |
when :os_versions | ||
dimension_key = :os_version | ||
groups = [:os_name_and_version] | ||
when :command_run | ||
dimension_key = "command_run" | ||
groups = [:command] | ||
when :command_run_options | ||
dimension_key = "command_run_options" | ||
groups = [:command, :options, :devcmdrun, :developer] | ||
additional_where += " AND ci = 'false'" | ||
when :test_bot_test | ||
dimension_key = "test_bot_test" | ||
groups = [:command, :passed, :arch, :os] | ||
else | ||
dimension_key = if category == :cask_install | ||
:cask | ||
|
@@ -189,6 +219,24 @@ def influx_analytics(args) | |
end | ||
when :os_versions | ||
format_os_version_dimension(tags["os_name_and_version"]) | ||
when :command_run_options | ||
"#{tags["command"]} #{tags["options"]}" | ||
when :test_bot_test | ||
command_and_package, options = tags["command"].split.partition { |arg| !arg.start_with?("-") } | ||
|
||
# Cleanup bad data before https://github.com/Homebrew/homebrew-test-bot/pull/1043 | ||
# TODO: actually delete this from InfluxDB. | ||
# Can delete this code after 27th April 2025. | ||
next if %w[audit install linkage style test].exclude?(command_and_package.first) | ||
next if command_and_package.last.include?("/") | ||
next if options.include?("--tap=") | ||
next if options.include?("--only-dependencies") | ||
next if options.include?("--cached") | ||
|
||
command_and_options = (command_and_package + options.sort).join(" ") | ||
passed = (tags["passed"] == "true") ? "PASSED" : "FAILED" | ||
|
||
"#{command_and_options} (#{tags["os"]} #{tags["arch"]}) (#{passed})" | ||
else | ||
tags[groups.first.to_s] | ||
end | ||
|
@@ -212,10 +260,9 @@ def influx_analytics(args) | |
dimension = dimension.strip | ||
next if dimension.match?(/[<>]/) | ||
|
||
# we want any valid count that isn't the options out of: | ||
# "time", "count_options", "count_os_name_and_version", "count_package", "count_tap_name", "count_version" | ||
# we want any valid count that isn't the time field | ||
count = nil | ||
result["values"].first.drop(2).find do |possible_count| | ||
result["values"].first.compact.drop(1).find do |possible_count| | ||
break if count.present? | ||
|
||
count ||= begin | ||
|
@@ -229,7 +276,15 @@ def influx_analytics(args) | |
rescue ArgumentError, TypeError | ||
nil | ||
end | ||
|
||
next if count <= 0 | ||
|
||
count | ||
end | ||
|
||
# TODO: we don't seem to get a valid count for these categories, unclear why. | ||
count ||= 1 if count_being_weird_categories.include?(category) | ||
Comment on lines
+285
to
+286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SMillerDev @Bo98 (and any other @homebrew/maintainers who understand InfluxDB): similarly: it'd be good to figure this out. I'm actually not convinced the counts are correct in this case (so am not going to have the data displayed publicly anywhere yet) but hopefully this being merged gives you enough to reproduce the weirdness with some There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InfluxQL does not support grouping by fields and SQL however seems to? Or at least it appears to work fine in the query webpage. Will require using a totally different API to send the query but I can have a look at doing that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Bo98 Ah, makes sense now, thanks. Yeh, I think moving this to SQL would be desirable on multiple counts. |
||
|
||
odie "Invalid amount of items" if count.blank? | ||
|
||
json[:total_items] += 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bo98 @SMillerDev could do with some help figuring out if we can just delete the data here. I tried and failed:
$ influx delete --bucket analytics --predicate '_measurement="test_bot_test"' --start='2024-04-01T00:00:00Z' --stop='2024-04-26T07:07:19.000Z' --org-id *** --host '***' --token="***"
This ran successfully but didn't seem to delete anything 🤷🏻. Help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI as a whole doesn't really work with InfluxDB v3.