Skip to content

Comments

Enable strict typing in Homebrew::TestBot (take 3)#21576

Open
dduugg wants to merge 3 commits intomainfrom
strict-typing-test-bot
Open

Enable strict typing in Homebrew::TestBot (take 3)#21576
dduugg wants to merge 3 commits intomainfrom
strict-typing-test-bot

Conversation

@dduugg
Copy link
Member

@dduugg dduugg commented Feb 14, 2026

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

AI was used to reapply the original strict typing PR, identify the two runtime type errors from the revert, implement fixes, and write regression specs. All changes were verified locally with brew typecheck, brew style --fix --changed, and brew tests for each affected spec file.


What does this PR do?

Reapplies #21539 (reverted in #21549) to enable typed: strict across all Homebrew::TestBot files, with fixes for the two Sorbet runtime type errors that caused the revert:

  1. Test#test Pathname handling: The test method now accepts T.any(String, Pathname) for its splat arguments and converts them to strings via .map(&:to_s) before forwarding to Step.new. This fixes the TypeError when callers like TestCleanup pass Pathname objects (e.g. repository).

  2. BottlesFetch#fetch_bottles! tag type: fetch_bottles! and formulae_by_tag now use Utils::Bottles::Tag instead of Symbol, matching what bottle_specification.collector.tags actually returns at runtime.

Additional type fixes included in the reapplied commit:

  • Formulae#testing_portable_ruby? returns false (not nil) via !! when tap is nil
  • Formulae#verify_local_bottles returns false (not bare return) for the portable ruby early exit
  • FormulaeDependents#install_dependent passes dependent.name (String) to skipped, not dependent (Formula)

Regression specs added

Tests use public run! interfaces where practical; send is used only for deeply internal methods without a reasonable public entry point.

  • bottles_fetch_spec.rb — exercises BottlesFetch#run! to verify Utils::Bottles::Tag is accepted
  • test_cleanup_spec.rb — exercises CleanupAfter#run! to verify cleanup_shared passes String to helper methods
  • test_spec.rb — verifies Pathname arguments are converted to strings
  • formulae_spec.rb — verifies testing_portable_ruby? and verify_local_bottles return T::Boolean
  • junit_spec.rb — verifies REXML loads correctly (the require was moved to initialize)
  • test_formulae_spec.rb — verifies download_artifacts_from_previous_run! hash access
  • setup_spec.rb — updated to use Homebrew::Cmd::TestBotCmd::Args

Fix two runtime type errors found in CI after the initial strict typing PR:

1. `Test#test` arguments parameter: Accept `T.any(String, Pathname)` and
   convert to strings via `.map(&:to_s)` before passing to `Step.new`.
   Callers like `TestCleanup` pass `repository` (a `Pathname`) directly.

2. `BottlesFetch#fetch_bottles!` tag parameter: Accept `Utils::Bottles::Tag`
   (what `collector.tags` actually returns) instead of `Symbol`.
@dduugg dduugg changed the title Enable strict typing in Homebrew::TestBot, redux test_bot: enable strict typing and fix runtime type errors Feb 14, 2026
@dduugg dduugg changed the title test_bot: enable strict typing and fix runtime type errors Enable strict typing in Homebrew::TestBot (take 3) Feb 14, 2026
@dduugg dduugg force-pushed the strict-typing-test-bot branch 3 times, most recently from c67c011 to b93074b Compare February 14, 2026 21:57
Test through public run! interfaces where practical
(BottlesFetch, CleanupAfter); use send for deeply
internal methods without a reasonable public entry point.
@dduugg dduugg force-pushed the strict-typing-test-bot branch from b93074b to c8b2f7a Compare February 15, 2026 19:09
@dduugg dduugg marked this pull request as ready for review February 17, 2026 19:17
Copilot AI review requested due to automatic review settings February 17, 2026 19:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reapplies Sorbet typed: strict across the Homebrew::TestBot implementation, addressing previously observed runtime type mismatches and adding regression specs to keep TestBot’s strict typing stable over time.

