-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (81 loc) · 2.99 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
# Define variables
ENV_FILE := .env
ENV := local
# Default target
all: build
# Setup the application
build: install_deps set_env $(ENV_FILE) assets migrate setup_waffle_switches messages
# Install Python dependencies
install_python_deps:
if ! command -v poetry >/dev/null 2>&1; then \
echo "Poetry is not installed. Please install it from https://python-poetry.org/docs/#installation"; \
exit 1; \
fi
poetry install --no-root
# Install Node.js dependencies
install_npm_deps:
if ! command -v npm >/dev/null 2>&1; then \
echo "npm is not installed. Please install it from https://nodejs.org/"; \
exit 1; \
fi
npm install
# Install dependencies
install_deps: install_npm_deps install_python_deps
if ! command -v op >/dev/null 2>&1; then \
echo "1password CLI is not installed. Please install it from https://1password.com/downloads/"; \
exit 1; \
fi
if ! command -v chromedriver >/dev/null 2>&1; then \
echo "Chromedriver is not installed. Please install it from https://sites.google.com/a/chromium.org/chromedriver/downloads"; \
exit 1; \
fi
# Generate .env file
$(ENV_FILE): .env.tpl
@echo "Setting ENV to ${ENV}"
op inject --in-file .env.tpl --out-file $(ENV_FILE)
@echo "Optionally, set CATALOGUE_TOKEN in ${ENV_FILE}"
# Collect static files
assets:
npm run dependencies
poetry run python manage.py collectstatic --noinput
# Run migrations
migrate:
poetry run python manage.py migrate
# Setup waffle switches
setup_waffle_switches:
poetry run python manage.py waffle_switch search-sort-radio-buttons off --create
poetry run python manage.py waffle_switch display-result-tags off --create
poetry run python manage.py waffle_switch show_is_nullable_in_table_details_column off --create
# Run makemessages
messages:
poetry run python manage.py makemessages --locale=en --ignore venv
poetry run python manage.py compilemessages --ignore venv
compilemessages:
poetry run python manage.py compilemessages --ignore venv
# Run the application
run:
poetry run python manage.py runserver
# Run unit tests
test: unit integration lint
# Run Python and Javascript unit tests
unit:
poetry run pytest --cov -m 'not slow and not datahub' --doctest-modules
npm test
# Run integration tests. Requires chromedriver - version works with chromedriver 127.0.1 use - `npm install -g [email protected]`
integration:
TESTING=true poetry run pytest tests/integration --axe-version 4.9.1 --chromedriver-path $$(which chromedriver)
end_to_end:
TESTING=true poetry run pytest tests/end_to_end --chromedriver-path $$(which chromedriver)
# Get npm cache directory and store it in a file
export_npm_cache_dir:
@echo "Fetching npm cache directory..."
@npm config get cache > .npm_cache_dir
@echo "NPM cache directory stored in .npm_cache_dir"
# Clean up (optional)
clean:
rm -rf staticfiles
rm -f $(ENV_FILE)
find . -name "*.pyc" -exec rm -f {} \;
lint:
pre-commit run --all-files
.PHONY: all build install_deps set_env assets migrate setup_waffle_switches messages compilemessages run test unit integration clean lint