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

feat: add prism Docker setup #626

Merged
merged 2 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ examples/Example.java
.vscode
sendgrid-java.jar
dependency-reduced-pom.xml
prism*
30 changes: 7 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
language: java
before_install:
- echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import --batch || true
matrix:
include:
- jdk: openjdk7
dist: trusty
- jdk: openjdk8
dist: xenial
- jdk: openjdk11
dist: xenial
- jdk: oraclejdk7
dist: precise
- jdk: oraclejdk8
dist: trusty
- jdk: oraclejdk11
dist: trusty
allow_failures:
- jdk: openjdk7
- jdk: oraclejdk7
before_script:
- "./scripts/startPrism.sh &"
- sleep 20
install:
- mvn --settings .maven.xml install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
env:
- version=8
- version=11
script:
- make test-docker

deploy:
- provider: script
script: mvn clean deploy --settings .maven.xml -DskipTests=true -B -U -Prelease
edge: true
on:
tags: true
jdk: openjdk8
condition: $version = 8
branch: master

notifications:
Expand Down
20 changes: 2 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,9 @@ All test files are in the [`tests`](https://github.com/sendgrid/sendgrid-java/tr

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.

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.)
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`.

1. Add execute permissions

```bash
chmod +x prism
```

1. In a separate terminal, cd into the directory you chose for prism and start the sendgrid local server which the tests will use.

```bash
./prism run --mock --list --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
```

1. Now you can run the test suite from the root of the project

```bash
./gradlew test -i
```
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`.

<a name="style-guidelines-and-naming-conventions"></a>
## Style Guidelines & Naming Conventions
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG version=latest
FROM openjdk:$version

# version <= 11
RUN apt-get update \
&& apt-get install -y make maven || true
COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
RUN update-ca-certificates || true

# version > 11
RUN yum update -y \
&& yum install -y make wget || true
RUN wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo \
&& yum install -y maven || true
RUN keytool -import -trustcacerts -cacerts -storepass changeit -noprompt \
-alias api.sendgrid.com -file /usr/local/share/ca-certificates/cert.crt || true

WORKDIR /app
COPY . .

RUN make install
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
.PHONY: install test test-integration clean
.PHONY: install test test-integ test-docker clean

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

test:
mvn test

test-integration:
./scripts/startPrism.sh &
sleep 5
test-integ: test

version ?= latest
test-docker:
curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh -o prism.sh
version=$(version) bash ./prism.sh

clean:
mvn clean
24 changes: 0 additions & 24 deletions docker/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions docker/README.md

This file was deleted.

32 changes: 0 additions & 32 deletions docker/USAGE.md

This file was deleted.

31 changes: 0 additions & 31 deletions docker/entrypoint.sh

This file was deleted.

58 changes: 0 additions & 58 deletions scripts/startPrism.sh

This file was deleted.

Loading