[travis] Avoiding build timeouts, removing run-in-docker.sh (#2820)

* Removes run-in-docker.sh from travis build
* Updates run-in-docker.sh so it will cache to a volume-bound .m2/repository directory as intended
This commit is contained in:
Jim Schubert 2019-05-05 15:15:18 -04:00 committed by GitHub
parent e8a83dfe1f
commit 26d0487a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -3,6 +3,10 @@ language: java
jdk: jdk:
- openjdk8 - 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/
cache: cache:
directories: directories:
- $HOME/.m2 - $HOME/.m2
@ -121,8 +125,9 @@ script:
# fail if generators contain tab '\t' # fail if generators contain tab '\t'
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh - /bin/bash ./bin/utils/detect_tab_in_java_class.sh
# run integration tests defined in maven pom.xml # run integration tests defined in maven pom.xml
- mvn --quiet --batch-mode clean install # WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
- mvn --quiet --batch-mode verify -Psamples - mvn --quiet --batch-mode --show-version clean install
- mvn --quiet --batch-mode --show-version verify -Psamples
after_success: after_success:
# push to maven repo # push to maven repo
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
@ -162,3 +167,4 @@ after_success:
env: 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 - 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

View File

@ -0,0 +1,7 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- This directory matches what is defined in run-in-docker.sh -->
<localRepository>/var/maven/.m2/repository</localRepository>
</settings>

View File

@ -7,12 +7,18 @@ maven_cache_repo="${HOME}/.m2/repository"
mkdir -p "${maven_cache_repo}" mkdir -p "${maven_cache_repo}"
# !! The -u option below needs to be defined so we don't write to a user's bound ~/.m2/repository as root.
# !! but using this also means we either need to setup a user with the same id, or we execute without a username and home directory.
# !! This means we can't bind the .m2 directory to any user's directory (like /root/.m2).
# !! We _must_ define $MAVEN_CONFIG explicitly as a location that is not /root/.m2; the user executing this may not have access to the container's user's directory.
docker run --rm -it \ docker run --rm -it \
-w /gen \ -w /gen \
-e GEN_DIR=/gen \ -e GEN_DIR=/gen \
-e MAVEN_CONFIG=/var/maven/.m2 \ -e MAVEN_CONFIG=/var/maven/.m2 \
-e MAVEN_OPTS="-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=/var/maven/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" \
-u "$(id -u):$(id -g)" \ -u "$(id -u):$(id -g)" \
-v "${PWD}:/gen" \ -v "${PWD}:/gen" \
-v "$HOME/.m2":/root/.m2 \ -v "${PWD}/CI/run-in-docker-settings.xml:/var/maven/.m2/settings.xml" \
-v "${maven_cache_repo}:/var/maven/.m2/repository" \
--entrypoint /gen/docker-entrypoint.sh \ --entrypoint /gen/docker-entrypoint.sh \
maven:3-jdk-8 "$@" maven:3-jdk-8 "$@"