2017-04-26 16:49:03 +00:00
|
|
|
# Java-related client, server tests
|
2016-12-12 09:42:08 +00:00
|
|
|
machine:
|
|
|
|
java:
|
2017-04-23 07:59:16 +00:00
|
|
|
version: openjdk8
|
2016-12-12 09:42:08 +00:00
|
|
|
services:
|
|
|
|
- docker
|
|
|
|
# Override /etc/hosts
|
|
|
|
hosts:
|
|
|
|
petstore.swagger.io: 127.0.0.1
|
2017-06-07 10:01:36 +00:00
|
|
|
environment:
|
|
|
|
DOCKER_GENERATOR_IMAGE_NAME: swaggerapi/swagger-generator
|
|
|
|
DOCKER_CODEGEN_CLI_IMAGE_NAME: swaggerapi/swagger-codegen-cli
|
2016-12-12 09:42:08 +00:00
|
|
|
|
|
|
|
dependencies:
|
|
|
|
cache_directories:
|
2017-04-26 16:49:03 +00:00
|
|
|
- "~/.m2"
|
|
|
|
- "~/.sbt"
|
|
|
|
|
2016-12-12 09:42:08 +00:00
|
|
|
pre:
|
2017-06-05 07:43:20 +00:00
|
|
|
- sudo add-apt-repository ppa:duggan/bats --yes
|
|
|
|
- sudo apt-get update -qq
|
|
|
|
- sudo apt-get install -qq bats
|
|
|
|
- sudo apt-get install -qq curl
|
2016-12-12 09:42:08 +00:00
|
|
|
# to run petstore server locally via docker
|
|
|
|
- docker pull swaggerapi/petstore
|
|
|
|
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
|
|
|
- docker ps -a
|
|
|
|
# show host table to confirm petstore.swagger.io is mapped to localhost
|
|
|
|
- cat /etc/hosts
|
|
|
|
override:
|
2017-04-23 07:59:16 +00:00
|
|
|
- cp pom.xml.circleci pom.xml
|
2016-12-12 09:42:08 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
override:
|
2017-07-03 09:40:00 +00:00
|
|
|
## test with jdk8
|
2017-04-23 07:59:16 +00:00
|
|
|
- java -version
|
2017-12-22 03:59:40 +00:00
|
|
|
- mvn clean install
|
|
|
|
- mvn -q verify -Psamples
|
2017-07-03 09:40:00 +00:00
|
|
|
# skip the rest if previous mvn task fails
|
|
|
|
- if [ $? -ne 0 ]; then exit 1; fi
|
|
|
|
## test with jdk7
|
2017-04-23 07:59:16 +00:00
|
|
|
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
|
|
|
- java -version
|
2017-12-22 03:59:40 +00:00
|
|
|
- mvn clean install
|
|
|
|
- mvn -q verify -Psamples
|
2017-07-03 09:40:00 +00:00
|
|
|
# skip the rest if previous mvn task fails
|
|
|
|
- if [ $? -ne 0 ]; then exit 1; fi
|
|
|
|
## docker: build generator image and push to Docker Hub
|
2017-06-07 15:09:08 +00:00
|
|
|
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
|
2017-07-03 09:40:00 +00:00
|
|
|
## docker: build cli image and push to Docker Hub
|
2017-06-07 15:09:08 +00:00
|
|
|
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
|