Skip to content

Commit 5dbf8a7

Browse files
authored
Merge pull request #38 from safdotdev/feat/v2
Feat/v2
2 parents 4cc862a + 3418e90 commit 5dbf8a7

File tree

131 files changed

+3162
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+3162
-88
lines changed

.github/workflows/test-broker.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Test Broker Workflow
2+
3+
on:
4+
# push:
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
ruby_version: ["3.3"]
15+
os: [
16+
"ubuntu-latest",
17+
"windows-latest",
18+
"macos-latest"
19+
]
20+
project: [e2e]
21+
runs-on: ${{ matrix.os }}
22+
defaults:
23+
run:
24+
shell: bash
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby_version }}
30+
bundler-cache: true
31+
working-directory: ${{ matrix.project }}
32+
- run: bundle install
33+
name: Install dependencies (pact_broker)
34+
working-directory: pact_broker
35+
- run: bundle exec rackup -s puma --pid broker.pid &
36+
shell: bash
37+
name: Start Pact Broker
38+
working-directory: pact_broker
39+
- run: "bundle exec rake pact:spec"
40+
name: Pact consumer tests
41+
working-directory: ${{ matrix.project }}
42+
- run: "bundle exec rake pact:verify:foobar"
43+
name: Pact provider verification (directory)
44+
working-directory: ${{ matrix.project }}
45+
- run: "bundle exec rake pact:publish"
46+
name: Publish pacts to broker
47+
working-directory: ${{ matrix.project }}/consumer
48+
- run: "bundle exec rake pact:verify:foobar"
49+
name: Pact provider verification (broker via PACT_URL)
50+
working-directory: ${{ matrix.project }}/provider
51+
env:
52+
PACT_URL: http://localhost:9292/pacts/provider/Bar/consumer/Foo/latest
53+
- run: "bundle exec rake pact:verify:foobar"
54+
name: Pact provider verification (broker via consumer version selectors)
55+
working-directory: ${{ matrix.project }}/provider
56+
env:
57+
PACT_BROKER_URL: http://localhost:9292
58+
- run: "bundle exec rake pact:verify:foobar"
59+
name: Pact provider verification (broker via PACT_URL) with published results
60+
working-directory: ${{ matrix.project }}/provider
61+
env:
62+
PACT_URL: http://localhost:9292/pacts/provider/Bar/consumer/Foo/latest
63+
PACT_PUBLISH_VERIFICATION_RESULTS: true
64+
- run: "bundle exec rake pact:verify:foobar"
65+
name: Pact provider verification (broker via consumer version selectors) with published results
66+
working-directory: ${{ matrix.project }}/provider
67+
env:
68+
PACT_BROKER_URL: http://localhost:9292
69+
PACT_PUBLISH_VERIFICATION_RESULTS: true
70+
- run: kill -9 $(cat broker.pid)
71+
shell: bash
72+
name: Stop Pact Broker
73+
working-directory: pact_broker
74+
if: runner.os != 'Windows'
75+
76+
- run: |
77+
for /f %%i in (broker.pid) do taskkill /PID %%i /F
78+
shell: cmd
79+
name: Stop Pact Broker (Windows)
80+
working-directory: pact_broker
81+
if: runner.os == 'Windows'
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: Test e2e/e2e-v1
22

