You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

  1. #!/bin/bash
  2. FORMAT_FILE=../README.md
  3. if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
  4. echo "running on $TRAVIS_BRANCH branch"
  5. LINK_FILE=../README.md
  6. else
  7. echo "running on Pull Request #$TRAVIS_PULL_REQUEST"
  8. DIFF_URL="https://patch-diff.githubusercontent.com/raw/toddmotto/public-apis/pull/$TRAVIS_PULL_REQUEST.diff"
  9. curl $DIFF_URL > diff.txt
  10. echo "------- BEGIN DIFF -------"
  11. cat diff.txt
  12. echo "-------- END DIFF --------"
  13. cat diff.txt | egrep "\+" > additions.txt
  14. echo "------ BEGIN ADDITIONS -----"
  15. cat additions.txt
  16. echo "------- END ADDITIONS ------"
  17. LINK_FILE=additions.txt
  18. fi
  19. echo "checking if /json was changed..."
  20. egrep "\+{3}\s.\/json\/" diff.txt > json.txt
  21. if [[$? == 0]]; then
  22. echo "JSON files are auto-generated! Please do not update these files:"
  23. cat json.txt
  24. exit 1
  25. else
  26. echo "/json check passed!"
  27. rm json.txt
  28. fi
  29. echo "running format validation on $FORMAT_FILE..."
  30. ./validate_format.rb $FORMAT_FILE
  31. if [[ $? != 0 ]]; then
  32. echo "format validation failed!"
  33. exit 1
  34. else
  35. echo "format validation passed!"
  36. ./build.sh && ./deploy.sh
  37. if [[ $? != 0 ]]; then
  38. echo "JSON build and deploy failed!"
  39. else
  40. echo "JSON build and deploy success!"
  41. fi
  42. fi
  43. echo "running link validation..."
  44. ./validate_links.rb $LINK_FILE
  45. if [[ $? != 0 ]]; then
  46. echo "link validation failed!"
  47. exit 1
  48. else
  49. echo "link validation passed!"
  50. fi