Skip to content

Commit 217e6ed

Browse files
author
childish-sambino
authored
feat: add prism Docker setup (#626)
1 parent b50129f commit 217e6ed

File tree

12 files changed

+272
-742
lines changed

12 files changed

+272
-742
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ examples/Example.java
1717
.vscode
1818
sendgrid-java.jar
1919
dependency-reduced-pom.xml
20+
prism*

.travis.yml

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
11
language: java
22
before_install:
33
- echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import --batch || true
4-
matrix:
5-
include:
6-
- jdk: openjdk7
7-
dist: trusty
8-
- jdk: openjdk8
9-
dist: xenial
10-
- jdk: openjdk11
11-
dist: xenial
12-
- jdk: oraclejdk7
13-
dist: precise
14-
- jdk: oraclejdk8
15-
dist: trusty
16-
- jdk: oraclejdk11
17-
dist: trusty
18-
allow_failures:
19-
- jdk: openjdk7
20-
- jdk: oraclejdk7
21-
before_script:
22-
- "./scripts/startPrism.sh &"
23-
- sleep 20
24-
install:
25-
- mvn --settings .maven.xml install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
4+
env:
5+
- version=8
6+
- version=11
7+
script:
8+
- make test-docker
9+
2610
deploy:
2711
- provider: script
2812
script: mvn clean deploy --settings .maven.xml -DskipTests=true -B -U -Prelease
2913
edge: true
3014
on:
3115
tags: true
32-
jdk: openjdk8
16+
condition: $version = 8
3317
branch: master
3418

3519
notifications:

CONTRIBUTING.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,9 @@ All test files are in the [`tests`](https://github.com/sendgrid/sendgrid-java/tr
128128

129129
For the purposes of contributing to this repo, please update the [`SendGridTest.java`](https://github.com/sendgrid/sendgrid-java/tree/master/src/test/java/com/sendgrid/SendGridTest.java) file with unit tests as you modify the code.
130130

131-
1. Download [prism](http://stoplight.io/platform/prism/) for your platform ([Mac OS X](https://github.com/stoplightio/prism/releases/download/v0.6.21/prism_darwin_amd64), [Linux](https://github.com/stoplightio/prism/releases/download/v0.6.21/prism_linux_amd64), [Windows](https://github.com/stoplightio/prism/releases/download/v0.6.21/prism_windows_amd64.exe)) and save the binary to the sendgrid-java directory (or any directory you would like. The sendgrid-java directory is chosen mostly for convenience.)
131+
The integration tests require a Twilio SendGrid mock API in order to execute. We've simplified setting this up using Docker to run the tests. You will just need [Docker Desktop](https://docs.docker.com/get-docker/) and `make`.
132132

133-
1. Add execute permissions
134-
135-
```bash
136-
chmod +x prism
137-
```
138-
139-
1. In a separate terminal, cd into the directory you chose for prism and start the sendgrid local server which the tests will use.
140-
141-
```bash
142-
./prism run --mock --list --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
143-
```
144-
145-
1. Now you can run the test suite from the root of the project
146-
147-
```bash
148-
./gradlew test -i
149-
```
133+
Once these are available, simply execute the Docker test target to run all tests: `make test-docker`. This command can also be used to open an interactive shell into the container where this library is installed. To start a *bash* shell for example, use this command: `command=bash make test-docker`.
150134

151135
<a name="style-guidelines-and-naming-conventions"></a>
152136
## Style Guidelines & Naming Conventions

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG version=latest
2+
FROM openjdk:$version
3+
4+
# version <= 11
5+
RUN apt-get update \
6+
&& apt-get install -y make maven || true
7+
COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
8+
RUN update-ca-certificates || true
9+
10+
# version > 11
11+
RUN yum update -y \
12+
&& yum install -y make wget || true
13+
RUN wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo \
14+
&& yum install -y maven || true
15+
RUN keytool -import -trustcacerts -cacerts -storepass changeit -noprompt \
16+
-alias api.sendgrid.com -file /usr/local/share/ca-certificates/cert.crt || true
17+
18+
WORKDIR /app
19+
COPY . .
20+
21+
RUN make install

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
.PHONY: install test test-integration clean
1+
.PHONY: install test test-integ test-docker clean
22

33
VERSION := $(shell mvn help:evaluate -Dexpression=project.version --batch-mode | grep -e '^[^\[]')
44
install:
55
@java -version || (echo "Java is not installed, please install Java >= 7"; exit 1);
6-
mvn clean install -DskipTests=true -Dgpg.skip -B
6+
mvn clean install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B
77
cp target/sendgrid-java-$(VERSION)-shaded.jar sendgrid-java.jar
88

99
test:
1010
mvn test
1111

12-
test-integration:
13-
./scripts/startPrism.sh &
14-
sleep 5
12+
test-integ: test
13+
14+
version ?= latest
15+
test-docker:
16+
curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh -o prism.sh
17+
version=$(version) bash ./prism.sh
1518

1619
clean:
1720
mvn clean

docker/Dockerfile

-24
This file was deleted.

docker/README.md

-31
This file was deleted.

docker/USAGE.md

-32
This file was deleted.

docker/entrypoint.sh

-31
This file was deleted.

scripts/startPrism.sh

-58
This file was deleted.

0 commit comments

Comments
 (0)