From 8c2c711d97d7bf50ec23af0563d69b98caf469eb Mon Sep 17 00:00:00 2001 From: Brandon Weaver Date: Wed, 28 Oct 2026 19:41:36 -0700 Subject: [PATCH 1/2] Add headers request option Lets callers send custom HTTP headers with a check request. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ lib/freno/client/request.rb | 5 +++-- test/freno/client/requests/check_test.rb | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23db9a1..f439c87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `headers` request option to send custom HTTP headers with a check + ## [0.9.0] - 2024-04-18 ### Added diff --git a/lib/freno/client/request.rb b/lib/freno/client/request.rb index 2b36935..53e84e0 100644 --- a/lib/freno/client/request.rb +++ b/lib/freno/client/request.rb @@ -9,7 +9,7 @@ class Client class Request include Freno::Client::Preconditions - attr_reader :faraday, :args, :options, :raise_on_timeout + attr_reader :faraday, :args, :options, :raise_on_timeout, :headers def self.perform(**kwargs) new(**kwargs).perform @@ -22,6 +22,7 @@ def initialize(**kwargs) @raise_on_timeout = options.fetch(:raise_on_timeout, true) @verb = options.fetch(:verb, :head) + @headers = options.fetch(:headers, nil) end def perform @@ -38,7 +39,7 @@ def perform protected def request(verb, path, params) - faraday.send(verb, path, params) + faraday.send(verb, path, params, headers) end def path diff --git a/test/freno/client/requests/check_test.rb b/test/freno/client/requests/check_test.rb index 931e664..4c1c371 100644 --- a/test/freno/client/requests/check_test.rb +++ b/test/freno/client/requests/check_test.rb @@ -79,4 +79,25 @@ def test_perform_calls_the_proper_service_endpoint_with_low_priority_and_succeed assert_equal 200, response.code assert_equal({ "StatusCode" => 200, "Value" => 0.025075, "Threshold" => 1, "Message" => "" }, response.body) end + + def test_perform_sends_custom_headers + faraday = stubbed_faraday do |stub| + stub.head("/check/github/mysql/main") do |env| + assert_equal "1", env.request_headers["X-Example"] + [200, {}, <<-BODY] + {"StatusCode":200, "Value":0.025075, "Threshold":1, "Message":""} + BODY + end + end + + request = Check.new( + faraday: faraday, + app: "github", + store_type: "mysql", + store_name: "main", + options: { headers: { "X-Example" => "1" } } + ) + + assert_equal :ok, request.perform.meaning + end end From f7b3854493a8229c9bff43909f5958034e92e975 Mon Sep 17 00:00:00 2001 From: Brandon Weaver Date: Mon, 2 Nov 2026 12:29:21 -0800 Subject: [PATCH 2/2] Fix CI for the Ubuntu 26.04 runner image and newer RuboCop cops ubuntu-latest now points to Ubuntu 26.04, where ruby/setup-ruby has no Ruby 3.0 or 3.1 builds. Pin the job to ubuntu-24.04 so the full matrix keeps testing every Ruby the gemspec supports. RuboCop's version floats and new cops are enabled, so newer releases flag existing code. Define the two error classes with the class keyword (Style/EmptyClassDefinition) and drop redundant parentheses (Style/RedundantParentheses). Behavior is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ruby.yml | 4 +++- lib/freno/client.rb | 2 +- lib/freno/client/errors.rb | 3 ++- lib/freno/client/preconditions.rb | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index a23112d..7ca7ce7 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -8,7 +8,9 @@ on: - main jobs: test: - runs-on: ubuntu-latest + # Ruby 3.0 and 3.1 builds aren't available for Ubuntu 26.04, which + # ubuntu-latest now points to. + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: diff --git a/lib/freno/client.rb b/lib/freno/client.rb index 36505e1..4674bb5 100644 --- a/lib/freno/client.rb +++ b/lib/freno/client.rb @@ -233,7 +233,7 @@ def decorated(request) outermost = to_decorate[0] current = outermost - (to_decorate[1..]).each do |decorator| + to_decorate[1..].each do |decorator| current.request = decorator current = current.request end diff --git a/lib/freno/client/errors.rb b/lib/freno/client/errors.rb index afbb591..fbbb7a1 100644 --- a/lib/freno/client/errors.rb +++ b/lib/freno/client/errors.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true module Freno - Error = Class.new(StandardError) + class Error < StandardError + end end diff --git a/lib/freno/client/preconditions.rb b/lib/freno/client/preconditions.rb index a49174b..2c5ed55 100644 --- a/lib/freno/client/preconditions.rb +++ b/lib/freno/client/preconditions.rb @@ -5,7 +5,8 @@ class Client module Preconditions module_function - PreconditionNotMet = Class.new(ArgumentError) + class PreconditionNotMet < ArgumentError + end class Checker attr_reader :errors