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.
 
 
 

26 lines
756 B

  1. #!/bin/bash
  2. # This script is used by the CI to check if 'go generate ./...' is up to date.
  3. #
  4. # Note: If the generated files aren't up to date then this script updates
  5. # them despite printing an error message so running it the second time
  6. # might not print any errors. This isn't very useful locally during development
  7. # but it works well with the CI that downloads a fresh version of the repo
  8. # each time before executing this script.
  9. set -euo pipefail
  10. TEMP_DIR=$( mktemp -d )
  11. function cleanup() {
  12. rm -rf "${TEMP_DIR}"
  13. }
  14. trap cleanup EXIT
  15. cp -r . "${TEMP_DIR}/"
  16. go generate ./...
  17. if ! diff -r . "${TEMP_DIR}"; then
  18. echo
  19. echo "The generated files aren't up to date."
  20. echo "Update them with the 'go generate ./...' command."
  21. exit 1
  22. fi