travis.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 # TODO this takes a lot of load and often fails (force pushes to maintainer branches, etc)
  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. if badTags="$(bashbrew list "${repos[@]}" | grep -E ':.+latest.*|:.*latest.+')" && [ -n "$badTags" ]; then
  32. echo >&2
  33. echo >&2 "Incorrectly formatted 'latest' tags detected:"
  34. echo >&2 ' ' $badTags
  35. echo >&2
  36. echo >&2 'Read https://github.com/docker-library/official-images#tags-and-aliases for more details.'
  37. echo >&2
  38. exit 1
  39. fi
  40. if [ -n "$extraCommands" ] && naughtyFrom="$(../naughty-from.sh "${repos[@]}")" && [ -n "$naughtyFrom" ]; then
  41. echo >&2
  42. echo >&2 "Invalid 'FROM' + 'Architectures' combinations detected:"
  43. echo >&2
  44. echo >&2 "$naughtyFrom"
  45. echo >&2
  46. echo >&2 'Read https://github.com/docker-library/official-images#multiple-architectures for more details.'
  47. echo >&2
  48. exit 1
  49. fi
  50. _bashbrew() {
  51. echo $'\n\n$ bashbrew' "$@" "${repos[@]}"
  52. bashbrew "$@" "${repos[@]}"
  53. }
  54. _bashbrew list
  55. _bashbrew list --uniq
  56. _bashbrew cat
  57. if [ -n "$extraCommands" ]; then
  58. _bashbrew list --build-order
  59. _bashbrew from
  60. fi
  61. echo; echo