Skip to content

Commit

Permalink
feat(standalone): use Ruby standalone package
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Aug 14, 2017
1 parent b3c2119 commit cdafe22
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 115 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ package:
bin:
@sh -c "$(CURDIR)/scripts/build.sh"

clean:
@sh -c "$(CURDIR)/scripts/clean.sh"

dev:
@TF_DEV=1 sh -c "$(CURDIR)/scripts/dev.sh"

Expand All @@ -23,4 +26,4 @@ testrace:
updatedeps:
go get -d -v -p 2 ./...

.PHONY: bin default dev test pact updatedeps
.PHONY: bin default dev test pact updatedeps clean
2 changes: 1 addition & 1 deletion daemon/mock_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ func (m *MockService) NewService(args []string) (int, Service) {

func getMockServiceCommandPath() string {
dir, _ := osext.ExecutableFolder()
return fmt.Sprintf(filepath.Join(dir, "pact-mock-service", "bin", "pact-mock-service"))
return fmt.Sprintf(filepath.Join(dir, "pact", "bin", "pact-mock-service"))
}
2 changes: 1 addition & 1 deletion daemon/verification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ func (m *VerificationService) NewService(args []string) (int, Service) {

func getVerifierCommandPath() string {
dir, _ := osext.ExecutableFolder()
return fmt.Sprintf(filepath.Join(dir, "pact-provider-verifier", "bin", "pact-provider-verifier"))
return fmt.Sprintf(filepath.Join(dir, "pact", "bin", "pact-provider-verifier"))
}
63 changes: 43 additions & 20 deletions scripts/build_standalone_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,50 @@ set -e
mkdir -p build
cd build

PACT_STANDALONE_VERSION=1.3.1
urls=(https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v$PACT_STANDALONE_VERSION/pact-$PACT_STANDALONE_VERSION-linux-x86.tar.gz https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v$PACT_STANDALONE_VERSION/pact-$PACT_STANDALONE_VERSION-linux-x86_64.tar.gz https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v$PACT_STANDALONE_VERSION/pact-$PACT_STANDALONE_VERSION-osx.tar.gz https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v$PACT_STANDALONE_VERSION/pact-$PACT_STANDALONE_VERSION-win32.zip)

# Provider Verifier
if [ ! -d "pact-provider-verifier-${PACT_PROVIDER_VERIFIER_VERSION}" ]; then
wget https://github.com/pact-foundation/pact-provider-verifier/archive/v${PACT_PROVIDER_VERIFIER_VERSION}.zip -O temp.zip
unzip temp.zip
rm temp.zip
cd pact-provider-verifier-${PACT_PROVIDER_VERIFIER_VERSION}
bundle
bundle exec rake package
cd ..
echo "--> Downloading Ruby Engine"
if [ ! -f pact-$PACT_STANDALONE_VERSION-linux-x86.tar.gz ]; then
for url in "${urls[@]}"
do
wget $url
done
else
echo "pact provider verifier already generated, run './scripts/clean.sh' to generate a new package"
echo "pact provider verifier already generated, run 'make clean' to generate a new package"
fi

# Mock Service
if [ ! -d "pact-mock_service-${PACT_MOCK_SERVICE_VERSION}" ]; then
wget https://github.com/bethesque/pact-mock_service/archive/v${PACT_MOCK_SERVICE_VERSION}.zip -O temp.zip
unzip temp.zip
rm temp.zip
cd pact-mock_service-${PACT_MOCK_SERVICE_VERSION}
bundle
bundle exec rake package
else
echo "pact mock service already generated, run './scripts/clean.sh' to generate a new package"
fi
osarchs=(osx win32 linux-x86 linux-x86_64)

echo "--> Packaging distributions"
mkdir -p ../dist
for os in "${osarchs[@]}"
do
echo "Building ${os}"
osarch=""
if [ "${os}" = "win32" ]; then
osarch="windows_386"
cp pact-go_$osarch.exe pact-go
zip -u pact-$PACT_STANDALONE_VERSION-$os.zip pact-go
cp pact-$PACT_STANDALONE_VERSION-$os.zip ../dist/pact-go_$osarch.zip
else
if [ "${os}" = "osx" ]; then
osarch="darwin_amd64"
cp pact-go_$osarch pact-go
elif [ "${os}" = "linux-x86" ]; then
osarch="linux_386"
cp pact-go_$osarch pact-go
elif [ "${os}" = "linux-x86_64" ]; then
osarch="linux_amd64"
cp pact-go_$osarch pact-go
fi

gunzip pact-$PACT_STANDALONE_VERSION-$os.tar.gz
tar -rf pact-$PACT_STANDALONE_VERSION-$os.tar pact-go
gzip pact-$PACT_STANDALONE_VERSION-$os.tar
cp pact-$PACT_STANDALONE_VERSION-$os.tar.gz ../dist/pact-go_$osarch.tar.gz
fi
done


84 changes: 0 additions & 84 deletions scripts/compile.sh

This file was deleted.

9 changes: 4 additions & 5 deletions scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
set -e

export PACT_MOCK_SERVICE_VERSION=2.1.0 # Seg faults...
export PACT_PROVIDER_VERIFIER_VERSION=1.2.0-2
export PACT_PROVIDER_VERIFIER_VERSION=1.3.1-1

echo "==> Building App"
make bin

# Create the OS specific versions of the mock service and verifier
echo "==> Building Ruby Binaries..."
scripts/build_standalone_packages.sh

# Build each go package for specific OS, bundling the mock service and verifier
echo "==> Creating OS distributions..."
scripts/compile.sh

echo
echo "==> Results:"
ls -hl dist/
4 changes: 4 additions & 0 deletions scripts/pact.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
$pactDir = "$env:TEMP\pact"
$exitCode = 0

if ($env:PACT_INTEGRATED_TESTS) {
Remove-Item env:\PACT_INTEGRATED_TESTS
}

# Set environment
if (!($env:GOPATH)) {
$env:GOPATH = "c:\go"
Expand Down
4 changes: 1 addition & 3 deletions scripts/pact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function shutdown() {
if [ ! -f "dist/pact-go" ]; then
cd dist
platform=$(detect_os)
archive="${platform}-amd64.tar.gz"
archive="pact-go_${platform}_amd64.tar.gz"
step "Installing Pact Go for ${platform}"

if [ ! -f "${archive}" ]; then
Expand All @@ -39,10 +39,8 @@ if [ ! -f "dist/pact-go" ]; then
log "Expanding archive"
if [[ $platform == 'linux' ]]; then
tar -xf $archive
cp pact-go_linux_amd64 pact-go
elif [[ $platform == 'darwin' ]]; then
tar -xf $archive
cp pact-go_darwin_amd64 pact-go
else
log "Unsupported platform ${platform}"
exit 1
Expand Down

0 comments on commit cdafe22

Please sign in to comment.