travis.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. set -e
  3. cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. repos=( --all )
  5. upstreamRepo='docker-library/official-images'
  6. upstreamBranch='master'
  7. if [ "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then
  8. upstreamRepo="$TRAVIS_REPO_SLUG"
  9. upstreamBranch="$TRAVIS_BRANCH"
  10. fi
  11. HEAD="$(git rev-parse --verify HEAD)"
  12. git fetch -q "https://github.com/$upstreamRepo.git" "refs/heads/$upstreamBranch"
  13. UPSTREAM="$(git rev-parse --verify FETCH_HEAD)"
  14. if [ "$TRAVIS_BRANCH" = 'master' -a "$TRAVIS_PULL_REQUEST" = 'false' ]; then
  15. # if we're testing master itself, RUN ALL THE THINGS
  16. echo >&2 'Testing master -- BUILD ALL THE THINGS!'
  17. elif [ "$(git diff --numstat "$UPSTREAM...$HEAD" -- . | wc -l)" -ne 0 ]; then
  18. # changes in bashbrew/ -- keep "--all" so we test the bashbrew script changes appropriately
  19. echo >&2 'Changes in bashbrew/ detected!'
  20. else
  21. repos=( $(git diff --numstat "$UPSTREAM...$HEAD" -- ../library | awk -F '/' '{ print $2 }') )
  22. fi
  23. if [ "${#repos[@]}" -eq 0 ]; then
  24. echo >&2 'Skipping test builds: no changes to library/ or bashbrew/ in PR'
  25. exit
  26. fi
  27. # --no-build because we has no Docker in Travis :)
  28. # TODO that will change eventually!
  29. set -x
  30. ./bashbrew.sh list --uniq "${repos[@]}"
  31. ./bashbrew.sh list "${repos[@]}"
  32. ./bashbrew.sh build --no-build "${repos[@]}"
  33. ./bashbrew.sh push --no-push "${repos[@]}"
  34. # TODO ./bashbrew.sh list "${repos[@]}" | xargs ../test/run.sh