Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Makefile/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
  2. # This copyright was auto-generated on Wed Jan 5 23:22:12 UTC 2022
  3. # This must be run from the directory it exists in.
  4. SHELL := bash
  5. PACKAGE_DIR := tutorial_modules
  6. REPORTS_DIR := reports
  7. ######################################### General ############################################################
  8. .PHONY: help
  9. help: ## Display this help which is generated from Make goal comments
  10. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  11. .PHONY: all
  12. all: clean format lint tests docs build ## Clean everything, then format code, lint, run tests, build docs, and build package
  13. .PHONY: clean_artifacts
  14. clean_artifacts:
  15. @echo "Cleaning artifacts..."
  16. @$$(find . -type f -name '*.py[co]' -delete -o -type d -name '__pycache__' -delete)
  17. @$$(find . -type f -name '*.log' -delete)
  18. @$$(find . -type f -name '*.jpg' -delete)
  19. @$$(find . -type f -name '*.mp4' -delete)
  20. @$$(find . -type f -name '*.JPG' -delete)
  21. @$$(find . -type f -name '*.MP4' -delete)
  22. @$$(find . -type f -name '*.csv' -delete)
  23. @$$(find . -type f -name '*.gpmf' -delete)
  24. @rm -rf .mypy_cache
  25. .PHONY: clean
  26. clean: clean_artifacts clean_tests ## Clean tests, docs, and build
  27. .PHONY: reports
  28. reports: ## Make the reports dir if it doesn't exist
  29. @mkdir -p ${REPORTS_DIR}
  30. ########################################## Testing ###########################################################
  31. .PHONY: clean_tests
  32. clean_tests: ## Clean raw coverage and html results
  33. @echo "Cleaning tests..."
  34. @rm -rf ${REPORTS_DIR}
  35. @rm -rf .pytest_cache
  36. @rm -f .coverage
  37. .PHONY: tests
  38. tests: clean_tests ## Run all tests (unit, e2e, and demos) and calculate coverage.
  39. @echo "Running all tests..."
  40. @pytest tests
  41. ###################################### Static Code Analyis ###################################################
  42. .PHONY: format
  43. format: ## Run Black to format code
  44. @echo "Running black to format all python code..."
  45. @black --line-length 111 tutorial_modules tests setup.py
  46. .PHONY: lint
  47. lint: reports ## Run mypy for static typing analysis and pylint for linting
  48. @echo "Performing static typing analysis..."
  49. @set -o pipefail; mypy ${PACKAGE_DIR} | tee ${REPORTS_DIR}/linting
  50. @echo "Linting..."
  51. @set -o pipefail; pylint ${PACKAGE_DIR} | tee -a ${REPORTS_DIR}/linting