Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate prism service. #229

Merged
merged 17 commits into from
Oct 22, 2017
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ matrix:
jdk: oraclejdk7
- os: linux
jdk: oraclejdk8
before_script:
- echo TRAVIS $TRAVIS
- echo MOCK_HOST $MOCK_HOST
- "./scripts/startPrism.sh &"
- sleep 10
before_install:
- cat /etc/hosts # optionally check the content *before*
- sudo hostname "$(hostname | cut -c1-63)"
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
- cat /etc/hosts # optionally check the content *after*
after_script:
- lsof -i :4010 -S # adds some debugging statements
- "./gradlew build"
- "./scripts/upload.sh"
env:
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ task renameSendGridVersionJarToSendGridJar {
}
}

task startPrism(type: Exec) {
workingDir 'scripts'
commandLine './startPrism.sh'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
Expand Down
58 changes: 58 additions & 0 deletions scripts/startPrism.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

set -eu

install () {

echo "Installing Prism..."

UNAME=$(uname)
ARCH=$(uname -m)
if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases"
exit 1
fi

if [ "$UNAME" = "Darwin" ] ; then
OSX_ARCH=$(uname -m)
if [ "${OSX_ARCH}" = "x86_64" ] ; then
PLATFORM="darwin_amd64"
fi
elif [ "$UNAME" = "Linux" ] ; then
LINUX_ARCH=$(uname -m)
if [ "${LINUX_ARCH}" = "i686" ] ; then
PLATFORM="linux_386"
elif [ "${LINUX_ARCH}" = "x86_64" ] ; then
PLATFORM="linux_amd64"
fi
fi

mkdir -p ../prism/bin
#LATEST=$(curl -s https://api.github.com/repos/stoplightio/prism/tags | grep -Eo '"name":.*?[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2)
LATEST="v0.6.21"
URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM"
DEST=../prism/bin/prism

if [ -z $LATEST ] ; then
echo "Error requesting. Download binary from ${URL}"
exit 1
else
curl -L $URL -o $DEST
chmod +x $DEST
fi
}

run () {
echo "Running prism..."
cd ../prism/bin
./prism run --mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
}

if [ -f ../prism/bin/prism ]; then
echo "Prism is already installed."
run
else
echo "Prism is not installed."
install
run
fi
Loading