mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
* [maven] Fallback to templates using classpath rather than OS-specific paths Previous checks would cause logic in Windows to return early, for built-in templates only. This reorganizes and simplifies the ordering behavior. * Match classpath check in WorkflowSettings with that in TemplateManager * [maven] Much needed unit/integration tests This follows similar approach used in PMD and other plugins managed by maven. Unit tests simply verify we can load configuration as expected into the Mojo. Integration tests execute actual sample projects bound to the current build's Maven plugin. This uses maven-invoker-plugin, which also allows for specifying the maven options in invoker.properties to execute the test. It also provides a verification framework using groovy files with the required naming convention of "verify.groovy". This allows us to quickly and easily check that certain files are outputted by generation, and we may also spotcheck file contents. templateResourcePath option is skipped on windows. I've tested back to version 3.3.3 and this doesn't seem to have worked consistently with how the property works on non-Windows. * Set groovy 3.0.5 for test harness * Print stacktrace on Maven error in Travis * [maven] Set groovy version in tests to supported in Java 11+ * Puts maven integration tests in separate profile called 'integration'
225 lines
12 KiB
YAML
225 lines
12 KiB
YAML
sudo: required
|
|
language: java
|
|
jdk:
|
|
- openjdk8
|
|
|
|
# See https://docs.travis-ci.com/user/languages/java/#caching
|
|
before_cache:
|
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
|
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
|
# Avoid caching our built dependencies between runs.
|
|
- rm -fr $HOME/.m2/repository/org/openapitools/
|
|
|
|
cache:
|
|
yarn: true
|
|
directories:
|
|
- $HOME/.m2
|
|
- $HOME/.ivy2
|
|
- $HOME/.gradle/caches/
|
|
- $HOME/.gradle/wrapper/
|
|
- $HOME/samples/client/petstore/javascript/node_modules
|
|
- $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor
|
|
- $HOME/samples/client/petstore/ruby/vendor/bundle
|
|
- $HOME/samples/client/petstore/python/.venv/
|
|
- $HOME/samples/openapi3/client/petstore/typescript/tests/default/node_modules
|
|
- $HOME/samples/openapi3/client/petstore/typescript/tests/jquery/node_modules
|
|
- $HOME/samples/openapi3/client/petstore/typescript/tests/object_params/node_modules
|
|
- $HOME/samples/openapi3/client/petstore/typescript/tests/inversify/node_modules
|
|
- $HOME/samples/client/petstore/typescript-node/npm/node_modules
|
|
- $HOME/samples/client/petstore/typescript-node/npm/typings/
|
|
- $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules
|
|
- $HOME/samples/client/petstore/typescript-fetch/tests/default/typings
|
|
- $HOME/samples/client/petstore/typescript-fetch/builds/default/node_modules
|
|
- $HOME/samples/client/petstore/typescript-fetch/builds/default/typings
|
|
- $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/node_modules
|
|
- $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/typings
|
|
- $HOME/samples/client/petstore/typescript-fetch/builds/with-npm-version/node_modules
|
|
- $HOME/samples/client/petstore/typescript-fetch/npm/with-npm-version/typings
|
|
- $HOME/samples/client/petstore/typescript-angular/node_modules
|
|
- $HOME/samples/client/petstore/typescript-angular/typings
|
|
- $HOME/samples/server/petstore/rust-server/target
|
|
- $HOME/perl5
|
|
- $HOME/.cargo
|
|
- $HOME/.pub-cache
|
|
- $HOME/samples/server/petstore/cpp-pistache/pistache
|
|
- $HOME/.npm
|
|
- $HOME/.rvm/gems/ruby-2.4.1
|
|
- $HOME/website/node_modules/
|
|
- $HOME/.cache/deno
|
|
|
|
services:
|
|
- docker
|
|
|
|
# comment out the host table change to use the public petstore server
|
|
addons:
|
|
apt:
|
|
sources:
|
|
- ubuntu-toolchain-r-test
|
|
packages:
|
|
- g++-5
|
|
chrome: stable
|
|
hosts:
|
|
- petstore.swagger.io
|
|
|
|
before_install:
|
|
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.22.0
|
|
- export PATH="$HOME/.yarn/bin:$PATH"
|
|
# install rust
|
|
- curl https://sh.rustup.rs -sSf | sh -s -- -y -v
|
|
# required when sudo: required for the Ruby petstore tests
|
|
- gem install bundler
|
|
- npm install -g typescript
|
|
- npm install -g npm
|
|
- npm config set registry http://registry.npmjs.org/
|
|
# set python 3.6.3 as default
|
|
- source ~/virtualenv/python3.6/bin/activate
|
|
# 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
|
|
# -- skip bash test to shorten build time
|
|
# Add bats test framework and cURL for Bash script integration tests
|
|
#- 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
|
|
# -- skip bash test end
|
|
# install dart
|
|
#- sudo apt-get update
|
|
#- sudo apt-get install apt-transport-https
|
|
#- sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
|
|
#- sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
|
|
#- sudo apt-get update
|
|
#- sudo apt-get install dart
|
|
# switch to php7
|
|
- phpenv versions
|
|
- phpenv global 7.2.15
|
|
- php -v
|
|
# comment out below as installation failed in travis
|
|
# Add rebar3 build tool and recent Erlang/OTP for Erlang petstore server tests.
|
|
# - Travis CI does not support rebar3 [yet](https://github.com/travis-ci/travis-ci/issues/6506#issuecomment-275189490).
|
|
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
|
|
# - . ~/otp/18.2.1/activate && erl -version
|
|
#- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
|
|
# install C++ tools
|
|
- sudo apt install -y --no-install-recommends valgrind cmake build-essential
|
|
# install Qt5
|
|
- sudo apt install -y --no-install-recommends qt5-default
|
|
- cmake --version
|
|
# -- skip perl test to shorten build time
|
|
# perl dep
|
|
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
|
#- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Igorned failure from cpanm"
|
|
# -- skip perl test end
|
|
# show host table to confirm petstore.swagger.io is mapped to localhost
|
|
- cat /etc/hosts
|
|
# show java version
|
|
- java -version
|
|
- if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
|
openssl aes-256-cbc -K $encrypted_6e2c8bba47c6_key -iv $encrypted_6e2c8bba47c6_iv -in sec.gpg.enc -out sec.gpg -d ;
|
|
gpg --keyserver keyserver.ubuntu.com --recv-key $SIGNING_KEY ;
|
|
gpg --check-trustdb ;
|
|
fi;
|
|
- pushd .; cd website; yarn install; popd
|
|
# install Deno
|
|
- curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.1.2
|
|
- export PATH="$HOME/.deno/bin:$PATH"
|
|
|
|
install:
|
|
# Add Godeps dependencies to GOPATH and PATH
|
|
#- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
|
|
#- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
|
|
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$HOME/.cargo/bin:$PATH:/usr/lib/dart/bin"
|
|
#- go version
|
|
- gcc -v
|
|
- echo $CC
|
|
- echo $CXX
|
|
#- pub version
|
|
#- dart --version
|
|
|
|
script:
|
|
# fail fast
|
|
- set -e
|
|
# fail if templates/generators contain carriage return '\r'
|
|
- /bin/bash ./bin/utils/detect_carriage_return.sh
|
|
# fail if generators contain merge conflicts
|
|
- /bin/bash ./bin/utils/detect_merge_conflict.sh
|
|
# fail if generators contain tab '\t'
|
|
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
|
|
# run integration tests defined in maven pom.xml
|
|
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
|
|
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
|
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
|
after_success:
|
|
# push to maven repo
|
|
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
|
if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ]; then
|
|
echo "Publishing from branch $TRAVIS_BRANCH";
|
|
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml;
|
|
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
|
pushd .;
|
|
cd modules/openapi-generator-gradle-plugin;
|
|
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishMavenJavaPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
|
|
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
|
|
popd;
|
|
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then
|
|
echo "Publishing from branch $TRAVIS_BRANCH";
|
|
mvn clean deploy --settings CI/settings.xml;
|
|
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
|
pushd .;
|
|
cd modules/openapi-generator-gradle-plugin;
|
|
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
|
|
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
|
|
popd;
|
|
fi;
|
|
if [ -n $TRAVIS_TAG ] && [[ "$TRAVIS_TAG" =~ ^[v][0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
echo "Publishing the gradle plugin to Gradle Portal on tag $TRAVIS_TAG (only)";
|
|
pushd .;
|
|
cd modules/openapi-generator-gradle-plugin;
|
|
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET --no-daemon;
|
|
echo "Finished ./gradlew publishPlugins (plugin portal)";
|
|
popd;
|
|
fi;
|
|
fi;
|
|
## docker: build and push openapi-generator-online to DockerHub
|
|
- if [ $DOCKER_HUB_USERNAME ]; then
|
|
echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin;
|
|
export cli_version=$(\mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[');
|
|
export build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ");
|
|
docker build --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-online --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online;
|
|
if [ ! -z "$TRAVIS_TAG" ]; then
|
|
docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG;
|
|
fi;
|
|
if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then
|
|
docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME";
|
|
fi;
|
|
fi;
|
|
## docker: build cli image and push to Docker Hub
|
|
- if [ $DOCKER_HUB_USERNAME ]; then
|
|
echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin;
|
|
cp docker-entrypoint.sh ./modules/openapi-generator-cli;
|
|
export cli_version=$(\mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[');
|
|
export build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ");
|
|
docker build --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-cli --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli;
|
|
if [ ! -z "$TRAVIS_TAG" ]; then
|
|
docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG;
|
|
fi;
|
|
if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then
|
|
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME;
|
|
echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
|
|
fi;
|
|
fi;
|
|
## publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
|
|
- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
|
cd website;
|
|
git config --global user.name "${GH_NAME}";
|
|
git config --global user.email "${GH_EMAIL}";
|
|
echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
|
|
yarn install;
|
|
GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
|
|
fi;
|
|
|
|
env:
|
|
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5
|
|
|