From 091229b255f80d42ef42f05c28a68f1d555d68cd Mon Sep 17 00:00:00 2001 From: Les Vogel Date: Tue, 8 Aug 2017 18:57:59 -0700 Subject: [PATCH] breaking change (#796) * breaking change Try switching to circleci v2 * fix some spacing * add a workflow * remove workflows * indent fix. * skip backports and more. * maybe working * more stuff * weird errors * weird * remove whitespace * argh * more explicit path * change digest to md5 * fix travis path * Rookie errors * more rookie errors * try again * try and give me a service account * clean a few things up. * quick final info --- .circleci/circle.yml | 17 ----------------- .circleci/config.yml | 21 +++++++++++++++++++++ travis.sh | 37 +++++++++++++++++++------------------ 3 files changed, 40 insertions(+), 35 deletions(-) delete mode 100644 .circleci/circle.yml create mode 100644 .circleci/config.yml diff --git a/.circleci/circle.yml b/.circleci/circle.yml deleted file mode 100644 index e397f27704d..00000000000 --- a/.circleci/circle.yml +++ /dev/null @@ -1,17 +0,0 @@ -machine: - java: - version: oraclejdk8 -dependencies: - pre: - - curl -LO https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz - && sudo tar -zxf geckodriver-*.tar.gz -C "${HOME}/bin" - - sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe" - && sudo apt-get update - && sudo apt-get install -t trusty-backports shellcheck - - sudo apt-get install expect - - openssl aes-256-cbc -d -in "${HOME}/${CIRCLE_PROJECT_REPONAME}/service-account.json.enc" -k "${key}" -iv "${iv}" -out "${HOME}/google-cloud-service-key.json" - - export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/google-cloud-service-key.json" -test: - override: - - bash ./travis.sh && - bash <(curl -s https://codecov.io/bash) # If successful, run code coverage diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..ba507ad0e40 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,21 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/openjdk:8-jdk-browsers + steps: + - checkout + - run: + name: get shellcheck expect + command: sudo apt-get update && sudo apt-get install shellcheck expect + - run: + name: service account + command: openssl aes-256-cbc -d -md md5 -in "${HOME}/project/service-account.json.enc" -k "${key}" -iv "${iv}" -out "${HOME}/google-cloud-service-key.json" && echo 'export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/google-cloud-service-key.json"' >> $BASH_ENV + - run: + name: test script + command: bash "${HOME}/project/travis.sh" && bash <(curl -s https://codecov.io/bash) # If successful, run code coverage + +# - run: +# name: Gecko Driver +# command: curl -LO https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz && sudo tar -zxf geckodriver-*.tar.gz -C "${HOME}/bin" + diff --git a/travis.sh b/travis.sh index 713c32a8493..f630207a13b 100755 --- a/travis.sh +++ b/travis.sh @@ -15,18 +15,19 @@ set -e -# Setup GCP application default credentials before `set -x` echos everything out -if [[ $GCLOUD_SERVICE_KEY ]]; then - echo "$GCLOUD_SERVICE_KEY" | \ - base64 --decode --ignore-garbage > "${HOME}/google-cloud-service-key.json" - export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/google-cloud-service-key.json" -fi +cd "${HOME}/project" # lv3 8/8/17 set -x # Set pipefail so that `egrep` does not eat the exit code. set -o pipefail shopt -s globstar +echo "GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}" +echo "CI_PULL_REQUEST: ${CI_PULL_REQUEST}" +echo "CIRCLE_BRANCH: ${CIRCLE_BRANCH}" +echo "git rev-parse HEAD: $(git rev-parse HEAD)" +echo "CIRCLE_PR_NUMBER: ${CIRCLE_PR_NUMBER}" +echo "CIRCLE_PR_USERNAME: ${CIRCLE_PR_USERNAME}" SKIP_TESTS=false if [ -z "$GOOGLE_APPLICATION_CREDENTIALS" ] ; then @@ -35,22 +36,22 @@ fi # Finds the closest parent dir that encompasses all changed files, and has a # pom.xml -travis_changed_files_parent() { +changed_files_parent() { # If we're not in a PR, forget it - [ -z "${TRAVIS_PULL_REQUEST-CI_PULL_REQUEST}" ] && return 0 + [ -z "${CI_PULL_REQUEST}" ] && return 0 ( set +e - changed="$(git diff --name-only "${TRAVIS_COMMIT-CIRCLE_SHA1}" "${TRAVIS_BRANCH-CIRCLE_BRANCH}")" + changed="$(git diff --name-only ${CIRCLE_SHA1} ${CIRCLE_BRANCH})" if [ $? -ne 0 ]; then # Fall back to git head - changed="$(git diff --name-only "$(git rev-parse HEAD)" "${TRAVIS_BRANCH-CIRCLE_BRANCH}")" + changed="$(git diff --name-only $(git rev-parse HEAD) ${CIRCLE_BRANCH})" [ $? -ne 0 ] && return 0 # Give up. Just run everything. fi # Find the common prefix - prefix="$(echo "$changed" | \ + prefix="$(echo $changed | sed -e 'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D')" # N: Do this for a pair of lines # s: capture the beginning of a line, that's followed by a new line # starting with that capture group. IOW - two lines that start with the @@ -58,7 +59,6 @@ travis_changed_files_parent() { # (ie the common prefix). # D: Delete the first line of the pair, leaving the second line for the # next pass. - sed -e 'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D')" while [ ! -z "$prefix" ] && [ ! -r "$prefix/pom.xml" ] && [ "${prefix%/*}" != "$prefix" ]; do prefix="${prefix%/*}" @@ -70,19 +70,20 @@ travis_changed_files_parent() { ) } -common_travis_dir="$(travis_changed_files_parent)" +common_dir="$(changed_files_parent)" + +echo "Common Dir: ${common_dir}" -[ -z "$common_travis_dir" ] || pushd "$common_travis_dir" +[ -z "${common_dir}" ] || pushd "${common_dir}" # Give Maven a bit more memory -#export MAVEN_OPTS='-XX:+PrintFlagsFinal -Xmx800m -Xms400m' export MAVEN_OPTS='-Xmx800m -Xms400m' -"${TRAVIS_BUILD_DIR-$HOME/$CIRCLE_PROJECT_REPONAME}"/mvnw \ +mvn \ --batch-mode clean verify -e \ -DskipTests=$SKIP_TESTS | \ egrep -v "(^\[INFO\] Download|^\[INFO\].*skipping)" -[ -z "$common_travis_dir" ] || popd +[ -z "$common_dir" ] || popd # Check that all shell scripts in this repo (including this one) pass the # Shell Check linter. @@ -99,7 +100,7 @@ test_localhost() { appengine/datastore/indexes-perfect ) for testdir in "${devserver_tests[@]}" ; do - if [ -z "$common_travis_dir" ] || [[ $testdir = $common_travis_dir* ]]; then + if [ -z "$common_dir" ] || [[ $testdir = $common_dir* ]]; then ./java-repo-tools/scripts/test-localhost.sh appengine "${testdir}" fi done