Skip to content

Commit ab43c8b

Browse files
Switch to installing the packages from pact-ruby-standalone
1 parent db3e7c3 commit ab43c8b

File tree

6 files changed

+32
-192
lines changed

6 files changed

+32
-192
lines changed

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ help:
55
@echo ""
66
@echo " clean to clear build and distribution directories"
77
@echo " deps to install the required files for development"
8+
@echo " e2e to run the end to end tests"
89
@echo " package to create a distribution package in /dist/"
910
@echo " release to perform a release build, including deps, test, and package targets"
1011
@echo " test to run all tests"
@@ -60,10 +61,6 @@ package:
6061
python setup.py sdist
6162

6263

63-
pact/bin:
64-
scripts/build.sh
65-
66-
6764
.PHONY: test
6865
test: deps pact/bin
6966
flake8

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,10 @@ For more information about provider states, refer to the [Pact documentation] on
267267
# Development
268268
Please read [CONTRIBUTING.md](CONTRIBUTING.md)
269269

270-
This project needs a combination of Python and Ruby, as the Pact mock service and verifier
271-
are currently Ruby based. To setup a development environment:
270+
To setup a development environment:
272271

273-
1. Install Ruby 2.2.2 using a tool like [rvm] or [rbenv]
274-
2. Install the [bundler] package manager for Ruby with `gem install bundler`
275-
3. If you want to run tests for all Python versions, install 2.7, 3.3, 3.4, 3.5, and 3.6 from source or using a tool like [pyenv]
276-
4. Its recommended to create a Python [virtualenv] for the project
272+
1. If you want to run tests for all Python versions, install 2.7, 3.3, 3.4, 3.5, and 3.6 from source or using a tool like [pyenv]
273+
2. Its recommended to create a Python [virtualenv] for the project
277274

278275
The setup the environment, run tests, and package the application, run:
279276
`make release`

RELEASING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
1. Increment the version according to semantic versioning rules in `pact/__init__.py`
44

55
2. To upgrade the the versions of `pact-mock_service` and `pact-provider-verifier`, change the
6-
appropriate `GEM_VESRION` variable in `scripts/build.sh` to the new version.
6+
`PACT_STANDALONE_VERSION` in `setup.py` to match the latest version available from the
7+
[pact-ruby-standalone](https://github.com/pact-foundation/pact-ruby-standalone/releases) repository.
78

89
3. Update the `CHANGELOG.md` using:
910

pact/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def provider_verifier_exe():
2020

2121

2222
MOCK_SERVICE_PATH = normpath(join(
23-
dirname(__file__), 'bin', 'mock-service', 'bin', mock_service_exe()))
23+
dirname(__file__), 'bin', 'pact', 'bin', mock_service_exe()))
2424

2525
VERIFIER_PATH = normpath(join(
26-
dirname(__file__), 'bin', 'verifier', 'bin', provider_verifier_exe()))
26+
dirname(__file__), 'bin', 'pact', 'bin', provider_verifier_exe()))

scripts/build.sh

Lines changed: 0 additions & 111 deletions
This file was deleted.

setup.py

Lines changed: 24 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
import tarfile
77

8-
import shutil
98
from zipfile import ZipFile
109

1110
from setuptools import setup
@@ -16,11 +15,7 @@
1615

1716

1817
IS_64 = sys.maxsize > 2 ** 32
19-
MOCK_SERVICE_URI = (
20-
'https://github.com/bethesque/pact-mock_service/releases/download/v2.1.0/')
21-
VERIFIER_URI = (
22-
'https://github.com/pact-foundation/pact-provider-verifier'
23-
'/releases/download/v1.0.2/')
18+
PACT_STANDALONE_VERSION = '0.0.1'
2419

2520

2621
class PactPythonDevelopCommand(develop):
@@ -37,8 +32,7 @@ def run(self):
3732
if not os.path.exists(bin_path):
3833
os.mkdir(bin_path)
3934

40-
mock_service(bin_path)
41-
verifier(bin_path)
35+
install_ruby_app(bin_path)
4236

4337

4438
class PactPythonInstallCommand(install):
@@ -52,26 +46,40 @@ def run(self):
5246
install.run(self)
5347
bin_path = os.path.join(self.install_lib, 'pact', 'bin')
5448
os.mkdir(bin_path)
55-
mock_service(bin_path)
56-
verifier(bin_path)
49+
install_ruby_app(bin_path)
5750

5851

59-
def install_ruby_app(bin_path, dir_name, platform_tar, repository_uri):
52+
def install_ruby_app(bin_path):
6053
"""
6154
Download a Ruby application and install it for use.
6255
6356
:param bin_path: The path where binaries should be installed.
64-
:param platform_tar: The application tar or zip file to download.
65-
:param dir_name: The directory name for the unpacked files.
66-
:param repository_uri: The GitHub repository URI.
6757
"""
58+
target_platform = platform.platform().lower()
59+
uri = ('https://github.com/pact-foundation/pact-ruby-standalone/releases'
60+
'/download/v{version}/pact-{version}-{suffix}')
61+
62+
if 'darwin' in target_platform:
63+
suffix = 'osx.tar.gz'
64+
elif 'linux' in target_platform and IS_64:
65+
suffix = 'linux-x86_64.tar.gz'
66+
elif 'linux' in target_platform:
67+
suffix = 'linux-x86.tar.gz'
68+
elif 'windows' in target_platform:
69+
suffix = 'win32.zip'
70+
else:
71+
msg = ('Unfortunately, {} is not a supported platform. Only Linux,'
72+
' Windows, and OSX are currently supported.').format(
73+
platform.platform())
74+
raise Exception(msg)
75+
6876
if sys.version_info.major == 2:
6977
from urllib import urlopen
7078
else:
7179
from urllib.request import urlopen
7280

73-
path = os.path.join(bin_path, platform_tar)
74-
resp = urlopen(repository_uri + platform_tar)
81+
path = os.path.join(bin_path, suffix)
82+
resp = urlopen(uri.format(version=PACT_STANDALONE_VERSION, suffix=suffix))
7583
with open(path, 'wb') as f:
7684
f.write(resp.read())
7785

@@ -82,38 +90,6 @@ def install_ruby_app(bin_path, dir_name, platform_tar, repository_uri):
8290
with tarfile.open(path) as f:
8391
f.extractall(bin_path)
8492

85-
platform_name = platform_tar.replace('.tar.gz', '').replace('.zip', '')
86-
shutil.move(os.path.join(bin_path, platform_name),
87-
os.path.join(bin_path, dir_name))
88-
89-
90-
def get_version():
91-
"""Return latest version noted in CHANGES.txt."""
92-
lastline = [line for line in read('CHANGES.txt').split('\n') if line][-1]
93-
version = lastline.split(',')[0]
94-
return version[1:]
95-
96-
97-
def mock_service(bin_path):
98-
"""Install the Ruby mock service for this platform."""
99-
target_platform = platform.platform().lower()
100-
if 'darwin' in target_platform:
101-
platform_tar = 'pact-mock-service-2.1.0-1-osx.tar.gz'
102-
elif 'linux' in target_platform and IS_64:
103-
platform_tar = 'pact-mock-service-2.1.0-1-linux-x86_64.tar.gz'
104-
elif 'linux' in target_platform:
105-
platform_tar = 'pact-mock-service-2.1.0-1-linux-x86.tar.gz'
106-
elif 'windows' in target_platform:
107-
platform_tar = 'pact-mock-service-2.1.0-1-win32.zip'
108-
else:
109-
msg = ('Unfortunately, {} is not a supported platform. Only Linux,'
110-
' Windows, and OSX are currently supported.').format(
111-
platform.platform())
112-
raise Exception(msg)
113-
114-
install_ruby_app(
115-
bin_path, 'mock-service', platform_tar, MOCK_SERVICE_URI)
116-
11793

11894
def read(filename):
11995
"""Read file contents."""
@@ -122,26 +98,6 @@ def read(filename):
12298
return f.read().decode('utf-8')
12399

124100

125-
def verifier(bin_path):
126-
"""Install the Ruby Pact Verifier for this platform."""
127-
target_platform = platform.platform().lower()
128-
if 'darwin' in target_platform:
129-
platform_tar = 'pact-provider-verifier-1.0.2-1-osx.tar.gz'
130-
elif 'linux' in target_platform and IS_64:
131-
platform_tar = 'pact-provider-verifier-1.0.2-1-linux-x86_64.tar.gz'
132-
elif 'linux' in target_platform:
133-
platform_tar = 'pact-provider-verifier-1.0.2-1-linux-x86.tar.gz'
134-
elif 'windows' in target_platform:
135-
platform_tar = 'pact-provider-verifier-1.0.2-1-win32.zip'
136-
else:
137-
msg = ('Unfortunately, {} is not a supported platform. Only Linux,'
138-
' Windows, and OSX are currently supported.').format(
139-
platform.platform())
140-
raise Exception(msg)
141-
142-
install_ruby_app(bin_path, 'verifier', platform_tar, VERIFIER_URI)
143-
144-
145101
dependencies = read('requirements.txt').split()
146102

147103
if sys.version_info.major == 2:

0 commit comments

Comments
 (0)