Skip to content

Add Coverband for production code coverage tracking#163

Merged
JuanVqz merged 16 commits intorailsbump:mainfrom
JuanVqz:feature/add-coverband
Apr 9, 2026
Merged

Add Coverband for production code coverage tracking#163
JuanVqz merged 16 commits intorailsbump:mainfrom
JuanVqz:feature/add-coverband

Conversation

@JuanVqz
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz commented Apr 9, 2026

Summary

  • Adds Coverband gem for tracking which code paths are hit in production (web + Sidekiq)
  • Uses existing Redis instance, mounts web UI at /coverband behind basic auth (same creds as Sidekiq)
  • Helps identify dead code before the DirectResolver migration

Test plan

  • Deploy to staging/production
  • Visit /coverband ask Juan for credentials
  • Verify coverage data appears after some traffic
  • Monitor Redis memory usage

JuanVqz added 10 commits April 8, 2026 15:51
CGI.parse was removed in Ruby 4.0, causing VCR 6.3.1 to fail.
Unmaintained since 2022 and incompatible with Ruby 4.0 (C extension).
Ruby 4.0 ships with the debug gem as a built-in replacement.
Its dependency rouge uses CGI.parse which is removed in Ruby 4.0.
Rails built-in error pages are sufficient for development.
faraday, faraday_middleware, faraday-multipart, and faraday-retry were
listed explicitly but never used directly in app code. Octokit pulls in
faraday transitively via sawyer. Removing the explicit pins allows
faraday to resolve to 2.x (from 1.x), dropping the deprecated
faraday_middleware and several unused adapter gems.
The codecov gem is deprecated and archived. Replace it with the official
Codecov GitHub Action which picks up SimpleCov's coverage output and
uploads it using the existing CODECOV_TOKEN secret.
CI runs on ubuntu (x86_64-linux) but lockfiles only had arm64-darwin-25.
Tracks which code paths are actually hit in production (web + Sidekiq),
helping identify dead code before the DirectResolver migration.

- Uses existing Redis via $redis global
- Mounts web UI at /coverband behind basic auth (same creds as Sidekiq)
- Enables view tracking and background reporting
@JuanVqz JuanVqz self-assigned this Apr 9, 2026
@JuanVqz JuanVqz requested a review from a team April 9, 2026 06:06
Copy link
Copy Markdown
Contributor

@jeremysmithco jeremysmithco left a comment

Choose a reason for hiding this comment

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

Cool! I haven't used Coverband before.

There might be some way to consolidate the auth checks in routes, like with a route constraint or something. But that's minor.

@jeremysmithco
Copy link
Copy Markdown
Contributor

@JuanVqz I just noticed when I tried to visit /coverband locally that it couldn't find Redis, and it appears it's because of the initializer load order. (coverband.rb loads before redis.rb, so $redis is nil when Coverband::Adapters::RedisStore.new($redis) runs) Were you seeing this on your machine?

Co-authored-by: Juan Vásquez <javasgon@gmail.com>
JuanVqz added 2 commits April 9, 2026 09:44
Coverband's initializer was using $redis which is defined in
config/initializers/redis.rb. Since initializers load alphabetically,
coverband.rb loads before redis.rb, making $redis nil and causing
"undefined method 'get' for nil" errors. Create a dedicated Redis
connection directly in the Coverband config to avoid the load order
dependency.
Enable web_enable_clear so coverage data can be reset from the
/coverband UI, useful for getting a clean baseline after deploys.
Add ignore list to exclude boot/config files that add noise to
the coverage report without providing actionable insights.
@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented Apr 9, 2026

@JuanVqz I just noticed when I tried to visit /coverband locally that it couldn't find Redis, and it appears it's because of the initializer load order. (coverband.rb loads before redis.rb, so $redis is nil when Coverband::Adapters::RedisStore.new($redis) runs) Were you seeing this on your machine?

Fixed, thanks for flagging it

@JuanVqz JuanVqz merged commit cc56abc into railsbump:main Apr 9, 2026
2 checks passed
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