Skip to content

Commit

Permalink
Merge pull request #229 from dmitraver/automate-prism-service-159
Browse files Browse the repository at this point in the history
Automate prism service.
  • Loading branch information
thinkingserious authored Oct 22, 2017
2 parents 66d264b + ff37ee0 commit 37dabf0
Show file tree
Hide file tree
Showing 5 changed files with 576 additions and 1,848 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ matrix:
jdk: oraclejdk7
- os: linux
jdk: oraclejdk8
before_script:
- "./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

0 comments on commit 37dabf0

Please sign in to comment.