Skip to content

CircleCI migration from 1.0 to 2.0 #333

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

Merged
merged 26 commits into from
Jun 17, 2018
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b980215
migration to circleci 2.0 config
wing328 Jun 12, 2018
ae5f08b
install docker compose
wing328 Jun 12, 2018
b2e5fdd
add setup remote docker
wing328 Jun 12, 2018
131c790
comment out docker compose
wing328 Jun 12, 2018
02a1891
using public petstore for testing
wing328 Jun 12, 2018
c8f145f
use only one working_directory
wing328 Jun 13, 2018
c1cc5ae
use openapitools/openapi-petstore instead
wing328 Jun 13, 2018
83780d9
disable auth in petstore server
wing328 Jun 13, 2018
480fa82
run petstore server locally via mvn jetty
wing328 Jun 13, 2018
05b3909
fix typo
wing328 Jun 13, 2018
bed2562
test go first
wing328 Jun 13, 2018
6d56cae
test pet server at port 8080
wing328 Jun 13, 2018
61f841f
remove docker compose command
wing328 Jun 13, 2018
f671436
wait for server to start up
wing328 Jun 13, 2018
fb8a142
sleep longer
wing328 Jun 13, 2018
8bfe17a
test mvn jetty again
wing328 Jun 13, 2018
7cdfee7
use machine executor
wing328 Jun 17, 2018
b03f73e
Merge branch 'circleci_migration' of https://github.com/openapitools/…
wing328 Jun 17, 2018
984cd88
comment out docker
wing328 Jun 17, 2018
585f9bd
comment out restore cache
wing328 Jun 17, 2018
775ff7a
sleep for 30s
wing328 Jun 17, 2018
2809a4b
change petstore port
wing328 Jun 17, 2018
640197d
restore petstore docker
wing328 Jun 17, 2018
614e876
fix docker run command
wing328 Jun 17, 2018
2b7c499
Merge remote-tracking branch 'origin/master' into circleci_migration
wing328 Jun 17, 2018
a1a9fe9
restore cache, clean up comments
wing328 Jun 17, 2018
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
147 changes: 93 additions & 54 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,93 @@
# Java-related client, server tests
machine:
java:
version: openjdk8
services:
- docker
# Override /etc/hosts
hosts:
petstore.swagger.io: 127.0.0.1
environment:
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli

dependencies:
cache_directories:
- "~/.m2"
- "~/.sbt"
- "~/.ivy2"

pre:
- 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
# 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:
- cp CI/pom.xml.circleci pom.xml

test:
override:
## test with jdk8
- java -version
- mvn --quiet clean install
- mvn --quiet verify -Psamples
# skip the rest if previous mvn task fails
- if [ $? -ne 0 ]; then exit 1; fi
## test with jdk7
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
- java -version
- cp CI/pom.xml.circleci.java7 pom.xml # use jdk7 pom
- mvn --quiet clean install
- mvn --quiet verify -Psamples
# skip the rest if previous mvn task fails
- if [ $? -ne 0 ]; then exit 1; fi
## docker push done in Travis instead
## docker: build generator image and push to Docker Hub
#- 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
### docker: build cli image and push to Docker Hub
#- 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
version: 2
jobs:
build:
machine:
docker_layer_caching: true
working_directory: ~/OpenAPITools/openapi-generator
parallelism: 1
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
steps:
# Machine Setup
# 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
# 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.
- checkout
# 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.
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
# This is based on your 1.0 configuration file or project settings
- run:
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
- run:
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
- run:
command: |-
printf '127.0.0.1 petstore.swagger.io
' | sudo tee -a /etc/hosts
# Dependencies
# This would typically go in either a build or a build-and-test job when using workflows
# Restore the dependency cache
- restore_cache:
keys:
# This branch if available
- v1-dep-{{ .Branch }}-
# Default branch if not
- v1-dep-master-
# This is based on your 1.0 configuration file or project settings
- run: sudo add-apt-repository ppa:duggan/bats --yes
- run: sudo apt-get update -qq
- run: sudo apt-get install -qq bats
- run: sudo apt-get install -qq curl
# - run: docker pull openapitools/openapi-petstore
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
- run: docker pull swaggerapi/petstore
- run: docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
- run: docker ps -a
- run: sleep 30
- run: cat /etc/hosts
# This is based on your 1.0 configuration file or project settings
- run: cp CI/pom.xml.circleci pom.xml
# 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