33
on:
44
push:
@@ -18,12 +18,22 @@ jobs:
1818
runs-on: ${{ matrix.os }}
1919
steps:
2020
- uses: actions/checkout@v4
21+
2122
- uses: ruby/setup-ruby@v1
2223
with:
2324
ruby-version: ${{ matrix.ruby_version }}
25+
# e2e - v1
2426
- run: "bundle install"
25-
- run: "bundle exec rake spec"
27+
working-directory: e2e-pact-ruby-v1
28+
- run: "bundle exec rake pact:spec"
29+
working-directory: e2e-pact-ruby-v1
2630
- run: "bundle exec rake pact:verify:foobar"
31+
working-directory: e2e-pact-ruby-v1
2732
if: matrix.os != 'windows-latest'
28-
- run: "ruby.exe -S pact verify --pact-helper ./provider/spec/pact_helper.rb --pact-uri ./consumer/spec/pacts/foo-bar.json"
29-
if: matrix.os == 'windows-latest'
33+
# e2e - v2
34+
- run: "bundle install"
35+
working-directory: e2e
36+
- run: "bundle exec rake pact:spec"
37+
working-directory: e2e
38+
- run: "bundle exec rake pact:verify:foobar"
39+
working-directory: e2e
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Test transport type: http/kafka/grpc/mixed"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
ruby: ["3.2", "3.3", "3.4"]
18+
os: [ windows-latest, macos-13, macos-14, ubuntu-latest ]
19+
env:
20+
RUBY_VERSION: ${{ matrix.ruby }}
21+
name: Ruby ${{ matrix.ruby }}-${{ matrix.os }}-${{ matrix.type }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
- name: Setup Ruby
26+
if: env.ACT == 'true' && runner.arch == 'ARM64'
27+
run: sudo apt-get update && apt-get install -y ruby-full ruby-bundler
28+
- name: Setup Ruby w/ same version as image
29+
uses: ruby/setup-ruby@v1
30+
with:
31+
ruby-version: ${{ matrix.ruby }}
32+
# http
33+
- name: Install dependencies
34+
run: make install
35+
working-directory: http
36+
- name: Run tests
37+
run: make
38+
working-directory: http
39+
# kafka
40+
- name: Install dependencies
41+
if: runner.os != 'Windows'
42+
run: make install
43+
working-directory: kafka
44+
- name: Run tests
45+
if: runner.os != 'Windows'
46+
run: make
47+
working-directory: kafka
48+
# grpc
49+
- name: Install dependencies
50+
run: make install
51+
working-directory: grpc
52+
- name: Run tests
53+
run: make
54+
working-directory: grpc
55+
# message
56+
- name: Install dependencies
57+
run: make install
58+
working-directory: message
59+
- name: Run tests
60+
run: make
61+
working-directory: message
62+
# mixed
63+
- name: Install dependencies
64+
if: runner.os != 'Windows'
65+
run: make install
66+
working-directory: mixed
67+
- name: Run tests
68+
if: runner.os != 'Windows'
69+
run: make
70+
working-directory: mixed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
spec/pacts
2+
logs
3+
log
4+
5+
## e2e project
16
pact_broker/log
27
Gemfile.lock
38
*.sqlite3
49
/log
5-
/provider/reports
10+
/provider/reports
11+
12+
# !pact_broker/Gemfile.lock

LICENSE

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
Copyright (c) 2025 pact-foundation
2+
13
MIT License
24

3-
Copyright (c) 2017 Pact Foundation
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
412

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
1115

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1423

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.

README.md

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,16 @@
1-
# Pact Ruby End to End Example
1+
# Pact Ruby End to End Examples
22

33
[![Test](https://github.com/pact-foundation/pact-ruby-e2e-example/actions/workflows/test.yml/badge.svg)](https://github.com/pact-foundation/pact-ruby-e2e-example/actions/workflows/test.yml)
44

55
Code base to use for demonstrating features or recreating issues in the ruby implementation of pact. Please fork it and modify to demonstrate or recreate your own code.
66

7-
This code base is _not_ intended as an example of a best practice pact implementation. Its purpose is to create a running example with the simplest code possible. If you want to see an example of how you would use pact in a Ruby consumer or provider project, see the [example] dir in the pact repository.
7+
## Projects
88

9-
## Usage
10-
11-
### Fork and clone the codebase
12-
13-
# Fork the repository using the 'Fork' button on the repository home page, then:
14-
git clone git@github.com:YOUR_USERNAME/pact-ruby-e2e-example.git
15-
cd pact-ruby-e2e-example
16-
17-
### Set the gem versions you are using
18-
19-
* Open up the `Gemfile` and set the exact gem versions you are using. eg `gem "pact", "1.12.1"`
20-
21-
* Run `bundle update`
22-
23-
### Set up consumer and provider
24-
25-
* Modify the code in `consumer/spec/bar_spec.rb` to recreate your consumer expectations and actual requests.
26-
* Modify the code in `provider/bar_app.rb` to recreate the response that your provider will return.
27-
* Run `bundle exec rake` to run the consumer specs, generate the pact file, and verify the pact file.
28-
* You will find the pact file in `consumer/spec/pacts/foo-bar.json`
29-
* To run just the consumer specs and generate the pact: `bundle exec rake spec`
30-
* To run just the provider verification: `bundle exec rake pact:verify:foobar`
31-
32-
### To recreate issues with a local pact broker
33-
34-
* Set the exact gem versions in `pact_broker/Gemfile` and run `bundle update`.
35-
36-
* In another terminal, cd into the `pact_broker` directory and run `bundle exec rackup`.
37-
38-
* Follow the above instructions for setting up the consumer and provider code.
39-
40-
* In the root directory of this project, run `bundle exec rake pact:verify:foobar_using_local_broker`
41-
42-
### To recreate issues with a remote pact broker
43-
44-
* In the `Rakefile` set the `REMOTE_PACT_BROKER_BASE_URL` to the value of your pact broker.
45-
46-
* Follow the above instructions for setting up the consumer and provider code.
47-
48-
* Set the `PACT_BROKER_USERNAME` and `PACT_BROKER_PASSWORD` environment variables if you are using a broker with basic auth.
49-
50-
export PACT_BROKER_USERNAME=your_username
51-
export PACT_BROKER_PASSWORD=your_password
52-
53-
* In the root directory of this project, run `bundle exec rake pact:verify:foobar_using_remote_broker`
54-
55-
## Reporting an issue
56-
57-
* Commit your code on a branch (so you can reuse it for other issues cleanly) and push it to your fork
58-
59-
git checkout -b "foo-issue"
60-
git add .
61-
git commit -m "Modifying code to recreate my issue"
62-
git push --set-upstream origin foo-issue
63-
64-
* Open an issue in the appropriate codebase (see [pact-foundation][pact-foundation] for most of the repositories) and include a link to your branch.
65-
66-
[pact-foundation]: https://github.com/pact-foundation
67-
[example]: https://github.com/pact-foundation/pact-ruby/tree/master/example
9+
- [e2e http + broker - pact-ruby v1](./e2e-pact-ruby-v1/)
10+
- [e2e http + broker - pact-ruby v2](./e2e/)
11+
- [http - pact-ruby v2](./http/)
12+
- [grpc - pact-ruby v2](./grpc/)
13+
- [kafka - pact-ruby v2](./kafka/)
14+
- [message - pact-ruby v2](./message/)
15+
- [mixed (http, grpc & kafka) - pact-ruby v2](./mixed/)
16+
- [sample pact broker](./pact_broker/)

e2e-pact-ruby-v1/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spec/internal/pacts
2+
logs
3+
log
4+
5+
## e2e project
6+
pact_broker/log
7+
Gemfile.lock
8+
*.sqlite3
9+
/log
10+
/provider/reports
File renamed without changes.

e2e-pact-ruby-v1/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Pact Foundation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)