Skip to content

Commit 37dabf0

Browse files
Merge pull request #229 from dmitraver/automate-prism-service-159
Automate prism service.
2 parents 66d264b + ff37ee0 commit 37dabf0

File tree

5 files changed

+576
-1848
lines changed

5 files changed

+576
-1848
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ matrix:
1010
jdk: oraclejdk7
1111
- os: linux
1212
jdk: oraclejdk8
13+
before_script:
14+
- "./scripts/startPrism.sh &"
15+
- sleep 10
16+
before_install:
17+
- cat /etc/hosts # optionally check the content *before*
18+
- sudo hostname "$(hostname | cut -c1-63)"
19+
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
20+
- cat /etc/hosts # optionally check the content *after*
1321
after_script:
22+
- lsof -i :4010 -S # adds some debugging statements
1423
- "./gradlew build"
1524
- "./scripts/upload.sh"
1625
env:

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ task renameSendGridVersionJarToSendGridJar {
9494
}
9595
}
9696

97+
task startPrism(type: Exec) {
98+
workingDir 'scripts'
99+
commandLine './startPrism.sh'
100+
}
101+
97102
task javadocJar(type: Jar, dependsOn: javadoc) {
98103
classifier = 'javadoc'
99104
from 'build/docs/javadoc'

scripts/startPrism.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
install () {
6+
7+
echo "Installing Prism..."
8+
9+
UNAME=$(uname)
10+
ARCH=$(uname -m)
11+
if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
12+
echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases"
13+
exit 1
14+
fi
15+
16+
if [ "$UNAME" = "Darwin" ] ; then
17+
OSX_ARCH=$(uname -m)
18+
if [ "${OSX_ARCH}" = "x86_64" ] ; then
19+
PLATFORM="darwin_amd64"
20+
fi
21+
elif [ "$UNAME" = "Linux" ] ; then
22+
LINUX_ARCH=$(uname -m)
23+
if [ "${LINUX_ARCH}" = "i686" ] ; then
24+
PLATFORM="linux_386"
25+
elif [ "${LINUX_ARCH}" = "x86_64" ] ; then
26+
PLATFORM="linux_amd64"
27+
fi
28+
fi
29+
30+
mkdir -p ../prism/bin
31+
#LATEST=$(curl -s https://api.github.com/repos/stoplightio/prism/tags | grep -Eo '"name":.*?[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2)
32+
LATEST="v0.6.21"
33+
URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM"
34+
DEST=../prism/bin/prism
35+
36+
if [ -z $LATEST ] ; then
37+
echo "Error requesting. Download binary from ${URL}"
38+
exit 1
39+
else
40+
curl -L $URL -o $DEST
41+
chmod +x $DEST
42+
fi
43+
}
44+
45+
run () {
46+
echo "Running prism..."
47+
cd ../prism/bin
48+
./prism run --mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
49+
}
50+
51+
if [ -f ../prism/bin/prism ]; then
52+
echo "Prism is already installed."
53+
run
54+
else
55+
echo "Prism is not installed."
56+
install
57+
run
58+
fi

0 commit comments

Comments
 (0)