Skip to content

Commit

Permalink
test: report test bot test results to analytics.
Browse files Browse the repository at this point in the history
This is used to identify the failure/success rate of various commands.
  • Loading branch information
MikeMcQuaid committed Apr 26, 2024
1 parent 541221a commit 28126a5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -6,4 +6,5 @@ group :test do
gem "activesupport"
gem "rspec"
gem "simplecov"
gem "sorbet-runtime"
end
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -41,6 +41,7 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sorbet-runtime (0.5.11357)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

Expand All @@ -51,3 +52,4 @@ DEPENDENCIES
activesupport
rspec
simplecov
sorbet-runtime
7 changes: 7 additions & 0 deletions lib/test.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "utils/analytics"

module Homebrew
class Test
def failed_steps
Expand Down Expand Up @@ -52,6 +54,11 @@ def test(*arguments, named_args: nil, env: {}, verbose: @verbose, ignore_failure
)
step.run(dry_run: @dry_run, fail_fast: @fail_fast)
@steps << step

if ENV["HOMEBREW_TEST_BOT_ANALYTICS"].present?
::Utils::Analytics.report_test_bot_test(step.command_short, step.passed?)
end

step
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -6,6 +6,12 @@
minimum_coverage 10
end

# Setup Sorbet for usage in stubs.
require "sorbet-runtime"
class Module
include T::Sig
end

PROJECT_ROOT = Pathname(__dir__).parent.freeze
STUB_PATH = (PROJECT_ROOT/"spec/stub").freeze
$LOAD_PATH.unshift(STUB_PATH)
Expand Down
9 changes: 9 additions & 0 deletions spec/stub/utils/analytics.rb
@@ -0,0 +1,9 @@
# typed: true
# frozen_string_literal: true

module Utils
module Analytics
sig { params(command: String, passed: T::Boolean).void }
def self.report_test_bot_test(command, passed); end
end
end

0 comments on commit 28126a5

Please sign in to comment.