|
| 1 | +SHELL := /bin/bash |
| 2 | +S3_BUCKET := SET-ME-PLEASE |
| 3 | +CLOUDFRONT_DISTRIBUTION_ID := SET-ME-PLEASE |
| 4 | + |
| 5 | +ifeq ($(OS),Windows_NT) |
| 6 | + PYTHON := python.exe |
| 7 | + ACTIVATE_VENV := venv\Scripts\activate |
| 8 | +else |
| 9 | + PYTHON := python3.13 |
| 10 | + ACTIVATE_VENV := source venv/bin/activate |
| 11 | +endif |
| 12 | +PIP := $(PYTHON) -m pip |
| 13 | + |
| 14 | + |
| 15 | +.PHONY: analyze pre-commit init lint clean help |
| 16 | + |
| 17 | +# Default target executed when no arguments are given to make. |
| 18 | +all: help |
| 19 | + |
| 20 | +analyze: |
| 21 | + cloc . --exclude-ext=svg,json,zip --vcs=git |
| 22 | + |
| 23 | + |
| 24 | +# ------------------------------------------------------------------------- |
| 25 | +# Install and run pre-commit hooks |
| 26 | +# ------------------------------------------------------------------------- |
| 27 | +pre-commit: |
| 28 | + pre-commit install |
| 29 | + pre-commit autoupdate |
| 30 | + pre-commit run --all-files |
| 31 | + |
| 32 | +# --------------------------------------------------------- |
| 33 | +# create python virtual environments for dev as well |
| 34 | +# as for the Lambda layer. |
| 35 | +# --------------------------------------------------------- |
| 36 | +init: |
| 37 | + make api-clean |
| 38 | + npm install && \ |
| 39 | + $(PYTHON) -m venv venv && \ |
| 40 | + $(ACTIVATE_VENV) && \ |
| 41 | + $(PIP) install --upgrade pip && \ |
| 42 | + $(PIP) install -r requirements.txt && \ |
| 43 | + deactivate && \ |
| 44 | + cd ./api/terraform/python/layer_genai/ && \ |
| 45 | + $(PYTHON) -m venv venv && \ |
| 46 | + $(ACTIVATE_VENV) && \ |
| 47 | + $(PIP) install --upgrade pip && \ |
| 48 | + $(PIP) install -r requirements.txt && \ |
| 49 | + $(PYTHON) -m spacy download en_core_web_sm |
| 50 | + deactivate && \ |
| 51 | + pre-commit install |
| 52 | + |
| 53 | +lint: |
| 54 | + terraform fmt -recursive |
| 55 | + pre-commit run --all-files |
| 56 | + black ./api/terraform/python/ |
| 57 | + flake8 api/terraform/python/ |
| 58 | + pylint api/terraform/python/openai_api/**/*.py |
| 59 | + |
| 60 | +clean: |
| 61 | + rm -rf venv |
| 62 | + rm -rf ./api/terraform/python/layer_genai/venv |
| 63 | + rm -rf ./api/terraform/build/ |
| 64 | + mkdir -p ./api/terraform/build/ |
| 65 | + find ./api/terraform/python/ -name __pycache__ -type d -exec rm -rf {} + |
| 66 | + |
| 67 | + |
| 68 | +###################### |
| 69 | +# HELP |
| 70 | +###################### |
| 71 | + |
| 72 | +help: |
| 73 | + @echo '====================================================================' |
| 74 | + @echo 'clean - remove all build, test, coverage and Python artifacts' |
| 75 | + @echo 'lint - run all code linters and formatters' |
| 76 | + @echo 'init - create environments for Python, NPM and pre-commit and install dependencies' |
| 77 | + @echo 'build - create and configure AWS infrastructure resources and build the React app' |
| 78 | + @echo 'run - run the web app in development mode' |
| 79 | + @echo 'analyze - generate code analysis report' |
| 80 | + @echo 'coverage - generate code coverage analysis report' |
| 81 | + @echo 'release - force a new release' |
| 82 | + @echo '-- AWS API Gateway + Lambda --' |
| 83 | + @echo 'api-init - create a Python virtual environment and install dependencies' |
| 84 | + @echo 'api-test - run Python unit tests' |
| 85 | + @echo 'api-lint - run Python linting' |
| 86 | + @echo 'api-clean - destroy the Python virtual environment' |
| 87 | + @echo '-- React App --' |
| 88 | + @echo 'client-clean - destroy npm environment' |
| 89 | + @echo 'client-init - run npm install' |
| 90 | + @echo 'client-lint - run npm lint' |
| 91 | + @echo 'client-update - update npm packages' |
| 92 | + @echo 'client-run - run the React app in development mode' |
| 93 | + @echo 'client-build - build the React app for production' |
| 94 | + @echo 'client-release - deploy the React app to AWS S3 and invalidate the Cloudfront CDN' |
0 commit comments