From 0a45a24df93e205ffc629ac9bfb492ec0438f77c Mon Sep 17 00:00:00 2001 From: Shinji Kakimoto Date: Sat, 11 Jan 2025 08:34:31 +0900 Subject: [PATCH 1/6] FIX: HTTP_HOST headers. --- lib/pact/provider/request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pact/provider/request.rb b/lib/pact/provider/request.rb index 0c51eb82..0c14c3bc 100644 --- a/lib/pact/provider/request.rb +++ b/lib/pact/provider/request.rb @@ -35,7 +35,7 @@ def body def headers request_headers = {} - request_headers.merge!('HTTP_HOST' => 'localhost') if defined?(Sinatra) + request_headers.merge!('HOST' => 'localhost') if defined?(Sinatra) return request_headers if expected_request.headers.is_a?(Pact::NullExpectation) expected_request.headers.each do |key, value| From 1379e6e21b177e23b3491c8ccff19e05b5bf149f Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Mon, 20 Jan 2025 16:13:56 +0000 Subject: [PATCH 2/6] test: test examples in CI --- .github/workflows/test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cdd81b70..c6b79453 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,6 @@ jobs: matrix: ruby_version: ["2.7", "3.0", "3.1", "3.2", "3.3"] os: ["ubuntu-latest","windows-latest","macos-latest"] - # defaults: - # run: - # shell: bash steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 @@ -27,6 +24,10 @@ jobs: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - run: "bundle exec rake" + - run: "bundle exec rake spec" + working-directory: example/zoo-app + - run: "bundle exec rake pact:verify" + working-directory: example/animal-service test-with-rack-2: runs-on: ${{ matrix.os }} strategy: @@ -59,4 +60,4 @@ jobs: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - run: "bundle exec appraisal install" - - run: "bundle exec appraisal activesupport rake spec_with_active_support" + - run: "bundle exec appraisal activesupport rake spec_with_active_support" \ No newline at end of file From c74112755d82d27aeca061060b256397f87cd892 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Mon, 20 Jan 2025 16:29:09 +0000 Subject: [PATCH 3/6] chore: update gemspecs --- example/animal-service/Gemfile.lock | 8 +++++--- example/zoo-app/Gemfile.lock | 12 ++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/example/animal-service/Gemfile.lock b/example/animal-service/Gemfile.lock index 0287c371..72687cfa 100644 --- a/example/animal-service/Gemfile.lock +++ b/example/animal-service/Gemfile.lock @@ -1,12 +1,14 @@ PATH remote: ../.. specs: - pact (1.65.3) + pact (1.66.0) + jsonpath (~> 1.0) pact-mock_service (~> 3.0, >= 3.3.1) - pact-support (~> 1.16, >= 1.16.9) + pact-support (~> 1.19, >= 1.19.0) rack-test (>= 0.6.3, < 3.0.0) rainbow (~> 3.1) rspec (~> 3.0) + string_pattern (~> 2.0) thor (>= 0.20, < 2.0) GEM @@ -104,7 +106,7 @@ DEPENDENCIES rake rspec sequel - sinatra (>= 4.0.0) + sinatra (>= 4.1.0) sqlite3 BUNDLED WITH diff --git a/example/zoo-app/Gemfile.lock b/example/zoo-app/Gemfile.lock index a8c79cfa..20f10ef6 100644 --- a/example/zoo-app/Gemfile.lock +++ b/example/zoo-app/Gemfile.lock @@ -1,12 +1,14 @@ PATH remote: ../.. specs: - pact (1.65.3) + pact (1.66.0) + jsonpath (~> 1.0) pact-mock_service (~> 3.0, >= 3.3.1) - pact-support (~> 1.16, >= 1.16.9) + pact-support (~> 1.19, >= 1.19.0) rack-test (>= 0.6.3, < 3.0.0) rainbow (~> 3.1) rspec (~> 3.0) + string_pattern (~> 2.0) thor (>= 0.20, < 2.0) GEM @@ -27,8 +29,11 @@ GEM mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) json (2.8.2) + jsonpath (1.1.5) + multi_json method_source (1.1.0) mini_mime (1.1.5) + multi_json (1.15.0) multi_xml (0.7.1) bigdecimal (~> 3.1) ostruct (0.6.1) @@ -66,6 +71,7 @@ GEM rack (>= 3) rainbow (3.1.1) rake (13.2.1) + regexp_parser (2.10.0) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -79,6 +85,8 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) + string_pattern (2.3.0) + regexp_parser (~> 2.5, >= 2.5.0) sync (0.5.0) table_print (1.5.7) term-ansicolor (1.11.2) From bd979bde11ff91e73e345ceb989863f1991b4938 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Mon, 20 Jan 2025 16:37:30 +0000 Subject: [PATCH 4/6] chore(ci): install bundle before exec --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6b79453..2f62b391 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,9 +24,9 @@ jobs: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - run: "bundle exec rake" - - run: "bundle exec rake spec" + - run: "bundle install && bundle exec rake spec" working-directory: example/zoo-app - - run: "bundle exec rake pact:verify" + - run: "bundle install && bundle exec rake pact:verify" working-directory: example/animal-service test-with-rack-2: runs-on: ${{ matrix.os }} From 4295dd38b618a90eb8817e32aaf09836504a78bb Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Mon, 20 Jan 2025 16:53:30 +0000 Subject: [PATCH 5/6] chore(ci): run examples on ruby 3.1+ --- .github/workflows/test.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f62b391..52e0642c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,38 @@ jobs: - run: "bundle exec rake" - run: "bundle install && bundle exec rake spec" working-directory: example/zoo-app - - run: "bundle install && bundle exec rake pact:verify" + - run: "bundle install" + working-directory: example/animal-service + - run: "bundle exec rake pact:verify" + if: matrix.os != 'windows-latest' + working-directory: example/animal-service + - run: "ruby.exe -S pact verify --pact-helper ./spec/service_consumers/pact_helper.rb --pact-uri ../zoo-app/spec/pacts/zoo_app-animal_service.json" + if: matrix.os == 'windows-latest' + working-directory: example/animal-service + test_examples: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + ruby_version: ["3.1", "3.2", "3.3"] # multi_xml-0.7.1 (dep of httparty) requires ruby version >= 3.1.2 + os: ["ubuntu-latest","windows-latest","macos-latest"] + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - run: "bundle install" + working-directory: example/zoo-app + - run: "bundle exec rake spec" + working-directory: example/zoo-app + - run: "bundle install" + working-directory: example/animal-service + - run: "bundle exec rake pact:verify" + if: matrix.os != 'windows-latest' + working-directory: example/animal-service + - run: "ruby.exe -S pact verify --pact-helper ./spec/service_consumers/pact_helper.rb --pact-uri ../zoo-app/spec/pacts/zoo_app-animal_service.json" + if: matrix.os == 'windows-latest' working-directory: example/animal-service test-with-rack-2: runs-on: ${{ matrix.os }} From 1b1a8bf5ae0833c36e7b447ff4f7c4e05c42d15d Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Mon, 20 Jan 2025 17:03:45 +0000 Subject: [PATCH 6/6] test: skip verify example on windows --- .github/workflows/test.yml | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52e0642c..aea11862 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,39 +25,10 @@ jobs: bundler-cache: true - run: "bundle exec rake" - run: "bundle install && bundle exec rake spec" + if: matrix.ruby_version > '3.0' working-directory: example/zoo-app - - run: "bundle install" - working-directory: example/animal-service - - run: "bundle exec rake pact:verify" - if: matrix.os != 'windows-latest' - working-directory: example/animal-service - - run: "ruby.exe -S pact verify --pact-helper ./spec/service_consumers/pact_helper.rb --pact-uri ../zoo-app/spec/pacts/zoo_app-animal_service.json" - if: matrix.os == 'windows-latest' - working-directory: example/animal-service - test_examples: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - ruby_version: ["3.1", "3.2", "3.3"] # multi_xml-0.7.1 (dep of httparty) requires ruby version >= 3.1.2 - os: ["ubuntu-latest","windows-latest","macos-latest"] - steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby_version }} - bundler-cache: true - - run: "bundle install" - working-directory: example/zoo-app - - run: "bundle exec rake spec" - working-directory: example/zoo-app - - run: "bundle install" - working-directory: example/animal-service - - run: "bundle exec rake pact:verify" - if: matrix.os != 'windows-latest' - working-directory: example/animal-service - - run: "ruby.exe -S pact verify --pact-helper ./spec/service_consumers/pact_helper.rb --pact-uri ../zoo-app/spec/pacts/zoo_app-animal_service.json" - if: matrix.os == 'windows-latest' + - run: "bundle install && bundle exec rake pact:verify" + if: matrix.os != 'windows-latest' && matrix.ruby_version > '3.0' working-directory: example/animal-service test-with-rack-2: runs-on: ${{ matrix.os }}