travis.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. set -e
  3. cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. repos=( --all )
  5. extraCommands=
  6. upstreamRepo='docker-library/official-images'
  7. upstreamBranch='master'
  8. if [ "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then
  9. upstreamRepo="$TRAVIS_REPO_SLUG"
  10. upstreamBranch="$TRAVIS_BRANCH"
  11. fi
  12. HEAD="$(git rev-parse --verify HEAD)"
  13. git fetch -q "https://github.com/$upstreamRepo.git" "refs/heads/$upstreamBranch"
  14. UPSTREAM="$(git rev-parse --verify FETCH_HEAD)"
  15. if [ "$TRAVIS_BRANCH" = 'master' -a "$TRAVIS_PULL_REQUEST" = 'false' ]; then
  16. # if we're testing master itself, RUN ALL THE THINGS
  17. echo >&2 'Testing master -- BUILD ALL THE THINGS!'
  18. elif [ "$(git diff --numstat "$UPSTREAM...$HEAD" -- . | wc -l)" -ne 0 ]; then
  19. # changes in bashbrew/ -- keep "--all" so we test the bashbrew script changes appropriately
  20. echo >&2 'Changes in bashbrew/ detected!'
  21. extraCommands=1
  22. else
  23. repos=( $(git diff --numstat "$UPSTREAM...$HEAD" -- ../library | awk -F '/' '{ print $2 }') )
  24. extraCommands=1
  25. fi
  26. if [ "${#repos[@]}" -eq 0 ]; then
  27. echo >&2 'Skipping test builds: no changes to library/ or bashbrew/ in PR'
  28. exit
  29. fi
  30. export BASHBREW_LIBRARY="$(dirname "$PWD")/library"
  31. cmds=(
  32. 'list'
  33. 'list --uniq'
  34. 'cat'
  35. )
  36. if [ "$extraCommands" ]; then
  37. cmds+=(
  38. 'list --build-order'
  39. 'from'
  40. )
  41. fi
  42. export PS4=$'\n\n$ '
  43. for cmd in "${cmds[@]}"; do
  44. ( set -x && bashbrew $cmd "${repos[@]}" )
  45. done
  46. echo; echo