-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
110 lines (90 loc) · 2.97 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
-include .env
export
APP_NAME ?= sde_prototype_govuk
ENV ?= development
FLASK_APP ?= $(APP_NAME):app
GOVUK_FRONTEND_VERSION ?= 4.3.1
GOVUK_PUBLISHING_COMPONENTS_VERSION ?= 30.6.1
PORT ?= 8000
STATIC ?= $(APP_NAME)/static
.PHONY: clean-python
clean-python:
find . \( -name '__pycache__' -and -not -name "venv" \) -d -prune -exec rm -r {} +
.PHONY: clean-static-assets
clean-static-assets:
rm -rf node_modules
rm -rf govuk_frontend
rm -rf govuk_publishing_components
rm -rf $(STATIC)/images $(STATIC)/fonts $(STATIC)/javascripts
flask assets clean
## clean: Remove temporary and generated files
.PHONY: clean
clean: clean-python clean-static-assets
.PHONY: python-deps
python-deps:
python -m pip install -U pip
python -m pip install -r requirements.txt
[ -f requirements-$(ENV).txt ] && python -m pip install -r requirements-$(ENV).txt
.PHONY: node-deps
node-deps:
npm install
# install: Install dependencies
.PHONY: install
install: python-deps node-deps
.PHONY: check
check:
black --check .
isort --check-only --profile=black --force-single-line-imports .
flake8 --max-line-length=88 --extend-ignore=E203
.PHONY: fix
fix:
pre-commit run --all-files
govuk_frontend:
mkdir -p govuk_frontend
curl -L -s https://github.com/alphagov/govuk-frontend/archive/refs/tags/v$(GOVUK_FRONTEND_VERSION).tar.gz | tar -xz --strip 1 -C govuk_frontend
govuk_publishing_components:
mkdir -p govuk_publishing_components
curl -L -s https://github.com/alphagov/govuk_publishing_components/archive/refs/tags/v$(GOVUK_PUBLISHING_COMPONENTS_VERSION).tar.gz | tar -xz --strip 1 -C govuk_publishing_components
rm -rf govuk_publishing_components/lib
.PHONY: consent_api
consent_api:
mkdir -p $(STATIC)/javascripts
cp node_modules/@alphagov/consent-api/client/src/singleconsent.js $(STATIC)/javascripts/
cp node_modules/@alphagov/consent-api/client/example/*.js $(STATIC)/javascripts/
.PHONY: assets
assets: govuk_frontend govuk_publishing_components consent_api
cp -f -R govuk_frontend/dist/assets/* $(STATIC)/
flask assets build
# test: Run tests
.PHONY: test
test:
pytest -x -n=auto --dist=loadfile -W ignore::DeprecationWarning
.PHONY: test-coverage
test-coverage:
pytest -n=auto --cov --cov-report=xml --cov-report=term -W ignore::DeprecationWarning
# run: Run development server
.PHONY: run
run:
flask --debug run --debugger --reload --host 0.0.0.0 --port $(PORT)
# docker-image: Build a Docker image
.PHONY: docker-image
docker-image: clean
docker buildx build \
--platform linux/amd64 \
--build-arg GOVUK_FRONTEND_VERSION=$(GOVUK_FRONTEND_VERSION) \
--build-arg GOVUK_PUBLISHING_COMPONENTS_VERSION=$(GOVUK_PUBLISHING_COMPONENTS_VERSION) \
-t $(APP_NAME) \
.
# docker-run: Start a Docker container
.PHONY: docker-run
docker-run:
docker run \
--rm \
--env CONSENT_API_HOST="$(CONSENT_API_HOST)" \
--env GUNICORN_CMD_ARGS="--bind=0.0.0.0:$(PORT)" \
-p $(PORT):$(PORT) \
$(APP_NAME)
## help: Show this message
.PHONY: help
help: Makefile
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'