Changes:

  • Switches multiple test_bot/* components to typed: strict, adding signatures and type-safe coercions (notably PathnameString for command arguments).
  • Aligns bottle tag typing with runtime (Utils::Bottles::Tag) and tightens boolean return types to satisfy strict typing.
  • Adds/updates RSpec coverage for key strict-typing regressions (Test runner helpers, bottles fetch tags, REXML/JUnit, portable ruby boolean returns, artifact cache hash access).

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Library/Homebrew/test_bot/test_runner.rbi Removes obsolete RBI stub for TestRunner.
Library/Homebrew/test_bot/test_runner.rb Converts to typed: strict and adds typed orchestration for TestBot runs and output artifacts.
Library/Homebrew/test_bot/test_formulae.rbi Removes obsolete RBI stub for TestFormulae.
Library/Homebrew/test_bot/test_formulae.rb Adds strict signatures and type fixes for artifact handling, git operations, and cleanup helpers.
Library/Homebrew/test_bot/test_cleanup.rb Adds strict signatures and coerces repository paths to String for typed helpers/system calls.
Library/Homebrew/test_bot/test.rb Adds strict signatures and coerces splat command args (incl. Pathname) to String for Step.
Library/Homebrew/test_bot/tap_syntax.rb Adds strict signatures and narrows tap usage for typed access.
Library/Homebrew/test_bot/step.rb Adds strict signatures and type assertions for command execution, timing, and GitHub Actions annotations.
Library/Homebrew/test_bot/setup.rb Adds strict signature for run!.
Library/Homebrew/test_bot/junit.rb Adds strict typing and ensures REXML is required before use.
Library/Homebrew/test_bot/formulae_detect.rb Adds strict typing and refines tap/git interactions for formula detection.
Library/Homebrew/test_bot/formulae_dependents.rb Adds strict typing and fixes dependent skipping/recording to use formula names.
Library/Homebrew/test_bot/formulae.rb Adds strict typing and boolean return fixes around portable ruby and local bottle verification.
Library/Homebrew/test_bot/cleanup_before.rb Adds strict signature for run!.
Library/Homebrew/test_bot/cleanup_after.rb Adds strict signature for run! and pkill helper.
Library/Homebrew/test_bot/bottles_fetch.rb Adds strict typing and switches bottle tag typing to Utils::Bottles::Tag.
Library/Homebrew/test_bot.rb Marks TestBot entrypoint as typed: strict and adds signatures for helpers.
Library/Homebrew/test/test_bot/test_spec.rb Adds regression spec for PathnameString coercion in Test#test.
Library/Homebrew/test/test_bot/test_formulae_spec.rb Adds regression spec for artifact download hash access keyed by new SHAs.
Library/Homebrew/test/test_bot/test_cleanup_spec.rb Adds regression spec ensuring cleanup helpers receive String repository paths.
Library/Homebrew/test/test_bot/setup_spec.rb Updates spec to use Homebrew::Cmd::TestBotCmd::Args and correct require.
Library/Homebrew/test/test_bot/junit_spec.rb Adds regression spec ensuring REXML is loaded and JUnit XML generation works.
Library/Homebrew/test/test_bot/formulae_spec.rb Adds regression specs for strict boolean returns in Formulae helpers.
Library/Homebrew/test/test_bot/bottles_fetch_spec.rb Adds regression spec ensuring Tag objects are accepted and used in fetch commands.
Files not reviewed (2)
  • Library/Homebrew/test_bot/test_formulae.rbi: Language not supported
  • Library/Homebrew/test_bot/test_runner.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@Homebrew/maintainers let's fix forward when this gets merged please 🙇🏻

@MikeMcQuaid
Copy link
Member

@dduugg Merge where you're ideally gonna be around for a few hours to help debug any issues!

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