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.

66 lines
1.6 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. echo "checking if /json was changed..."
  19. if egrep "\+{3}\s.\/json\/" diff.txt > json.txt; then
  20. echo "JSON files are auto-generated! Please do not update these files:"
  21. cat json.txt
  22. exit 1
  23. else
  24. echo "/json check passed!"
  25. rm json.txt
  26. fi
  27. fi
  28. echo "checking if /json was changed..."
  29. egrep "\+{3}\s.\/json\/" diff.txt > json.txt
  30. if [[$? == 0]]; then
  31. echo "JSON files are auto-generated! Please do not update these files:"
  32. cat json.txt
  33. exit 1
  34. else
  35. echo "/json check passed!"
  36. rm json.txt
  37. fi
  38. echo "running format validation on $FORMAT_FILE..."
  39. ./validate_format.rb $FORMAT_FILE
  40. if [[ $? != 0 ]]; then
  41. echo "format validation failed!"
  42. exit 1
  43. else
  44. echo "format validation passed!"
  45. ./build.sh && ./deploy.sh
  46. if [[ $? != 0 ]]; then
  47. echo "JSON build and deploy failed!"
  48. else
  49. echo "JSON build and deploy success!"
  50. fi
  51. fi
  52. echo "running link validation..."
  53. ./validate_links.rb $LINK_FILE
  54. if [[ $? != 0 ]]; then
  55. echo "link validation failed!"
  56. exit 1
  57. else
  58. echo "link validation passed!"
  59. fi