forked from loafle/openapi-generator-original
CircleCI migration from 1.0 to 2.0 (#333)
* migration to circleci 2.0 config * install docker compose * add setup remote docker * comment out docker compose * using public petstore for testing * use only one working_directory * use openapitools/openapi-petstore instead * disable auth in petstore server * run petstore server locally via mvn jetty * fix typo * test go first * test pet server at port 8080 * remove docker compose command * wait for server to start up * sleep longer * test mvn jetty again * use machine executor * comment out docker * comment out restore cache * sleep for 30s * change petstore port * restore petstore docker * fix docker run command * restore cache, clean up comments
This commit is contained in:
parent
c607ea8b31
commit
7c49bdd953
141
circle.yml
141
circle.yml
@ -1,54 +1,93 @@
|
|||||||
# Java-related client, server tests
|
version: 2
|
||||||
machine:
|
jobs:
|
||||||
java:
|
build:
|
||||||
version: openjdk8
|
machine:
|
||||||
services:
|
docker_layer_caching: true
|
||||||
- docker
|
working_directory: ~/OpenAPITools/openapi-generator
|
||||||
# Override /etc/hosts
|
parallelism: 1
|
||||||
hosts:
|
shell: /bin/bash --login
|
||||||
petstore.swagger.io: 127.0.0.1
|
|
||||||
environment:
|
environment:
|
||||||
|
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
||||||
|
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
|
||||||
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
|
||||||
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
|
||||||
|
steps:
|
||||||
dependencies:
|
# Machine Setup
|
||||||
cache_directories:
|
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||||
- "~/.m2"
|
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
|
||||||
- "~/.sbt"
|
- checkout
|
||||||
- "~/.ivy2"
|
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
|
||||||
|
# In many cases you can simplify this from what is generated here.
|
||||||
pre:
|
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
|
||||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
|
||||||
- sudo apt-get update -qq
|
# This is based on your 1.0 configuration file or project settings
|
||||||
- sudo apt-get install -qq bats
|
- run:
|
||||||
- sudo apt-get install -qq curl
|
command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV
|
||||||
# to run petstore server locally via docker
|
- run:
|
||||||
- docker pull swaggerapi/petstore
|
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
|
||||||
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
- run:
|
||||||
- docker ps -a
|
command: |-
|
||||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
printf '127.0.0.1 petstore.swagger.io
|
||||||
- cat /etc/hosts
|
' | sudo tee -a /etc/hosts
|
||||||
override:
|
# Dependencies
|
||||||
- cp CI/pom.xml.circleci pom.xml
|
# This would typically go in either a build or a build-and-test job when using workflows
|
||||||
|
# Restore the dependency cache
|
||||||
test:
|
- restore_cache:
|
||||||
override:
|
keys:
|
||||||
## test with jdk8
|
# This branch if available
|
||||||
- java -version
|
- v1-dep-{{ .Branch }}-
|
||||||
- mvn --quiet clean install
|
# Default branch if not
|
||||||
- mvn --quiet verify -Psamples
|
- v1-dep-master-
|
||||||
# skip the rest if previous mvn task fails
|
# This is based on your 1.0 configuration file or project settings
|
||||||
- if [ $? -ne 0 ]; then exit 1; fi
|
- run: sudo add-apt-repository ppa:duggan/bats --yes
|
||||||
## test with jdk7
|
- run: sudo apt-get update -qq
|
||||||
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
- run: sudo apt-get install -qq bats
|
||||||
- java -version
|
- run: sudo apt-get install -qq curl
|
||||||
- cp CI/pom.xml.circleci.java7 pom.xml # use jdk7 pom
|
# - run: docker pull openapitools/openapi-petstore
|
||||||
- mvn --quiet clean install
|
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
|
||||||
- mvn --quiet verify -Psamples
|
- run: docker pull swaggerapi/petstore
|
||||||
# skip the rest if previous mvn task fails
|
- run: docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||||
- if [ $? -ne 0 ]; then exit 1; fi
|
- run: docker ps -a
|
||||||
## docker push done in Travis instead
|
- run: sleep 30
|
||||||
## docker: build generator image and push to Docker Hub
|
- run: cat /etc/hosts
|
||||||
#- 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/opeanapi-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
|
# This is based on your 1.0 configuration file or project settings
|
||||||
### docker: build cli image and push to Docker Hub
|
- run: cp CI/pom.xml.circleci pom.xml
|
||||||
#- 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/openapi-generator-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
|
# Save dependency cache
|
||||||
|
- save_cache:
|
||||||
|
key: v1-dep-{{ .Branch }}
|
||||||
|
paths:
|
||||||
|
# This is a broad list of cache paths to include many possible development environments
|
||||||
|
# You can probably delete some of these entries
|
||||||
|
- vendor/bundle
|
||||||
|
- ~/virtualenvs
|
||||||
|
- ~/.m2
|
||||||
|
- ~/.ivy2
|
||||||
|
- ~/.bundle
|
||||||
|
- ~/.go_workspace
|
||||||
|
- ~/.gradle
|
||||||
|
- ~/.cache/bower
|
||||||
|
# These cache paths were specified in the 1.0 config
|
||||||
|
- ~/.sbt
|
||||||
|
# Test
|
||||||
|
# This would typically be a build job when using workflows, possibly combined with build
|
||||||
|
# This is based on your 1.0 configuration file or project settings
|
||||||
|
- run: java -version
|
||||||
|
- run: mvn --quiet clean install
|
||||||
|
- run: mvn --quiet verify -Psamples
|
||||||
|
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||||
|
- run: java -version
|
||||||
|
- run: cp CI/pom.xml.circleci.java7 pom.xml
|
||||||
|
- run: mvn --quiet clean install
|
||||||
|
- run: mvn --quiet verify -Psamples
|
||||||
|
- run: if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
# Teardown
|
||||||
|
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||||
|
# Save test results
|
||||||
|
- store_test_results:
|
||||||
|
path: /tmp/circleci-test-results
|
||||||
|
# Save artifacts
|
||||||
|
- store_artifacts:
|
||||||
|
path: /tmp/circleci-artifacts
|
||||||
|
- store_artifacts:
|
||||||
|
path: /tmp/circleci-test-results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user