From 1088609cf9ae98ee78e8913ccd4c361b93dbb3d0 Mon Sep 17 00:00:00 2001 From: Khalid Dermoumi Date: Fri, 25 Aug 2017 21:05:26 +0200 Subject: [PATCH 1/5] Minor fixes and comments in README I installed the pact_broker (thanks for that) on a local Windows system, and fixed a few minor issues in the README. I also added a hint on how Windows users get Rails/Ruby. Since Windows users aren't generally very familiar with Ruby, I believe this makes sense. You may like these edits or not, they are not spectacular, but I did not want to keep the findings for myself. Thanks for your work with pact! --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c3754d28..464002e49 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,10 @@ Use the HAL browser to view documentation as you browse. ### To have a play around on your local machine * Install ruby 2.2.0 or later and bundler >= 1.12.0 -* Run `git clone git@github.com:pact-foundation/pact_broker.git && cd pact_broker/example` -* Run `bundle` + * Windows users: get a Rails/Ruby installer from [RailsInstaller](http://railsinstaller.org/) and run it + * unix users just use their package manager +* Run `git clone https://github.com:pact-foundation/pact_broker.git && cd pact_broker/example` +* Run `bundle install` * Run `bundle exec rackup -p 8080` * Open [http://localhost:8080](http://localhost:8080) and you should see a list containing the pact between the Zoo App and the Animal Service. * Click on the arrow to see the generated HTML documentation. From c4a456685aa2be1ba7afb4559422c4d0343e567a Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Sun, 27 Aug 2017 10:48:52 +1000 Subject: [PATCH 2/5] docs(README): revert repo address to use git protocol --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 464002e49..9d7f9f8f9 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ Use the HAL browser to view documentation as you browse. * Install ruby 2.2.0 or later and bundler >= 1.12.0 * Windows users: get a Rails/Ruby installer from [RailsInstaller](http://railsinstaller.org/) and run it - * unix users just use their package manager -* Run `git clone https://github.com:pact-foundation/pact_broker.git && cd pact_broker/example` + * unix users just use your package manager +* Run `git clone git@github.com:pact-foundation/pact_broker.git && cd pact_broker/example` * Run `bundle install` * Run `bundle exec rackup -p 8080` * Open [http://localhost:8080](http://localhost:8080) and you should see a list containing the pact between the Zoo App and the Animal Service. From e4b7ad3eead101a4c0db0cf85dd2ba1c7fcf1861 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 6 Sep 2017 17:48:30 +1000 Subject: [PATCH 3/5] chore: add server with random failures for testing webhook executions --- script/webhook-server.ru | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 script/webhook-server.ru diff --git a/script/webhook-server.ru b/script/webhook-server.ru new file mode 100644 index 000000000..7664a678c --- /dev/null +++ b/script/webhook-server.ru @@ -0,0 +1,6 @@ +count = 0 +run -> (env) { + count += 1 + status = (count % 3 == 0) ? 200 : 500 + puts "Received request"; [status, {}, ["Hello. This might be an error.\n"]] +} From f8123bfc9774ac4767095b60ebb627b4909fc042 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 6 Sep 2017 17:49:38 +1000 Subject: [PATCH 4/5] chore: correct method of accessing command line argument --- script/seed.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/seed.rb b/script/seed.rb index 5cfb12349..3c6b3d31d 100755 --- a/script/seed.rb +++ b/script/seed.rb @@ -1,13 +1,13 @@ #!/usr/bin/env ruby -raise "Please supply database path" unless $1 +raise "Please supply database path" unless ARGV[0] $LOAD_PATH.unshift './lib' $LOAD_PATH.unshift './spec' ENV['RACK_ENV'] = 'development' require 'sequel' require 'logger' -DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "sqlite", database: $1, :encoding => 'utf8'} +DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "sqlite", database: ARGV[0], :encoding => 'utf8'} connection = Sequel.connect(DATABASE_CREDENTIALS) connection.timezone = :utc require 'pact_broker' From 5fb16b6802da3f7fede486f0240d849bfb46c563 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 6 Sep 2017 17:50:34 +1000 Subject: [PATCH 5/5] chore(script): correct regexp for extracting version from pact URL --- script/publish-new.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/script/publish-new.sh b/script/publish-new.sh index 10c4c6b9b..7ec5cfdde 100755 --- a/script/publish-new.sh +++ b/script/publish-new.sh @@ -1,10 +1,9 @@ -# set -x +set -e BODY=$(ruby -e "require 'json'; j = JSON.parse(File.read('script/foo-bar.json')); j['interactions'][0]['providerState'] = 'it is ' + Time.now.to_s; puts j.to_json") latest_url=$(curl http://localhost:9292/pacts/provider/Bar/consumer/Foo/latest | jq -r ._links.self.href) -next_version=$(echo ${latest_url} | ruby -e "require 'semver'; puts SemVer.parse(ARGF.read[/\d+\.\d\.\d+/]).tap{ | v| v.minor = v.minor + 1}.format('%M.%m.%p')") -echo ${BODY} >> tmp.json -curl -v -XPUT \-H "Content-Type: application/json" \ --d@tmp.json \ -http://127.0.0.1:9292/pacts/provider/Bar/consumer/Foo/version/${next_version} +next_version=$(echo ${latest_url} | ruby -e "version = ARGF.read[/\d+\.\d+\.\d+/]; require 'semver'; puts SemVer.parse(version).tap{ | v| v.minor = v.minor + 1}.format('%M.%m.%p')") +echo ${BODY} > tmp.json +curl -v -XPUT \-H "Content-Type: application/json" -d@tmp.json \ + http://localhost:9292/pacts/provider/Bar/consumer/Foo/version/${next_version} rm tmp.json echo ""