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

test: report test bot test results to analytics. #1025

Merged
merged 1 commit into from Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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