Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Set variable matching to current user who launch this script
  4. export HOST_UID_GID=$(id -u):$(id -g)
  5.  
  6. # Set variable define custom name related to Project/Server/Branch/Buid_number
  7. # used by docker to have custom instances and network name
  8. COMPOSE_ID=${JOB_NAME:-local}
  9.  
  10. #
  11. # Runs the django in an isolated docker-compose environment and runs
  12. # our test suite in a container. At the end, everything is cleaned up :)
  13. #
  14. printf "Search and destroy previously running instances of the django env. ...\n"
  15. docker-compose -p $COMPOSE_ID rm -f
  16.  
  17. printf "Starting the django environment (MySQL + Django)...\n"
  18. docker-compose -p $COMPOSE_ID up --build --abort-on-container-exit --timeout 120
  19.  
  20. # Let's retrieve the exit code of the previous command (0 if all tests
  21. # passed successfully)
  22. test_status=$?
  23.  
  24. # Let's give some feedback about the tests to our user. In particular, let's
  25. # show him the docker-compose logs in case a failure occured, this should make
  26. # debugging much easier.
  27. if [ "$test_status" -eq "0" ]; then
  28. printf "\n\n\n"
  29. printf "TEST SUITE RAN SUCCESSFULLY ON DJANGO !!\n"
  30. printf " <3 <3 <3 FEEL FREE TO MERGE <3 <3 <3\n"
  31. printf "\n\n\n"
  32. exit 0
  33. else
  34. printf "END-TO-END TEST SUITE FAILED ON DJANGO !!\n"
  35. printf "BEWARE, your code might be flaky somehow. Don't deploy on production unless you're perfectly aware of what you're doing...\n"
  36. printf "\n\n\n Here are the logs of your environment in case it helps \n\n\n"
  37. docker-compose -p $COMPOSE_ID logs
  38. printf "\n\n\n"
  39. exit 1
  40. fi
  41.  
  42. printf "Cleaning the Django environment..."
  43. docker-compose -p $COMPOSE_ID rm -f
  44.  
  45. # This exit code sets the status of the build. If it's 0, we'll see a
  46. # blue/green ball :)
  47. exit $test_status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement