forked from pypi/warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (95 loc) · 4.42 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
DB := example
IPYTHON := no
# set environment variable WAREHOUSE_IPYTHON_SHELL=1 if IPython
# needed in development environment
ifeq ($(WAREHOUSE_IPYTHON_SHELL), 1)
IPYTHON = yes
endif
default:
@echo "Call a specific subcommand:"
@echo
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null\
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}'\
| sort\
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@echo
@exit 1
.state/docker-build-web: Dockerfile package.json package-lock.json requirements/main.txt requirements/deploy.txt requirements/lint.txt requirements/tests.txt
# Build our web container for this project.
docker compose build --build-arg IPYTHON=$(IPYTHON) --force-rm web
# Mark the state so we don't rebuild this needlessly.
mkdir -p .state
touch .state/docker-build-web
.state/docker-build-static: Dockerfile package.json package-lock.json .babelrc
# Build our static container for this project.
docker compose build --force-rm static
# Mark the state so we don't rebuild this needlessly.
mkdir -p .state
touch .state/docker-build-static
.state/docker-build-docs: Dockerfile requirements/docs/dev.txt requirements/docs/blog.txt requirements/docs/user.txt
# Build the worker container for this project
docker compose build --build-arg USER_ID=$(shell id -u) --build-arg GROUP_ID=$(shell id -g) --force-rm dev-docs
# Mark the state so we don't rebuild this needlessly.
mkdir -p .state
touch .state/docker-build-docs
.state/docker-build: .state/docker-build-web .state/docker-build-static .state/docker-build-docs
# Build the worker container for this project
docker compose build --force-rm worker
# Mark the state so we don't rebuild this needlessly.
mkdir -p .state
touch .state/docker-build
build:
@$(MAKE) .state/docker-build
docker system prune -f --filter "label=com.docker.compose.project=warehouse"
serve: .state/docker-build
docker compose up --remove-orphans
debug: .state/docker-build-web
docker compose run --rm --service-ports web
tests: .state/docker-build-web
docker compose run --rm web bin/tests --postgresql-host db $(T) $(TESTARGS)
static_tests: .state/docker-build-static
docker compose run --rm static bin/static_tests $(T) $(TESTARGS)
static_pipeline: .state/docker-build-static
docker compose run --rm static bin/static_pipeline $(T) $(TESTARGS)
reformat: .state/docker-build-web
docker compose run --rm web bin/reformat
lint: .state/docker-build-web
docker compose run --rm web bin/lint
docker compose run --rm static bin/static_lint
dev-docs: .state/docker-build-docs
docker compose run --rm dev-docs bin/dev-docs
user-docs: .state/docker-build-docs
docker compose run --rm user-docs bin/user-docs
blog: .state/docker-build-docs
docker compose run --rm blog mkdocs build -f docs/mkdocs-blog.yml
licenses: .state/docker-build-web
docker compose run --rm web bin/licenses
deps: .state/docker-build-web
docker compose run --rm web bin/deps
translations: .state/docker-build-web
docker compose run --rm web bin/translations
requirements/%.txt: requirements/%.in
docker compose run --rm web bin/pip-compile --allow-unsafe --generate-hashes --output-file=$@ $<
initdb: .state/docker-build-web
docker compose run --rm web psql -h db -d postgres -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname ='warehouse';"
docker compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS warehouse"
docker compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'"
docker compose run --rm web bash -c "xz -d -f -k dev/$(DB).sql.xz --stdout | psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f -"
docker compose run --rm web psql -h db -d warehouse -U postgres -c "UPDATE users SET name='Ee Durbin' WHERE username='ewdurbin'"
docker compose run --rm web python -m warehouse db upgrade head
docker compose run --rm web python -m warehouse sponsors populate-db
docker compose run --rm web python -m warehouse classifiers sync
$(MAKE) reindex
reindex: .state/docker-build-web
docker compose run --rm web python -m warehouse search reindex
shell: .state/docker-build-web
docker compose run --rm web python -m warehouse shell
clean:
rm -rf dev/*.sql
purge: stop clean
rm -rf .state
docker compose down -v
docker compose rm --force
stop:
docker compose stop
.PHONY: default build serve initdb shell tests dev-docs user-docs deps clean purge debug stop compile-pot