Skip to content

Commit

Permalink
breaking change (#796)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lesv authored Aug 9, 2017
1 parent 2055dc7 commit 091229b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
17 changes: 0 additions & 17 deletions .circleci/circle.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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"

37 changes: 19 additions & 18 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,30 +36,29 @@ 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
# same zero-or-more characters. Replace it with just the capture group
# (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%/*}"
Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 091229b

Please sign in to comment.