Files
notifications-api/Makefile
T

113 lines
3.4 KiB
Makefile
Raw Normal View History

.DEFAULT_GOAL := help
SHELL := /bin/bash
DATE = $(shell date +%Y-%m-%d:%H:%M:%S)
APP_VERSION_FILE = app/version.py
2016-08-26 16:18:04 +01:00
GIT_BRANCH ?= $(shell git symbolic-ref --short HEAD 2> /dev/null || echo "detached")
GIT_COMMIT ?= $(shell git rev-parse HEAD)
2020-03-03 11:51:50 +00:00
## DEVELOPMENT
2021-02-17 17:22:45 +00:00
.PHONY: bootstrap
2022-10-26 14:05:37 +00:00
bootstrap: ## Set up everything to run the app
2022-10-26 15:26:53 -04:00
make generate-version-file
2022-10-26 15:34:12 -04:00
pipenv install --dev
2021-02-18 15:19:40 +00:00
createdb notification_api || true
2022-10-26 14:05:37 +00:00
(pipenv run flask db upgrade) || true
2021-02-17 17:22:45 +00:00
2022-02-24 17:11:46 +00:00
.PHONY: bootstrap-with-docker
bootstrap-with-docker: ## Build the image to run the app in Docker
docker build -f docker/Dockerfile -t notifications-api .
2022-11-01 09:54:31 -04:00
.PHONY: run-procfile
run-procfile:
pipenv run honcho start -f Procfile.dev
2021-02-17 16:49:05 +00:00
.PHONY: run-flask
run-flask: ## Run flask
2023-01-17 14:08:17 -05:00
pipenv run newrelic-admin run-program flask run -p 6011 --host=0.0.0.0
2021-02-17 16:49:05 +00:00
.PHONY: run-celery
2022-06-13 13:45:07 -07:00
run-celery: ## Run celery, TODO remove purge for staging/prod
2022-10-26 14:05:37 +00:00
pipenv run celery -A run_celery.notify_celery purge -f
2023-01-17 14:08:17 -05:00
pipenv run newrelic-admin run-program celery \
2021-02-17 16:49:05 +00:00
-A run_celery.notify_celery worker \
--pidfile="/tmp/celery.pid" \
--loglevel=INFO \
--concurrency=4
.PHONY: run-celery-beat
run-celery-beat: ## Run celery beat
2023-01-18 10:03:45 -05:00
pipenv run celery \
2022-06-13 13:45:07 -07:00
-A run_celery.notify_celery beat \
--loglevel=INFO
2021-02-17 16:49:05 +00:00
2023-05-09 21:54:22 -04:00
.PHONY: cloudgov-user-report
2023-05-09 21:44:15 -04:00
cloudgov-user-report:
@pipenv run python -m terraform.ops.cloudgov_user_report
.PHONY: help
help:
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: generate-version-file
generate-version-file: ## Generates the app version file
@echo -e "__git_commit__ = \"${GIT_COMMIT}\"\n__time__ = \"${DATE}\"" > ${APP_VERSION_FILE}
.PHONY: test
2023-01-17 14:08:17 -05:00
test: export NEW_RELIC_ENVIRONMENT=test
test: ## Run tests and create coverage report
2022-10-28 12:58:07 +00:00
pipenv run flake8 .
pipenv run isort --check-only ./app ./tests
2023-08-15 10:35:34 -07:00
pipenv run coverage run -m pytest -vv --maxfail=10
pipenv run coverage report -m --fail-under=95
pipenv run coverage html -d .coverage_cache
.PHONY: freeze-requirements
2019-10-28 11:26:55 +00:00
freeze-requirements: ## Pin all requirements including sub dependencies into requirements.txt
2022-10-26 14:05:37 +00:00
pipenv lock
pipenv requirements
2022-08-12 15:12:07 +00:00
.PHONY: audit
audit:
2022-10-26 14:05:37 +00:00
pipenv requirements > requirements.txt
pipenv requirements --dev > requirements_for_test.txt
pipenv run pip-audit -r requirements.txt
2023-01-03 09:44:53 -05:00
-pipenv run pip-audit -r requirements_for_test.txt
2022-08-12 15:12:07 +00:00
2022-08-12 17:19:28 -04:00
.PHONY: static-scan
static-scan:
2022-10-28 12:58:07 +00:00
pipenv run bandit -r app/
2022-08-12 17:19:28 -04:00
2016-12-08 12:12:45 +00:00
.PHONY: clean
clean:
2020-12-07 17:51:15 +00:00
rm -rf node_modules cache target venv .coverage build tests/.cache ${CF_MANIFEST_PATH}
2016-12-08 12:12:45 +00:00
2020-03-03 11:51:50 +00:00
## DEPLOYMENT
2022-10-20 14:04:10 -04:00
# .PHONY: cf-deploy-failwhale
# cf-deploy-failwhale:
# $(if ${CF_SPACE},,$(error Must target space, eg `make preview cf-deploy-failwhale`))
# cd ./paas-failwhale; cf push notify-api-failwhale -f manifest.yml
2020-05-11 18:53:52 +01:00
2022-10-20 14:04:10 -04:00
# .PHONY: enable-failwhale
# enable-failwhale: ## Enable the failwhale app and disable api
# $(if ${DNS_NAME},,$(error Must target space, eg `make preview enable-failwhale`))
# # make sure failwhale is running first
# cf start notify-api-failwhale
2020-05-11 18:53:52 +01:00
2022-10-20 14:04:10 -04:00
# cf map-route notify-api-failwhale ${DNS_NAME} --hostname api
# cf unmap-route notify-api ${DNS_NAME} --hostname api
# @echo "Failwhale is enabled"
2020-05-11 18:53:52 +01:00
2022-10-20 14:04:10 -04:00
# .PHONY: disable-failwhale
# disable-failwhale: ## Disable the failwhale app and enable api
# $(if ${DNS_NAME},,$(error Must target space, eg `make preview disable-failwhale`))
2020-05-11 18:53:52 +01:00
2022-10-20 14:04:10 -04:00
# cf map-route notify-api ${DNS_NAME} --hostname api
# cf unmap-route notify-api-failwhale ${DNS_NAME} --hostname api
# cf stop notify-api-failwhale
# @echo "Failwhale is disabled"