check_for_website_dead_links.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # arg is path to website root source directory
  18. # e.g.
  19. # docs/docs-site
  20. # docs/gethue
  21. #
  22. # https://github.com/raviqqe/muffet
  23. # go get -u github.com/raviqqe/muffet
  24. #
  25. # We lower the concurrency and whitelist Jiras to avoid hammering the external sites.
  26. SOURCE=${1:-"docs/docs-site"}
  27. LINT_EXIT_CODE=1
  28. git diff --name-only origin/master --diff-filter=b | egrep "^$SOURCE"
  29. if [ "$?" -eq "0" ];
  30. then
  31. cd $1
  32. echo $PATH
  33. hugo serve&
  34. HUGO_PID=$!
  35. sleep 5
  36. muffet http://localhost:1313/ \
  37. --exclude "https://issues.cloudera.org*|http://localhost:8005|http://localhost:5555*|https://issues.apache.org/jira*|https://github.com*\
  38. |http://demo.gethue.com*|https://twitter.com/gethue|https://github.com*|https://cdn.gethue.com/downloads/*" \
  39. --ignore-fragments \
  40. --timeout 15 \
  41. --concurrency 10
  42. LINT_EXIT_CODE=$?
  43. kill $HUGO_PID
  44. else
  45. echo "No documentation change"
  46. LINT_EXIT_CODE=0
  47. fi
  48. exit $LINT_EXIT_CODE