From db7ded66fe32592671b8db5626d3f78a6dac2d05 Mon Sep 17 00:00:00 2001 From: Bryan Powell Date: Sun, 28 Jun 2026 09:08:13 -0700 Subject: [PATCH] Fix CI: lint offense, server spec on old Ruby, and test on Ruby 4 - ffi/lib/llhttp.rb: add empty line after module inclusion (Layout/EmptyLinesAfterModuleInclusion). - spec/initialize.rb: silence Lint/RedundantRequireStatement; the require is still needed on Ruby < 3.x where Pathname isn't autoloaded. - spec/acceptance/server_spec.rb: poll until the forked server responds instead of a single curl under a 1s timeout (removes a cold-start race), and skip it on Ruby < 3.2 since the async test stack dropped 3.1 and bundle then resolves to a stack that can't serve the request. llhttp core is still covered by the rest of the suite on those versions. - ci.yml: add Ruby 4.0 to the FFI and MRI test matrices. --- .github/workflows/ci.yml | 2 ++ ffi/lib/llhttp.rb | 1 + spec/acceptance/server_spec.rb | 19 ++++++++++++++++--- spec/initialize.rb | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6631579..48c6c22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: - 3.2 - 3.3 - 3.4 + - "4.0" fail-fast: false @@ -94,6 +95,7 @@ jobs: - 3.2 - 3.3 - 3.4 + - "4.0" fail-fast: false diff --git a/ffi/lib/llhttp.rb b/ffi/lib/llhttp.rb index 236c81e..329b06c 100644 --- a/ffi/lib/llhttp.rb +++ b/ffi/lib/llhttp.rb @@ -10,6 +10,7 @@ module LLHttp require_relative "llhttp/version" extend FFI::Library + ffi_lib(FFI::Compiler::Loader.find("llhttp-ext")) callback :llhttp_data_cb, [:pointer, :size_t], :void diff --git a/spec/acceptance/server_spec.rb b/spec/acceptance/server_spec.rb index 1efedb2..fba55be 100644 --- a/spec/acceptance/server_spec.rb +++ b/spec/acceptance/server_spec.rb @@ -29,9 +29,22 @@ @bound_endpoint&.close end - it "parses" do - Timeout.timeout(1) do - expect(system("curl -v http://localhost:9000")).to be(true) + # The async-based test server requires Ruby >= 3.2: newer async drops 3.1, so + # on older Rubies bundle resolves to a stack that can't serve the request. + # llhttp core is still exercised by the rest of the suite on those versions. + it "parses", skip: RUBY_VERSION < "3.2" && "async test server requires Ruby >= 3.2" do + # Poll until the forked server is accepting and responding rather than + # asserting on a single curl under a tight timeout, so a slow fork + Async + # reactor cold start on a loaded CI runner costs a few retries, not a + # spurious failure. + result = false + + Timeout.timeout(10) do + until (result = system("curl -sf http://localhost:9000", out: File::NULL, err: File::NULL)) + sleep(0.05) + end end + + expect(result).to be(true) end end diff --git a/spec/initialize.rb b/spec/initialize.rb index 2e21c11..b3e73df 100644 --- a/spec/initialize.rb +++ b/spec/initialize.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "pathname" +require "pathname" # standard:disable Lint/RedundantRequireStatement -- needed on Ruby < 3.x where Pathname isn't autoloaded initializers = Pathname.new(File.expand_path("../initializers", __FILE__))