From 01cd87d9c7e893c8f36ca536aa45c7fe70417093 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Tue, 8 Jan 2019 19:45:46 -0800 Subject: [PATCH 1/4] Make CI more efficient. --- .travis.yml | 496 ++++++++++-------- build-support/bin/ci.sh | 25 +- .../bin/get_ci_bootstrapped_pants_pex.sh | 8 +- build-support/bin/install_aws_cli_for_ci.sh | 24 + build-support/bin/release.sh | 22 +- build-support/travis/before_install.mustache | 10 - .../travis/before_install_linux.mustache | 6 + .../travis/before_install_osx.mustache | 3 + build-support/travis/generate_travis_yml.py | 15 +- build-support/travis/travis.yml.mustache | 313 ++++++----- src/python/pants/releases/packages.py | 2 +- 11 files changed, 545 insertions(+), 379 deletions(-) create mode 100755 build-support/bin/install_aws_cli_for_ci.sh delete mode 100644 build-support/travis/before_install.mustache create mode 100644 build-support/travis/before_install_linux.mustache create mode 100644 build-support/travis/before_install_osx.mustache diff --git a/.travis.yml b/.travis.yml index 713867d1e24..8f777354e8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,57 +13,8 @@ env: - PYTEST_PASSTHRU_ARGS="-v --duration=3" - LC_ALL="en_US.UTF-8" - BOOTSTRAPPED_PEX_BUCKET=ci-public.pantsbuild.org - - BOOTSTRAPPED_PEX_KEY=${TRAVIS_BUILD_NUMBER}/${TRAVIS_BUILD_ID}/pants.pex - - BOOTSTRAPPED_PEX_URL=s3://${BOOTSTRAPPED_PEX_BUCKET}/${BOOTSTRAPPED_PEX_KEY} - - -before_cache: - # Ensure permissions to do the below removals, which happen with or without caching enabled. - - sudo chown -R travis:travis "${HOME}" "${TRAVIS_BUILD_DIR}" - # Kill all python bytecode in our cached venvs. Some files appear to - # get bytecode compiled in non-yet-understood circumstances leading to - # a full cache re-pack due to new bytecode files. - - find build-support -name "*.py[co]" -delete - # The `ivydata-*.properties` & root level `*.{properties,xml}` files' - # effect on resolution time is in the noise, but they are - # re-timestamped in internal comments and fields on each run and this - # leads to travis-ci cache thrash. Kill these files before the cache - # check to avoid un-needed cache re-packing and re-upload (a ~100s - # operation). - - find ${HOME}/.ivy2/pants -type f -name "ivydata-*.properties" -delete - - rm -f ${HOME}/.ivy2/pants/*.{css,properties,xml,xsl} - # We have several tests that do local file:// url resolves for - # com.example artifacts, these disrupt the cache but are fast since - # they're resolved from local files when omitted from the cache. - - rm -rf ${HOME}/.ivy2/pants/com.example - # The stats cache contains timestamped reports unused by CI but that - # thrash the cache. Skip caching these. - - rm -rf ${HOME}/.cache/pants/stats - # While the bin directory and rust toolchains are relatively large, they're also very quick to - # restore/install: prune them to keep the total cache size down. - # see https://docs.travis-ci.com/user/caching/#Things-not-to-cache - # NB: We do _not_ prune the cargo cache, since that holds compiled tools, package indexes and - # individually resolved crates. - - rm -rf ${HOME}/.cache/pants/bin - - rm -rf ${HOME}/.cache/pants/rust/rustup - - rm -rf ${HOME}/.cache/pants/lmdb_store - # Render a summary of what is left in the home directory, to assist with further pruning of - # the cache. - - du -m -d2 ${HOME} | sort -r -n - -cache: - # The default timeout is 180 seconds, and our larger cache uploads exceed this. - # TODO: Figure out why we have such large caches (2-7GB) and try to trim them. - timeout: 500 - directories: - - ${HOME}/.cache/pants - - ${HOME}/.ivy2/pants - # TODO(John Sirois): Update this to ~/.npm/pants when pants starts - # using its own isolated cache: - # https://github.com/pantsbuild/pants/issues/2485 - - ${HOME}/.npm - - build-support/pants_dev_deps.venv - - src/rust/engine/target + - BOOTSTRAPPED_PEX_KEY_PREFIX=${TRAVIS_BUILD_NUMBER}/${TRAVIS_BUILD_ID}/pants.pex + - BOOTSTRAPPED_PEX_URL_PREFIX=s3://${BOOTSTRAPPED_PEX_BUCKET}/${BOOTSTRAPPED_PEX_KEY_PREFIX} # Stages are documented here: https://docs.travis-ci.com/user/build-stages stages: @@ -77,7 +28,57 @@ stages: - name: &build_unstable Deploy Pants Pex Unstable if: tag IS NOT present AND type NOT IN (pull_request, cron) -default_test_config: &default_test_config +# Travis cache config for jobs that build the native engine. +native_engine_cache_config: &native_engine_cache_config + before_cache: + # Ensure permissions to do the below removals, which happen with or without caching enabled. + - sudo chown -R travis:travis "${HOME}" "${TRAVIS_BUILD_DIR}" + # Kill all python bytecode in our cached venvs. Some files appear to + # get bytecode compiled in non-yet-understood circumstances leading to + # a full cache re-pack due to new bytecode files. + - find build-support -name "*.py[co]" -delete + cache: + # The default timeout is 180 seconds, and our larger cache uploads exceed this. + # TODO: Figure out why we have such large caches (2-7GB) and try to trim them. + timeout: 500 + directories: + - ${HOME}/.cache/pants/rust/cargo + - build-support/pants_dev_deps.venv + - src/rust/engine/target + +# Travis cache config for jobs that run a bootstrapped pants.pex. +pants_run_cache_config: &pants_run_cache_config + before_cache: + # Ensure permissions to do the below removals, which happen with or without caching enabled. + - sudo chown -R travis:travis "${HOME}" "${TRAVIS_BUILD_DIR}" + # The `ivydata-*.properties` & root level `*.{properties,xml}` files' + # effect on resolution time is in the noise, but they are + # re-timestamped in internal comments and fields on each run and this + # leads to travis-ci cache thrash. Kill these files before the cache + # check to avoid un-needed cache re-packing and re-upload (a ~100s + # operation). + - find ${HOME}/.ivy2/pants -type f -name "ivydata-*.properties" -delete + - rm -f ${HOME}/.ivy2/pants/*.{css,properties,xml,xsl} + # We have several tests that do local file:// url resolves for + # com.example artifacts, these disrupt the cache but are fast since + # they're resolved from local files when omitted from the cache. + - rm -rf ${HOME}/.ivy2/pants/com.example + # Render a summary to assist with further tuning the cache. + - du -m -d2 ${HOME}/.cache/pants | sort -r -n + cache: + # The default timeout is 180 seconds, and our larger cache uploads exceed this. + # TODO: Figure out why we have such large caches (2-7GB) and try to trim them. + timeout: 500 + directories: + - ${HOME}/.cache/pants/tools + - ${HOME}/.cache/pants/zinc + - ${HOME}/.ivy2/pants + # TODO(John Sirois): Update this to ~/.npm/pants when pants starts + # using its own isolated cache: + # https://github.com/pantsbuild/pants/issues/2485 + - ${HOME}/.npm + +default_linux_config: &default_linux_config os: linux dist: xenial sudo: required @@ -91,34 +92,45 @@ default_test_config: &default_test_config - python-dev - openssl - libssl-dev - stage: *test + - jq + - unzip language: python python: &python_version "2.7" + before_install: + - ./build-support/bin/install_aws_cli_for_ci.sh + after_failure: + - ./build-support/bin/ci-failure.sh + +default_linux_test_config: &default_linux_test_config + <<: *default_linux_config + <<: *pants_run_cache_config + stage: *test before_install: - PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin":$PATH - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 # Increase the max number of user watches to ensure that watchman is able to watch all # files in the working copy. - sudo sysctl fs.inotify.max_user_watches=524288 - - sudo pip install awscli - # Multipart operations aren't supported for anonymous users, so we set the - # threshold high to avoid them being used automatically by the aws cli. - - aws configure set default.s3.multipart_threshold 1024MB - - sudo apt-get install -y jq unzip + - ./build-support/bin/install_aws_cli_for_ci.sh before_script: - - ./build-support/bin/get_ci_bootstrapped_pants_pex.sh ${BOOTSTRAPPED_PEX_BUCKET} ${BOOTSTRAPPED_PEX_KEY} - + - ./build-support/bin/get_ci_bootstrapped_pants_pex.sh ${BOOTSTRAPPED_PEX_BUCKET} ${BOOTSTRAPPED_PEX_KEY_PREFIX}.linux -osx_test_config: &osx_test_config +default_osx_config: &default_osx_config os: osx - stage: *test language: generic - script: - - MODE=debug ./build-support/bin/travis-ci.sh -m + before_install: + - curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 -o /usr/local/bin/jq + - chmod 755 /usr/local/bin/jq + - ./build-support/bin/install_aws_cli_for_ci.sh -default_cron_test_config: &default_cron_test_config - <<: *default_test_config - stage: *cron +default_osx_test_config: &default_osx_test_config + <<: *default_osx_config + <<: *pants_run_cache_config + stage: *test + before_script: + - ulimit -c unlimited + - ulimit -n 8192 + - ./build-support/bin/get_ci_bootstrapped_pants_pex.sh ${BOOTSTRAPPED_PEX_BUCKET} ${BOOTSTRAPPED_PEX_KEY_PREFIX}.osx linux_with_fuse: &linux_with_fuse before_install: @@ -127,11 +139,7 @@ linux_with_fuse: &linux_with_fuse # Increase the max number of user watches to ensure that watchman is able to watch all # files in the working copy. - sudo sysctl fs.inotify.max_user_watches=524288 - - sudo pip install awscli - # Multipart operations aren't supported for anonymous users, so we set the - # threshold high to avoid them being used automatically by the aws cli. - - aws configure set default.s3.multipart_threshold 1024MB - - sudo apt-get install -y jq unzip + - ./build-support/bin/install_aws_cli_for_ci.sh - sudo apt-get install -y pkg-config fuse libfuse-dev - sudo modprobe fuse - sudo chmod 666 /dev/fuse @@ -139,70 +147,100 @@ linux_with_fuse: &linux_with_fuse matrix: include: - - <<: *default_test_config - name: "Bootstrap Pants" + - <<: *default_linux_config + <<: *native_engine_cache_config + name: "Build Linux native engine and pants.pex" stage: *bootstrap + services: + - docker + env: + - CACHE_NAME=linuxpexbuild + - PREPARE_DEPLOY=1 # To deploy fs_util. before_script: + - ulimit -c unlimited script: - - ./build-support/bin/travis-ci.sh # With no args this script just bootstraps. - - aws --no-sign-request --region us-east-1 s3 cp ./pants.pex ${BOOTSTRAPPED_PEX_URL} + - docker build --rm -t travis_ci + --build-arg "TRAVIS_USER=$(id -un)" + --build-arg "TRAVIS_UID=$(id -u)" + --build-arg "TRAVIS_GROUP=$(id -gn)" + --build-arg "TRAVIS_GID=$(id -g)" + build-support/docker/travis_ci/ + # Note that: + # * We mount ${HOME} to cache the ${HOME}/.cache/pants/rust-toolchain. + # * With no args ci.sh just bootstraps a pants.pex. + # * We also build fs_util, to take advantage of the rust code built during bootstrapping. + - docker run --rm -t + -v "${HOME}:/travis/home" + -v "${TRAVIS_BUILD_DIR}:/travis/workdir" + travis_ci:latest + sh -c "git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f" + - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.linux # Build macOS engine - - name: "OSX Native Engine Binary Builder" - os: osx + - <<: *default_osx_config + <<: *native_engine_cache_config + name: "Build OSX native engine and pants.pex" + stage: *bootstrap # We request the oldest image we can (corresponding to OSX 10.11) for maximum compatibility. # We use 10.11 as a minimum to avoid https://github.com/rust-lang/regex/issues/489. # See: https://docs.travis-ci.com/user/reference/osx/#OS-X-Version osx_image: xcode8 + env: + - CACHE_NAME=macospexbuild + - PREPARE_DEPLOY=1 # To deploy fs_util. + script: + # With no args ci.sh just bootstraps a pants.pex. We also build fs_util, to take advantage + # of the rust code built during bootstrapping. + - git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f + - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.osx + after_failure: + - ./build-support/bin/ci-failure.sh + + - <<: *default_linux_test_config + name: "Build Linux wheels" stage: *test - language: generic env: + - CACHE_NAME=linuxwheelsbuild + - RUN_PANTS_FROM_PEX=1 - PREPARE_DEPLOY=1 script: - - ./pants --version && ./build-support/bin/release.sh -n + - ./build-support/bin/release.sh -n + + - <<: *default_osx_test_config + name: "Build OSX wheels" + osx_image: xcode8 + env: + - CACHE_NAME=osxwheelsbuild + - RUN_PANTS_FROM_PEX=1 + - PREPARE_DEPLOY=1 + script: + - ./build-support/bin/release.sh -n # TODO: Update this to use 10.14 once it is available - - name: "OSX 10.12 Sanity Check" - <<: *osx_test_config + - <<: *default_osx_test_config + name: "OSX 10.12 sanity check" osx_image: xcode9.2 + env: + - CACHE_NAME=macos10.12sanity + script: + - MODE=debug ./build-support/bin/travis-ci.sh -bm - - name: "OSX 10.13 Sanity Check" - <<: *osx_test_config + - <<: *default_osx_test_config + name: "OSX 10.13 sanity check" osx_image: xcode10.1 - - # Build Linux engine - - name: "Linux Native Engine Binary Builder" - os: linux - stage: *test - language: generic - services: - - docker env: - - PREPARE_DEPLOY=1 - before_script: - - ulimit -c unlimited + - CACHE_NAME=macos10.13sanity script: - - docker build --rm -t travis_ci - --build-arg "TRAVIS_USER=$(id -un)" - --build-arg "TRAVIS_UID=$(id -u)" - --build-arg "TRAVIS_GROUP=$(id -gn)" - --build-arg "TRAVIS_GID=$(id -g)" - build-support/docker/travis_ci/ - # Mount ${HOME} to cache the ${HOME}/.cache/pants/rust-toolchain - - docker run --rm -t - -v "${HOME}:/travis/home" - -v "${TRAVIS_BUILD_DIR}:/travis/workdir" - travis_ci:latest - sh -c "git clean -xfd && ./pants --version && ./build-support/bin/release.sh -n" - after_failure: - - build-support/bin/ci-failure.sh + - MODE=debug ./build-support/bin/travis-ci.sh -bm # Deploy Pex Stable - - name: "Deploy Pants PEX" + - name: "Deploy stable multiplatform pants.pex" os: linux language: python stage: *build_stable env: + - CACHE_NAME=linuxpexdeploystable + - RUN_PANTS_FROM_PEX=1 - PANTS_PEX_RELEASE=stable script: - ./build-support/bin/release.sh -p @@ -221,325 +259,359 @@ matrix: repo: pantsbuild/pants # Deploy Pex Unstable to s3 - - name: "Deploy Pants PEX Unstable" + - name: "Deploy unstable multiplatform pants.pex" os: linux language: python stage: *build_unstable env: + - CACHE_NAME=linuxpexdeployunstable + - RUN_PANTS_FROM_PEX=1 - PREPARE_DEPLOY=1 script: - ./build-support/bin/release.sh -p && mkdir -p dist/deploy/pex/ && mv dist/pants*.pex dist/deploy/pex/ - - <<: *default_test_config + - <<: *default_linux_test_config <<: *linux_with_fuse - name: "Self checks, lint, and JVM tests" + name: "Self-checks, lint, and JVM tests" + env: + - CACHE_NAME=linuxselfchecks script: - - ./build-support/bin/travis-ci.sh -fbkmrjt + - ./build-support/bin/travis-ci.sh -fbmrjt - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py2 - Unit tests for pants and pants-plugins" + env: + - CACHE_NAME=linuxunittests.py2 script: - ./build-support/bin/travis-ci.sh -blp - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py3 - Unit tests for pants and pants-plugins" + env: + - CACHE_NAME=linuxunittests.py3 script: - ./build-support/bin/travis-ci.sh -3blp - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py2 - Python contrib tests" + env: + - CACHE_NAME=linuxcontribtests.py2 script: - ./build-support/bin/travis-ci.sh -bn - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py3 - Python contrib tests" + env: + - CACHE_NAME=linuxcontribtests.py3 script: - ./build-support/bin/travis-ci.sh -3bn - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 0" env: - - CACHE_NAME=integrationshard0 # Ensure distinct caches. + - CACHE_NAME=integrationshard0 script: - ./build-support/bin/travis-ci.sh -bc3 -i 0/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 1" env: - - CACHE_NAME=integrationshard1 # Ensure distinct caches. + - CACHE_NAME=integrationshard1 script: - ./build-support/bin/travis-ci.sh -bc3 -i 1/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 2" env: - - CACHE_NAME=integrationshard2 # Ensure distinct caches. + - CACHE_NAME=integrationshard2 script: - ./build-support/bin/travis-ci.sh -bc3 -i 2/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 3" env: - - CACHE_NAME=integrationshard3 # Ensure distinct caches. + - CACHE_NAME=integrationshard3 script: - ./build-support/bin/travis-ci.sh -bc3 -i 3/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 4" env: - - CACHE_NAME=integrationshard4 # Ensure distinct caches. + - CACHE_NAME=integrationshard4 script: - ./build-support/bin/travis-ci.sh -bc3 -i 4/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 5" env: - - CACHE_NAME=integrationshard5 # Ensure distinct caches. + - CACHE_NAME=integrationshard5 script: - ./build-support/bin/travis-ci.sh -bc3 -i 5/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 6" env: - - CACHE_NAME=integrationshard6 # Ensure distinct caches. + - CACHE_NAME=integrationshard6 script: - ./build-support/bin/travis-ci.sh -bc3 -i 6/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 7" env: - - CACHE_NAME=integrationshard7 # Ensure distinct caches. + - CACHE_NAME=integrationshard7 script: - ./build-support/bin/travis-ci.sh -bc3 -i 7/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 8" env: - - CACHE_NAME=integrationshard8 # Ensure distinct caches. + - CACHE_NAME=integrationshard8 script: - ./build-support/bin/travis-ci.sh -bc3 -i 8/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 9" env: - - CACHE_NAME=integrationshard9 # Ensure distinct caches. + - CACHE_NAME=integrationshard9 script: - ./build-support/bin/travis-ci.sh -bc3 -i 9/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 10" env: - - CACHE_NAME=integrationshard10 # Ensure distinct caches. + - CACHE_NAME=integrationshard10 script: - ./build-support/bin/travis-ci.sh -bc3 -i 10/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 11" env: - - CACHE_NAME=integrationshard11 # Ensure distinct caches. + - CACHE_NAME=integrationshard11 script: - ./build-support/bin/travis-ci.sh -bc3 -i 11/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 12" env: - - CACHE_NAME=integrationshard12 # Ensure distinct caches. + - CACHE_NAME=integrationshard12 script: - ./build-support/bin/travis-ci.sh -bc3 -i 12/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 13" env: - - CACHE_NAME=integrationshard13 # Ensure distinct caches. + - CACHE_NAME=integrationshard13 script: - ./build-support/bin/travis-ci.sh -bc3 -i 13/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 14" env: - - CACHE_NAME=integrationshard14 # Ensure distinct caches. + - CACHE_NAME=integrationshard14 script: - ./build-support/bin/travis-ci.sh -bc3 -i 14/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 15" env: - - CACHE_NAME=integrationshard15 # Ensure distinct caches. + - CACHE_NAME=integrationshard15 script: - ./build-support/bin/travis-ci.sh -bc3 -i 15/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 16" env: - - CACHE_NAME=integrationshard16 # Ensure distinct caches. + - CACHE_NAME=integrationshard16 script: - ./build-support/bin/travis-ci.sh -bc3 -i 16/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 17" env: - - CACHE_NAME=integrationshard17 # Ensure distinct caches. + - CACHE_NAME=integrationshard17 script: - ./build-support/bin/travis-ci.sh -bc3 -i 17/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 18" env: - - CACHE_NAME=integrationshard18 # Ensure distinct caches. + - CACHE_NAME=integrationshard18 script: - ./build-support/bin/travis-ci.sh -bc3 -i 18/20 - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard 19" env: - - CACHE_NAME=integrationshard19 # Ensure distinct caches. + - CACHE_NAME=integrationshard19 script: - ./build-support/bin/travis-ci.sh -bc3 -i 19/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 0" + stage: *cron env: - - CACHE_NAME=cronshard0 # Ensure distinct caches. + - CACHE_NAME=cronshard0 script: - ./build-support/bin/travis-ci.sh -bc -i 0/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 1" + stage: *cron env: - - CACHE_NAME=cronshard1 # Ensure distinct caches. + - CACHE_NAME=cronshard1 script: - ./build-support/bin/travis-ci.sh -bc -i 1/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 2" + stage: *cron env: - - CACHE_NAME=cronshard2 # Ensure distinct caches. + - CACHE_NAME=cronshard2 script: - ./build-support/bin/travis-ci.sh -bc -i 2/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 3" + stage: *cron env: - - CACHE_NAME=cronshard3 # Ensure distinct caches. + - CACHE_NAME=cronshard3 script: - ./build-support/bin/travis-ci.sh -bc -i 3/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 4" + stage: *cron env: - - CACHE_NAME=cronshard4 # Ensure distinct caches. + - CACHE_NAME=cronshard4 script: - ./build-support/bin/travis-ci.sh -bc -i 4/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 5" + stage: *cron env: - - CACHE_NAME=cronshard5 # Ensure distinct caches. + - CACHE_NAME=cronshard5 script: - ./build-support/bin/travis-ci.sh -bc -i 5/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 6" + stage: *cron env: - - CACHE_NAME=cronshard6 # Ensure distinct caches. + - CACHE_NAME=cronshard6 script: - ./build-support/bin/travis-ci.sh -bc -i 6/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 7" + stage: *cron env: - - CACHE_NAME=cronshard7 # Ensure distinct caches. + - CACHE_NAME=cronshard7 script: - ./build-support/bin/travis-ci.sh -bc -i 7/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 8" + stage: *cron env: - - CACHE_NAME=cronshard8 # Ensure distinct caches. + - CACHE_NAME=cronshard8 script: - ./build-support/bin/travis-ci.sh -bc -i 8/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 9" + stage: *cron env: - - CACHE_NAME=cronshard9 # Ensure distinct caches. + - CACHE_NAME=cronshard9 script: - ./build-support/bin/travis-ci.sh -bc -i 9/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 10" + stage: *cron env: - - CACHE_NAME=cronshard10 # Ensure distinct caches. + - CACHE_NAME=cronshard10 script: - ./build-support/bin/travis-ci.sh -bc -i 10/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 11" + stage: *cron env: - - CACHE_NAME=cronshard11 # Ensure distinct caches. + - CACHE_NAME=cronshard11 script: - ./build-support/bin/travis-ci.sh -bc -i 11/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 12" + stage: *cron env: - - CACHE_NAME=cronshard12 # Ensure distinct caches. + - CACHE_NAME=cronshard12 script: - ./build-support/bin/travis-ci.sh -bc -i 12/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 13" + stage: *cron env: - - CACHE_NAME=cronshard13 # Ensure distinct caches. + - CACHE_NAME=cronshard13 script: - ./build-support/bin/travis-ci.sh -bc -i 13/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 14" + stage: *cron env: - - CACHE_NAME=cronshard14 # Ensure distinct caches. + - CACHE_NAME=cronshard14 script: - ./build-support/bin/travis-ci.sh -bc -i 14/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 15" + stage: *cron env: - - CACHE_NAME=cronshard15 # Ensure distinct caches. + - CACHE_NAME=cronshard15 script: - ./build-support/bin/travis-ci.sh -bc -i 15/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 16" + stage: *cron env: - - CACHE_NAME=cronshard16 # Ensure distinct caches. + - CACHE_NAME=cronshard16 script: - ./build-support/bin/travis-ci.sh -bc -i 16/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 17" + stage: *cron env: - - CACHE_NAME=cronshard17 # Ensure distinct caches. + - CACHE_NAME=cronshard17 script: - ./build-support/bin/travis-ci.sh -bc -i 17/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 18" + stage: *cron env: - - CACHE_NAME=cronshard18 # Ensure distinct caches. + - CACHE_NAME=cronshard18 script: - ./build-support/bin/travis-ci.sh -bc -i 18/20 - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard 19" + stage: *cron env: - - CACHE_NAME=cronshard19 # Ensure distinct caches. + - CACHE_NAME=cronshard19 script: - ./build-support/bin/travis-ci.sh -bc -i 19/20 # Rust on linux - <<: *linux_with_fuse - name: "Rust Tests Linux" + name: "Linux Rust tests" + env: + - CACHE_NAME=linuxrusttests os: linux dist: xenial sudo: required @@ -551,26 +623,27 @@ matrix: - ulimit -n 8192 script: - ./build-support/bin/travis-ci.sh -be + # Rust on macOS - - name: "Rust + Platform-specific Tests OSX" - os: osx + - <<: *default_osx_test_config + name: "OSX Rust + platform-specific tests" + env: + - CACHE_NAME=macosrusttests # Fuse actually works on this image. It hangs on many others. osx_image: xcode8.3 - stage: *test - language: generic before_install: + - curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 -o /usr/local/bin/jq + - chmod 755 /usr/local/bin/jq + - ./build-support/bin/install_aws_cli_for_ci.sh - brew tap caskroom/cask && brew update && brew cask install osxfuse - before_script: - - ulimit -c unlimited - - ulimit -n 8192 script: - # Platform-specific tests currently need a pants pex, so we bootstrap here (no -b) and - # set -z to run the platform-specific tests. - - ./build-support/bin/travis-ci.sh -ez + - ./build-support/bin/travis-ci.sh -bez # Rust Clippy on Linux - <<: *linux_with_fuse - name: "Rust Clippy on Linux" + name: "Linux Rust Clippy" + env: + - CACHE_NAME=linuxclippy os: linux dist: xenial sudo: required @@ -586,6 +659,8 @@ matrix: # Cargo audit - <<: *linux_with_fuse name: "Cargo audit" + env: + - CACHE_NAME=linuxcargoaudit os: linux dist: xenial sudo: required @@ -594,6 +669,7 @@ matrix: - ./build-support/bin/travis-ci.sh -ba deploy: + # Deploy whatever a previous stage has left in dist/deploy. # See: https://docs.travis-ci.com/user/deployment/s3/ provider: s3 access_key_id: AKIAIWOKBXVU3JLY6EGQ diff --git a/build-support/bin/ci.sh b/build-support/bin/ci.sh index c85db84a6f3..46a92294187 100755 --- a/build-support/bin/ci.sh +++ b/build-support/bin/ci.sh @@ -21,7 +21,6 @@ Usage: $0 (-h|-3fxbkmrjlpuneycitzs) -x run bootstrap clean-all (assume bootstrapping from a fresh clone) -b skip bootstrapping pants from local sources - -k run bootstrapped pants self compile check -m run sanity checks of bootstrapped pants and repo BUILD files -r run doc generation tests @@ -55,25 +54,19 @@ EOF fi } -bootstrap_compile_args=( - lint.python-eval - --transitive -) - # No python test sharding (1 shard) by default. python_unit_shard="0/1" python_contrib_shard="0/1" python_intg_shard="0/1" python_three="false" -while getopts "h3fxbkmrjlpeasu:ny:ci:tz" opt; do +while getopts "h3fxbmrjlpeasu:ny:ci:tz" opt; do case ${opt} in h) usage ;; 3) python_three="true" ;; f) run_pre_commit_checks="true" ;; x) run_bootstrap_clean="true" ;; b) run_bootstrap="false" ;; - k) bootstrap_compile_args=() ;; m) run_sanity_checks="true" ;; r) run_docs="true" ;; j) run_jvm="true" ;; @@ -111,21 +104,13 @@ esac # We're running against a Pants clone. export PANTS_DEV=1 -set -x - -if [[ "${run_pre_commit_checks:-false}" == "true" ]]; then - start_travis_section "PreCommit" "Running pre-commit checks" - FULL_CHECK=1 ./build-support/bin/pre-commit.sh || exit 1 - end_travis_section -fi - if [[ "${run_bootstrap:-true}" == "true" ]]; then start_travis_section "Bootstrap" "Bootstrapping pants" ( if [[ "${run_bootstrap_clean:-false}" == "true" ]]; then ./build-support/python/clean.sh || die "Failed to clean before bootstrapping pants." fi - ./pants ${bootstrap_compile_args[@]} binary \ + ./pants binary \ src/python/pants/bin:pants_local_binary && \ mv dist/pants_local_binary.pex pants.pex && \ ./pants.pex -V @@ -139,6 +124,12 @@ fi # integration tests that shell out to `./pants`, so we set this env var for those cases. export RUN_PANTS_FROM_PEX=1 +if [[ "${run_pre_commit_checks:-false}" == "true" ]]; then + start_travis_section "PreCommit" "Running pre-commit checks" + FULL_CHECK=1 ./build-support/bin/pre-commit.sh || exit 1 + end_travis_section +fi + # NB: Ordering matters here. We (currently) always bootstrap a Python 2 pex. if [[ "${python_three:-false}" == "true" ]]; then banner "Setting interpreter constraints for 3!" diff --git a/build-support/bin/get_ci_bootstrapped_pants_pex.sh b/build-support/bin/get_ci_bootstrapped_pants_pex.sh index fb08d97175a..30608491ba8 100755 --- a/build-support/bin/get_ci_bootstrapped_pants_pex.sh +++ b/build-support/bin/get_ci_bootstrapped_pants_pex.sh @@ -4,6 +4,7 @@ set -euo pipefail BOOTSTRAPPED_PEX_BUCKET=$1 BOOTSTRAPPED_PEX_KEY=$2 + BOOTSTRAPPED_PEX_URL=s3://${BOOTSTRAPPED_PEX_BUCKET}/${BOOTSTRAPPED_PEX_KEY} # Note that in the aws cli --no-sign-request allows access to public S3 buckets without @@ -13,7 +14,7 @@ BOOTSTRAPPED_PEX_URL=s3://${BOOTSTRAPPED_PEX_BUCKET}/${BOOTSTRAPPED_PEX_KEY} NUM_VERSIONS=$(aws --no-sign-request --region us-east-1 s3api list-object-versions \ --bucket ${BOOTSTRAPPED_PEX_BUCKET} --prefix ${BOOTSTRAPPED_PEX_KEY} --max-items 2 \ | jq '.Versions | length') -[ "${NUM_VERSIONS}" == "1" ] || die "Error: Found ${NUM_VERSIONS} versions for ${BOOTSTRAPPED_PEX_URL}" +[ "${NUM_VERSIONS}" == "1" ] || (echo "Error: Found ${NUM_VERSIONS} versions for ${BOOTSTRAPPED_PEX_URL}" && exit 1) # Now fetch the pre-bootstrapped pex, so that the ./pants wrapper script can use it # instead of running from sources (and re-bootstrapping). @@ -23,4 +24,7 @@ chmod 755 ./pants.pex # Pants code executing under test expects native_engine.so to be present as a resource # in the source tree. Normally it'll be there because we created it there during bootstrapping. # So here we have to manually extract it there from the bootstrapped pex. -unzip -j pants.pex pants/engine/native_engine.so -d src/python/pants/engine/ +# The "|| true" is necessary because unzip returns a non-zero exit code if there were any +# bytes before the zip magic number (in our case, the pex shebang), even though the unzip +# operation otherwise succeeds. +unzip -j pants.pex pants/engine/native_engine.so -d src/python/pants/engine/ || true diff --git a/build-support/bin/install_aws_cli_for_ci.sh b/build-support/bin/install_aws_cli_for_ci.sh new file mode 100755 index 00000000000..91192cdc0cc --- /dev/null +++ b/build-support/bin/install_aws_cli_for_ci.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Install the AWS CLI in CI jobs. + +# This is the fastest, most reliable way to install the AWS CLI on Linux and, particularly, MacOS. +# Using pip is broken on some systems, and package managers (e.g., brew) must be updated prior +# to use, which slows down CI jobs significantly. This is also the installation method recommended +# by AWS, see https://docs.aws.amazon.com/cli/latest/userguide/install-bundle.html. + +TMPDIR=$(mktemp -d) + +pushd ${TMPDIR} + +curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" +unzip awscli-bundle.zip +sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws + +popd + +# Multipart operations aren't supported for anonymous users, so we set the +# threshold high to avoid them being used automatically by the aws cli. +aws configure set default.s3.multipart_threshold 1024MB diff --git a/build-support/bin/release.sh b/build-support/bin/release.sh index 61cd19d79f5..82642eb9f2f 100755 --- a/build-support/bin/release.sh +++ b/build-support/bin/release.sh @@ -133,14 +133,20 @@ function pants_version_reset() { pushd ${ROOT} > /dev/null git checkout -- ${VERSION_FILE} popd > /dev/null + unset _PANTS_VERSION_OVERRIDE } function pants_version_set() { - # Mutates `src/python/pants/VERSION` to temporarily override it. Sets a `trap` to restore to - # HEAD on exit. + # Set the version in the wheels we build by mutating `src/python/pants/VERSION` to temporarily + # override it. Sets a `trap` to restore to HEAD on exit. local version=$1 trap pants_version_reset EXIT echo "${version}" > "${VERSION_FILE}" + # Also set the version reported by the prebuilt pant.pex we use to build the wheels. + # This is so that we pass the sanity-check that verifies that the built wheels have the same + # version as the pants version used to build them. + # TODO: Do we actually need that sanity check? + export _PANTS_VERSION_OVERRIDE=${version} } function build_3rdparty_packages() { @@ -187,8 +193,6 @@ function build_pants_packages() { } function build_fs_util() { - local version=$1 - start_travis_section "fs_util" "Building fs_util binary" # fs_util is a standalone tool which can be used to inspect and manipulate # Pants's engine's file store, and interact with content addressable storage @@ -200,7 +204,7 @@ function build_fs_util() { set -e RUST_BACKTRACE=1 "${ROOT}/build-support/bin/native/cargo" build --release \ --manifest-path="${ROOT}/src/rust/engine/Cargo.toml" -p fs_util - dst_dir="${DEPLOY_DIR}/bin/fs_util/$("${ROOT}/build-support/bin/get_os.sh")/${version}" + dst_dir="${DEPLOY_DIR}/bin/fs_util/$("${ROOT}/build-support/bin/get_os.sh")/${PANTS_UNSTABLE_VERSION}" mkdir -p "${dst_dir}" cp "${ROOT}/src/rust/engine/target/release/fs_util" "${dst_dir}/" ) || die "Failed to build fs_util" @@ -615,13 +619,14 @@ function usage() { echo "PyPi. Credentials are needed for this as described in the" echo "release docs: http://pantsbuild.org/release.html" echo - echo "Usage: $0 [-d] [-c] (-h|-n|-t|-l|-o|-e|-p)" + echo "Usage: $0 [-d] [-c] (-h|-n|-f|-t|-l|-o|-e|-p)" echo " -d Enables debug mode (verbose output, script pauses after venv creation)" echo " -h Prints out this help message." echo " -n Performs a release dry run." echo " All package distributions will be built, installed locally in" echo " an ephemeral virtualenv and exercised to validate basic" echo " functioning." + echo " -f Build the fs_util binary." echo " -t Tests a live release." echo " Ensures the latest packages have been propagated to PyPi" echo " and can be installed in an ephemeral virtualenv." @@ -640,11 +645,12 @@ function usage() { fi } -while getopts "hdntcloepqw" opt; do +while getopts "hdnftcloepqw" opt; do case ${opt} in h) usage ;; d) debug="true" ;; n) dry_run="true" ;; + f) build_fs_util ; exit $? ;; t) test_release="true" ;; l) run_packages_script list ; exit $? ;; o) run_packages_script list-owners ; exit $? ;; @@ -666,7 +672,7 @@ if [[ "${dry_run}" == "true" && "${test_release}" == "true" ]]; then elif [[ "${dry_run}" == "true" ]]; then banner "Performing a dry run release" && \ ( - dry_run_install && build_fs_util "${PANTS_UNSTABLE_VERSION}" && \ + dry_run_install && \ banner "Dry run release succeeded" ) || die "Dry run release failed." elif [[ "${test_release}" == "true" ]]; then diff --git a/build-support/travis/before_install.mustache b/build-support/travis/before_install.mustache deleted file mode 100644 index 8b0204d6252..00000000000 --- a/build-support/travis/before_install.mustache +++ /dev/null @@ -1,10 +0,0 @@ - - PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin":$PATH - - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - # Increase the max number of user watches to ensure that watchman is able to watch all - # files in the working copy. - - sudo sysctl fs.inotify.max_user_watches=524288 - - sudo pip install awscli - # Multipart operations aren't supported for anonymous users, so we set the - # threshold high to avoid them being used automatically by the aws cli. - - aws configure set default.s3.multipart_threshold 1024MB - - sudo apt-get install -y jq unzip diff --git a/build-support/travis/before_install_linux.mustache b/build-support/travis/before_install_linux.mustache new file mode 100644 index 00000000000..fa160b114ba --- /dev/null +++ b/build-support/travis/before_install_linux.mustache @@ -0,0 +1,6 @@ +- PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin":$PATH +- JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 +# Increase the max number of user watches to ensure that watchman is able to watch all +# files in the working copy. +- sudo sysctl fs.inotify.max_user_watches=524288 +- ./build-support/bin/install_aws_cli_for_ci.sh diff --git a/build-support/travis/before_install_osx.mustache b/build-support/travis/before_install_osx.mustache new file mode 100644 index 00000000000..f56bd2147e3 --- /dev/null +++ b/build-support/travis/before_install_osx.mustache @@ -0,0 +1,3 @@ +- curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 -o /usr/local/bin/jq +- chmod 755 /usr/local/bin/jq +- ./build-support/bin/install_aws_cli_for_ci.sh diff --git a/build-support/travis/generate_travis_yml.py b/build-support/travis/generate_travis_yml.py index 8af6d853277..ee9e822e5bc 100644 --- a/build-support/travis/generate_travis_yml.py +++ b/build-support/travis/generate_travis_yml.py @@ -20,14 +20,19 @@ def generate_travis_yml(): """Generates content for a .travis.yml file from templates.""" - template = pkg_resources.resource_string(__name__, - 'travis.yml.mustache').decode('utf-8') - before_install = pkg_resources.resource_string(__name__, - 'before_install.mustache').decode('utf-8') + template = pkg_resources.resource_string( + __name__, 'travis.yml.mustache').decode('utf-8') + before_install_linux = pkg_resources.resource_string( + __name__, 'before_install_linux.mustache').decode('utf-8') + before_install_osx = pkg_resources.resource_string( + __name__, 'before_install_osx.mustache').decode('utf-8') context = { 'header': HEADER, 'integration_shards': range(0, num_integration_shards), 'integration_shards_length': num_integration_shards, } - renderer = pystache.Renderer(partials={'before_install': before_install}) + renderer = pystache.Renderer(partials={ + 'before_install_linux': before_install_linux, + 'before_install_osx': before_install_osx + }) print(renderer.render(template, context)) diff --git a/build-support/travis/travis.yml.mustache b/build-support/travis/travis.yml.mustache index 40eface4b64..61056c30fc8 100644 --- a/build-support/travis/travis.yml.mustache +++ b/build-support/travis/travis.yml.mustache @@ -9,57 +9,8 @@ env: - PYTEST_PASSTHRU_ARGS="-v --duration=3" - LC_ALL="en_US.UTF-8" - BOOTSTRAPPED_PEX_BUCKET=ci-public.pantsbuild.org - - BOOTSTRAPPED_PEX_KEY=${TRAVIS_BUILD_NUMBER}/${TRAVIS_BUILD_ID}/pants.pex - - BOOTSTRAPPED_PEX_URL=s3://${BOOTSTRAPPED_PEX_BUCKET}/${BOOTSTRAPPED_PEX_KEY} - - -before_cache: - # Ensure permissions to do the below removals, which happen with or without caching enabled. - - sudo chown -R travis:travis "${HOME}" "${TRAVIS_BUILD_DIR}" - # Kill all python bytecode in our cached venvs. Some files appear to - # get bytecode compiled in non-yet-understood circumstances leading to - # a full cache re-pack due to new bytecode files. - - find build-support -name "*.py[co]" -delete - # The `ivydata-*.properties` & root level `*.{properties,xml}` files' - # effect on resolution time is in the noise, but they are - # re-timestamped in internal comments and fields on each run and this - # leads to travis-ci cache thrash. Kill these files before the cache - # check to avoid un-needed cache re-packing and re-upload (a ~100s - # operation). - - find ${HOME}/.ivy2/pants -type f -name "ivydata-*.properties" -delete - - rm -f ${HOME}/.ivy2/pants/*.{css,properties,xml,xsl} - # We have several tests that do local file:// url resolves for - # com.example artifacts, these disrupt the cache but are fast since - # they're resolved from local files when omitted from the cache. - - rm -rf ${HOME}/.ivy2/pants/com.example - # The stats cache contains timestamped reports unused by CI but that - # thrash the cache. Skip caching these. - - rm -rf ${HOME}/.cache/pants/stats - # While the bin directory and rust toolchains are relatively large, they're also very quick to - # restore/install: prune them to keep the total cache size down. - # see https://docs.travis-ci.com/user/caching/#Things-not-to-cache - # NB: We do _not_ prune the cargo cache, since that holds compiled tools, package indexes and - # individually resolved crates. - - rm -rf ${HOME}/.cache/pants/bin - - rm -rf ${HOME}/.cache/pants/rust/rustup - - rm -rf ${HOME}/.cache/pants/lmdb_store - # Render a summary of what is left in the home directory, to assist with further pruning of - # the cache. - - du -m -d2 ${HOME} | sort -r -n - -cache: - # The default timeout is 180 seconds, and our larger cache uploads exceed this. - # TODO: Figure out why we have such large caches (2-7GB) and try to trim them. - timeout: 500 - directories: - - ${HOME}/.cache/pants - - ${HOME}/.ivy2/pants - # TODO(John Sirois): Update this to ~/.npm/pants when pants starts - # using its own isolated cache: - # https://github.com/pantsbuild/pants/issues/2485 - - ${HOME}/.npm - - build-support/pants_dev_deps.venv - - src/rust/engine/target + - BOOTSTRAPPED_PEX_KEY_PREFIX=${TRAVIS_BUILD_NUMBER}/${TRAVIS_BUILD_ID}/pants.pex + - BOOTSTRAPPED_PEX_URL_PREFIX=s3://${BOOTSTRAPPED_PEX_BUCKET}/${BOOTSTRAPPED_PEX_KEY_PREFIX} # Stages are documented here: https://docs.travis-ci.com/user/build-stages stages: @@ -73,7 +24,57 @@ stages: - name: &build_unstable Deploy Pants Pex Unstable if: tag IS NOT present AND type NOT IN (pull_request, cron) -default_test_config: &default_test_config +# Travis cache config for jobs that build the native engine. +native_engine_cache_config: &native_engine_cache_config + before_cache: + # Ensure permissions to do the below removals, which happen with or without caching enabled. + - sudo chown -R travis:travis "${HOME}" "${TRAVIS_BUILD_DIR}" + # Kill all python bytecode in our cached venvs. Some files appear to + # get bytecode compiled in non-yet-understood circumstances leading to + # a full cache re-pack due to new bytecode files. + - find build-support -name "*.py[co]" -delete + cache: + # The default timeout is 180 seconds, and our larger cache uploads exceed this. + # TODO: Figure out why we have such large caches (2-7GB) and try to trim them. + timeout: 500 + directories: + - ${HOME}/.cache/pants/rust/cargo + - build-support/pants_dev_deps.venv + - src/rust/engine/target + +# Travis cache config for jobs that run a bootstrapped pants.pex. +pants_run_cache_config: &pants_run_cache_config + before_cache: + # Ensure permissions to do the below removals, which happen with or without caching enabled. + - sudo chown -R travis:travis "${HOME}" "${TRAVIS_BUILD_DIR}" + # The `ivydata-*.properties` & root level `*.{properties,xml}` files' + # effect on resolution time is in the noise, but they are + # re-timestamped in internal comments and fields on each run and this + # leads to travis-ci cache thrash. Kill these files before the cache + # check to avoid un-needed cache re-packing and re-upload (a ~100s + # operation). + - find ${HOME}/.ivy2/pants -type f -name "ivydata-*.properties" -delete + - rm -f ${HOME}/.ivy2/pants/*.{css,properties,xml,xsl} + # We have several tests that do local file:// url resolves for + # com.example artifacts, these disrupt the cache but are fast since + # they're resolved from local files when omitted from the cache. + - rm -rf ${HOME}/.ivy2/pants/com.example + # Render a summary to assist with further tuning the cache. + - du -m -d2 ${HOME}/.cache/pants | sort -r -n + cache: + # The default timeout is 180 seconds, and our larger cache uploads exceed this. + # TODO: Figure out why we have such large caches (2-7GB) and try to trim them. + timeout: 500 + directories: + - ${HOME}/.cache/pants/tools + - ${HOME}/.cache/pants/zinc + - ${HOME}/.ivy2/pants + # TODO(John Sirois): Update this to ~/.npm/pants when pants starts + # using its own isolated cache: + # https://github.com/pantsbuild/pants/issues/2485 + - ${HOME}/.npm + +default_linux_config: &default_linux_config os: linux dist: xenial sudo: required @@ -87,29 +88,42 @@ default_test_config: &default_test_config - python-dev - openssl - libssl-dev - stage: *test + - jq + - unzip language: python python: &python_version "2.7" before_install: -{{>before_install}} - before_script: - - ./build-support/bin/get_ci_bootstrapped_pants_pex.sh ${BOOTSTRAPPED_PEX_BUCKET} ${BOOTSTRAPPED_PEX_KEY} + - ./build-support/bin/install_aws_cli_for_ci.sh + after_failure: + - ./build-support/bin/ci-failure.sh +default_linux_test_config: &default_linux_test_config + <<: *default_linux_config + <<: *pants_run_cache_config + stage: *test + before_install: + {{>before_install_linux}} + before_script: + - ./build-support/bin/get_ci_bootstrapped_pants_pex.sh ${BOOTSTRAPPED_PEX_BUCKET} ${BOOTSTRAPPED_PEX_KEY_PREFIX}.linux -osx_test_config: &osx_test_config +default_osx_config: &default_osx_config os: osx - stage: *test language: generic - script: - - MODE=debug ./build-support/bin/travis-ci.sh -m + before_install: + {{>before_install_osx}} -default_cron_test_config: &default_cron_test_config - <<: *default_test_config - stage: *cron +default_osx_test_config: &default_osx_test_config + <<: *default_osx_config + <<: *pants_run_cache_config + stage: *test + before_script: + - ulimit -c unlimited + - ulimit -n 8192 + - ./build-support/bin/get_ci_bootstrapped_pants_pex.sh ${BOOTSTRAPPED_PEX_BUCKET} ${BOOTSTRAPPED_PEX_KEY_PREFIX}.osx linux_with_fuse: &linux_with_fuse before_install: -{{>before_install}} + {{>before_install_linux}} - sudo apt-get install -y pkg-config fuse libfuse-dev - sudo modprobe fuse - sudo chmod 666 /dev/fuse @@ -117,70 +131,100 @@ linux_with_fuse: &linux_with_fuse matrix: include: - - <<: *default_test_config - name: "Bootstrap Pants" + - <<: *default_linux_config + <<: *native_engine_cache_config + name: "Build Linux native engine and pants.pex" stage: *bootstrap + services: + - docker + env: + - CACHE_NAME=linuxpexbuild + - PREPARE_DEPLOY=1 # To deploy fs_util. before_script: + - ulimit -c unlimited script: - - ./build-support/bin/travis-ci.sh # With no args this script just bootstraps. - - aws --no-sign-request --region us-east-1 s3 cp ./pants.pex ${BOOTSTRAPPED_PEX_URL} + - docker build --rm -t travis_ci + --build-arg "TRAVIS_USER=$(id -un)" + --build-arg "TRAVIS_UID=$(id -u)" + --build-arg "TRAVIS_GROUP=$(id -gn)" + --build-arg "TRAVIS_GID=$(id -g)" + build-support/docker/travis_ci/ + # Note that: + # * We mount ${HOME} to cache the ${HOME}/.cache/pants/rust-toolchain. + # * With no args ci.sh just bootstraps a pants.pex. + # * We also build fs_util, to take advantage of the rust code built during bootstrapping. + - docker run --rm -t + -v "${HOME}:/travis/home" + -v "${TRAVIS_BUILD_DIR}:/travis/workdir" + travis_ci:latest + sh -c "git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f" + - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.linux # Build macOS engine - - name: "OSX Native Engine Binary Builder" - os: osx + - <<: *default_osx_config + <<: *native_engine_cache_config + name: "Build OSX native engine and pants.pex" + stage: *bootstrap # We request the oldest image we can (corresponding to OSX 10.11) for maximum compatibility. # We use 10.11 as a minimum to avoid https://github.com/rust-lang/regex/issues/489. # See: https://docs.travis-ci.com/user/reference/osx/#OS-X-Version osx_image: xcode8 + env: + - CACHE_NAME=macospexbuild + - PREPARE_DEPLOY=1 # To deploy fs_util. + script: + # With no args ci.sh just bootstraps a pants.pex. We also build fs_util, to take advantage + # of the rust code built during bootstrapping. + - git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f + - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.osx + after_failure: + - ./build-support/bin/ci-failure.sh + + - <<: *default_linux_test_config + name: "Build Linux wheels" stage: *test - language: generic env: + - CACHE_NAME=linuxwheelsbuild + - RUN_PANTS_FROM_PEX=1 + - PREPARE_DEPLOY=1 + script: + - ./build-support/bin/release.sh -n + + - <<: *default_osx_test_config + name: "Build OSX wheels" + osx_image: xcode8 + env: + - CACHE_NAME=osxwheelsbuild + - RUN_PANTS_FROM_PEX=1 - PREPARE_DEPLOY=1 script: - - ./pants --version && ./build-support/bin/release.sh -n + - ./build-support/bin/release.sh -n # TODO: Update this to use 10.14 once it is available - - name: "OSX 10.12 Sanity Check" - <<: *osx_test_config + - <<: *default_osx_test_config + name: "OSX 10.12 sanity check" osx_image: xcode9.2 + env: + - CACHE_NAME=macos10.12sanity + script: + - MODE=debug ./build-support/bin/travis-ci.sh -bm - - name: "OSX 10.13 Sanity Check" - <<: *osx_test_config + - <<: *default_osx_test_config + name: "OSX 10.13 sanity check" osx_image: xcode10.1 - - # Build Linux engine - - name: "Linux Native Engine Binary Builder" - os: linux - stage: *test - language: generic - services: - - docker env: - - PREPARE_DEPLOY=1 - before_script: - - ulimit -c unlimited + - CACHE_NAME=macos10.13sanity script: - - docker build --rm -t travis_ci - --build-arg "TRAVIS_USER=$(id -un)" - --build-arg "TRAVIS_UID=$(id -u)" - --build-arg "TRAVIS_GROUP=$(id -gn)" - --build-arg "TRAVIS_GID=$(id -g)" - build-support/docker/travis_ci/ - # Mount ${HOME} to cache the ${HOME}/.cache/pants/rust-toolchain - - docker run --rm -t - -v "${HOME}:/travis/home" - -v "${TRAVIS_BUILD_DIR}:/travis/workdir" - travis_ci:latest - sh -c "git clean -xfd && ./pants --version && ./build-support/bin/release.sh -n" - after_failure: - - build-support/bin/ci-failure.sh + - MODE=debug ./build-support/bin/travis-ci.sh -bm # Deploy Pex Stable - - name: "Deploy Pants PEX" + - name: "Deploy stable multiplatform pants.pex" os: linux language: python stage: *build_stable env: + - CACHE_NAME=linuxpexdeploystable + - RUN_PANTS_FROM_PEX=1 - PANTS_PEX_RELEASE=stable script: - ./build-support/bin/release.sh -p @@ -199,55 +243,68 @@ matrix: repo: pantsbuild/pants # Deploy Pex Unstable to s3 - - name: "Deploy Pants PEX Unstable" + - name: "Deploy unstable multiplatform pants.pex" os: linux language: python stage: *build_unstable env: + - CACHE_NAME=linuxpexdeployunstable + - RUN_PANTS_FROM_PEX=1 - PREPARE_DEPLOY=1 script: - ./build-support/bin/release.sh -p && mkdir -p dist/deploy/pex/ && mv dist/pants*.pex dist/deploy/pex/ - - <<: *default_test_config + - <<: *default_linux_test_config <<: *linux_with_fuse - name: "Self checks, lint, and JVM tests" + name: "Self-checks, lint, and JVM tests" + env: + - CACHE_NAME=linuxselfchecks script: - - ./build-support/bin/travis-ci.sh -fbkmrjt + - ./build-support/bin/travis-ci.sh -fbmrjt - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py2 - Unit tests for pants and pants-plugins" + env: + - CACHE_NAME=linuxunittests.py2 script: - ./build-support/bin/travis-ci.sh -blp - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py3 - Unit tests for pants and pants-plugins" + env: + - CACHE_NAME=linuxunittests.py3 script: - ./build-support/bin/travis-ci.sh -3blp - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py2 - Python contrib tests" + env: + - CACHE_NAME=linuxcontribtests.py2 script: - ./build-support/bin/travis-ci.sh -bn - - <<: *default_test_config + - <<: *default_linux_test_config name: "Py3 - Python contrib tests" + env: + - CACHE_NAME=linuxcontribtests.py3 script: - ./build-support/bin/travis-ci.sh -3bn {{#integration_shards}} - - <<: *default_test_config + - <<: *default_linux_test_config name: "Integration tests for pants - shard {{.}}" env: - - CACHE_NAME=integrationshard{{.}} # Ensure distinct caches. + - CACHE_NAME=integrationshard{{.}} script: - ./build-support/bin/travis-ci.sh -bc3 -i {{.}}/{{integration_shards_length}} {{/integration_shards}} {{#integration_shards}} - - <<: *default_cron_test_config + - <<: *default_linux_test_config name: "Integration tests for pants (Python 2) - shard {{.}}" + stage: *cron env: - - CACHE_NAME=cronshard{{.}} # Ensure distinct caches. + - CACHE_NAME=cronshard{{.}} script: - ./build-support/bin/travis-ci.sh -bc -i {{.}}/{{integration_shards_length}} @@ -255,7 +312,9 @@ matrix: # Rust on linux - <<: *linux_with_fuse - name: "Rust Tests Linux" + name: "Linux Rust tests" + env: + - CACHE_NAME=linuxrusttests os: linux dist: xenial sudo: required @@ -267,26 +326,25 @@ matrix: - ulimit -n 8192 script: - ./build-support/bin/travis-ci.sh -be + # Rust on macOS - - name: "Rust + Platform-specific Tests OSX" - os: osx + - <<: *default_osx_test_config + name: "OSX Rust + platform-specific tests" + env: + - CACHE_NAME=macosrusttests # Fuse actually works on this image. It hangs on many others. osx_image: xcode8.3 - stage: *test - language: generic before_install: + {{>before_install_osx}} - brew tap caskroom/cask && brew update && brew cask install osxfuse - before_script: - - ulimit -c unlimited - - ulimit -n 8192 script: - # Platform-specific tests currently need a pants pex, so we bootstrap here (no -b) and - # set -z to run the platform-specific tests. - - ./build-support/bin/travis-ci.sh -ez + - ./build-support/bin/travis-ci.sh -bez # Rust Clippy on Linux - <<: *linux_with_fuse - name: "Rust Clippy on Linux" + name: "Linux Rust Clippy" + env: + - CACHE_NAME=linuxclippy os: linux dist: xenial sudo: required @@ -302,6 +360,8 @@ matrix: # Cargo audit - <<: *linux_with_fuse name: "Cargo audit" + env: + - CACHE_NAME=linuxcargoaudit os: linux dist: xenial sudo: required @@ -310,6 +370,7 @@ matrix: - ./build-support/bin/travis-ci.sh -ba deploy: + # Deploy whatever a previous stage has left in dist/deploy. # See: https://docs.travis-ci.com/user/deployment/s3/ provider: s3 access_key_id: AKIAIWOKBXVU3JLY6EGQ diff --git a/src/python/pants/releases/packages.py b/src/python/pants/releases/packages.py index 5218f493337..623c66b7ec1 100644 --- a/src/python/pants/releases/packages.py +++ b/src/python/pants/releases/packages.py @@ -182,7 +182,7 @@ def build_and_print_packages(version): packages_by_flags[package.bdist_wheel_flags].append(package) for (flags, packages) in packages_by_flags.items(): - args = ("./pants", "-q", "setup-py", "--run=bdist_wheel {}".format(" ".join(flags))) + tuple(package.target for package in packages) + args = ("./pants.pex", "-q", "setup-py", "--run=bdist_wheel {}".format(" ".join(flags))) + tuple(package.target for package in packages) try: subprocess.check_call(args) for package in packages: From 7aff577680d2bb1f35d871146383aecdfcd92ba5 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Wed, 9 Jan 2019 09:22:32 -0500 Subject: [PATCH 2/4] Address code review comments. --- .travis.yml | 2 ++ build-support/bin/release.sh | 2 +- build-support/travis/travis.yml.mustache | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8f777354e8f..f0f6661e345 100644 --- a/.travis.yml +++ b/.travis.yml @@ -609,6 +609,7 @@ matrix: # Rust on linux - <<: *linux_with_fuse + - <<: *native_engine_cache_config name: "Linux Rust tests" env: - CACHE_NAME=linuxrusttests @@ -641,6 +642,7 @@ matrix: # Rust Clippy on Linux - <<: *linux_with_fuse + - <<: *native_engine_cache_config name: "Linux Rust Clippy" env: - CACHE_NAME=linuxclippy diff --git a/build-support/bin/release.sh b/build-support/bin/release.sh index 82642eb9f2f..2df73d4216c 100755 --- a/build-support/bin/release.sh +++ b/build-support/bin/release.sh @@ -137,7 +137,7 @@ function pants_version_reset() { } function pants_version_set() { - # Set the version in the wheels we build by mutating `src/python/pants/VERSION` to temporarily + # Set the version in the wheels we build by mutating `src/python/pants/VERSION` to temporarily # override it. Sets a `trap` to restore to HEAD on exit. local version=$1 trap pants_version_reset EXIT diff --git a/build-support/travis/travis.yml.mustache b/build-support/travis/travis.yml.mustache index 61056c30fc8..cc1c360c2e8 100644 --- a/build-support/travis/travis.yml.mustache +++ b/build-support/travis/travis.yml.mustache @@ -312,6 +312,7 @@ matrix: # Rust on linux - <<: *linux_with_fuse + - <<: *native_engine_cache_config name: "Linux Rust tests" env: - CACHE_NAME=linuxrusttests @@ -342,6 +343,7 @@ matrix: # Rust Clippy on Linux - <<: *linux_with_fuse + - <<: *native_engine_cache_config name: "Linux Rust Clippy" env: - CACHE_NAME=linuxclippy From 697f8ac01c7027610c7b09c5723c866a47316b5f Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Wed, 9 Jan 2019 09:25:45 -0500 Subject: [PATCH 3/4] Remove git clean fdx. --- .travis.yml | 4 ++-- build-support/travis/travis.yml.mustache | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f0f6661e345..8db7cae1ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -173,7 +173,7 @@ matrix: -v "${HOME}:/travis/home" -v "${TRAVIS_BUILD_DIR}:/travis/workdir" travis_ci:latest - sh -c "git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f" + sh -c "./build-support/bin/ci.sh && ./build-support/bin/release.sh -f" - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.linux # Build macOS engine @@ -191,7 +191,7 @@ matrix: script: # With no args ci.sh just bootstraps a pants.pex. We also build fs_util, to take advantage # of the rust code built during bootstrapping. - - git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f + - ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.osx after_failure: - ./build-support/bin/ci-failure.sh diff --git a/build-support/travis/travis.yml.mustache b/build-support/travis/travis.yml.mustache index cc1c360c2e8..747ff9472df 100644 --- a/build-support/travis/travis.yml.mustache +++ b/build-support/travis/travis.yml.mustache @@ -157,7 +157,7 @@ matrix: -v "${HOME}:/travis/home" -v "${TRAVIS_BUILD_DIR}:/travis/workdir" travis_ci:latest - sh -c "git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f" + sh -c "./build-support/bin/ci.sh && ./build-support/bin/release.sh -f" - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.linux # Build macOS engine @@ -175,7 +175,7 @@ matrix: script: # With no args ci.sh just bootstraps a pants.pex. We also build fs_util, to take advantage # of the rust code built during bootstrapping. - - git clean -xfd && ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f + - ./build-support/bin/ci.sh && ./build-support/bin/release.sh -f - aws --no-sign-request --region us-east-1 s3 cp ${TRAVIS_BUILD_DIR}/pants.pex ${BOOTSTRAPPED_PEX_URL_PREFIX}.osx after_failure: - ./build-support/bin/ci-failure.sh From 0da572f832a3a4d94f0db0dd9ddcdb2154e3fc49 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Wed, 9 Jan 2019 10:49:03 -0500 Subject: [PATCH 4/4] WIP --- .travis.yml | 4 ++-- build-support/travis/travis.yml.mustache | 4 ++-- src/python/pants/releases/packages.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8db7cae1ffa..5e3f822bf1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -609,7 +609,7 @@ matrix: # Rust on linux - <<: *linux_with_fuse - - <<: *native_engine_cache_config + <<: *native_engine_cache_config name: "Linux Rust tests" env: - CACHE_NAME=linuxrusttests @@ -642,7 +642,7 @@ matrix: # Rust Clippy on Linux - <<: *linux_with_fuse - - <<: *native_engine_cache_config + <<: *native_engine_cache_config name: "Linux Rust Clippy" env: - CACHE_NAME=linuxclippy diff --git a/build-support/travis/travis.yml.mustache b/build-support/travis/travis.yml.mustache index 747ff9472df..e4f544eb98d 100644 --- a/build-support/travis/travis.yml.mustache +++ b/build-support/travis/travis.yml.mustache @@ -312,7 +312,7 @@ matrix: # Rust on linux - <<: *linux_with_fuse - - <<: *native_engine_cache_config + <<: *native_engine_cache_config name: "Linux Rust tests" env: - CACHE_NAME=linuxrusttests @@ -343,7 +343,7 @@ matrix: # Rust Clippy on Linux - <<: *linux_with_fuse - - <<: *native_engine_cache_config + <<: *native_engine_cache_config name: "Linux Rust Clippy" env: - CACHE_NAME=linuxclippy diff --git a/src/python/pants/releases/packages.py b/src/python/pants/releases/packages.py index 623c66b7ec1..5218f493337 100644 --- a/src/python/pants/releases/packages.py +++ b/src/python/pants/releases/packages.py @@ -182,7 +182,7 @@ def build_and_print_packages(version): packages_by_flags[package.bdist_wheel_flags].append(package) for (flags, packages) in packages_by_flags.items(): - args = ("./pants.pex", "-q", "setup-py", "--run=bdist_wheel {}".format(" ".join(flags))) + tuple(package.target for package in packages) + args = ("./pants", "-q", "setup-py", "--run=bdist_wheel {}".format(" ".join(flags))) + tuple(package.target for package in packages) try: subprocess.check_call(args) for package in packages: