testbuilder.sh 962 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. # Download, build and run a docker project tests
  3. # Environment variables: DEPLOYMENT
  4. cat $0
  5. set -e
  6. set -x
  7. PROJECT=$1
  8. COMMIT=${2-HEAD}
  9. REPO=${3-https://github.com/dotcloud/$PROJECT}
  10. BRANCH=${4-master}
  11. REPO_PROJ="https://github.com/docker-test/$PROJECT"
  12. if [ "$DEPLOYMENT" == "production" ]; then
  13. REPO_PROJ="https://github.com/dotcloud/$PROJECT"
  14. fi
  15. set +x
  16. # Generate a random string of $1 characters
  17. function random {
  18. cat /dev/urandom | tr -cd 'a-f0-9' | head -c $1
  19. }
  20. PROJECT_PATH="$PROJECT-tmp-$(random 12)"
  21. # Set docker-test git user
  22. set -x
  23. git config --global user.email "docker-test@docker.io"
  24. git config --global user.name "docker-test"
  25. # Fetch project
  26. git clone -q $REPO_PROJ -b master /data/$PROJECT_PATH
  27. cd /data/$PROJECT_PATH
  28. echo "Git commit: $(git rev-parse HEAD)"
  29. git fetch -q $REPO $BRANCH
  30. git merge --no-edit $COMMIT
  31. # Build the project dockertest
  32. /testbuilder/$PROJECT.sh $PROJECT_PATH
  33. rm -rf /data/$PROJECT_PATH