Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
179 lines (146 loc) · 5.59 KB
/
Copy pathMakefile
File metadata and controls
179 lines (146 loc) · 5.59 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
SHELL := /bin/bash
GIT_BRANCH := $(shell git branch --show-current)
PY_VENV := .venv/
UV_LOCKFILE := uv.lock
WEB_CANVAS_STEM := cm-canvas-bundle
WEB_PACKAGE_ROOT := packages/cm-web/
#------------------------------------------------------------------------------
# Default help target (thanks ChatGPT)
#------------------------------------------------------------------------------
help:
@echo "Available targets:"
@awk -F':' '/^[a-zA-Z0-9\._-]+:/ && !/^[ \t]*\.PHONY/ {print $$1}' $(MAKEFILE_LIST) | sort -u | column
#------------------------------------------------------------------------------
# DX: Use uv to bootstrap project
#------------------------------------------------------------------------------
$(UV_LOCKFILE):
uv lock --build-isolation
$(PY_VENV): $(UV_LOCKFILE)
uv sync --frozen --all-packages --all-extras
.PHONY: clean
clean:
rm -rf $(PY_VENV)
rm -f test_cm.db
rm -rf ./output
find src -type d -name '__pycache__' | xargs rm -rf
find tests -type d -name '__pycache__' | xargs rm -rf
find . -type f -name '.DS_Store' | xargs rm -rf
.PHONY: update-deps
update-deps:
uv lock --upgrade --build-isolation
.PHONY: init
init: $(PY_VENV)
uv run playwright install
uv run prek install -f
uv run prek install --prepare-hooks
.PHONY: update
update: update-deps init
.PHONY: build
build: export BUILDKIT_PROGRESS=plain
build: export COMPOSE_BAKE=true
build:
docker compose build cmservice
docker compose build cmworker
.PHONY: uv
uv:
script/bootstrap_uv
#------------------------------------------------------------------------------
# Target to create a "release" that consists of an increment of the version
# patch level in the appropriate file, a git commit and a matching git tag on
# the "main" trunk; else a prerelease version is created and no tag is created.
#------------------------------------------------------------------------------
.PHONY: release
release: export GIT_COMMIT_AUTHOR="$(shell git config user.name) <$(shell git config user.email)>"
release:
psr version --no-push --no-vcs-release --skip-build --no-changelog --no-tag
.PHONY: signed-release
signed-release: release
signed-release: export RELEASE_TAG=$(shell psr version --print-last-released)
signed-release:
git tag -d "$(RELEASE_TAG)" || true
git tag -s "$(RELEASE_TAG)" -m "Release $(RELEASE_TAG)"
#------------------------------------------------------------------------------
# Convenience targets to run pre-commit/prek hooks ("lint") and mypy ("typing")
#------------------------------------------------------------------------------
.PHONY: lint
lint:
prek run --all-files
.PHONY: typing
typing:
mypy
#------------------------------------------------------------------------------
# Targets for develpers to debug against a local Postgres run under docker
# compose. Can be used on local machines and in github CI, but not on USDF dev
# nodes since we can't run docker there.
#------------------------------------------------------------------------------
.PHONY: run-compose
run-compose:
docker compose up --wait
.PHONY: psql
psql: PGPORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
psql: export DB__PASSWORD=INSECURE-PASSWORD
psql: run-compose
psql postgresql://cm-service:${DB__PASSWORD}@localhost:${PGPORT}/cm-service
.PHONY: test
test: PGPORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
test: export DB__URL=postgresql://cm-service@localhost:${PGPORT}/cm-service
test: export DB__PASSWORD=INSECURE-PASSWORD
test: export DB__TABLE_SCHEMA=cm_service_test
test: export BPS__ARTIFACT_PATH=$(PWD)/output
test: run-compose
alembic upgrade head
pytest -vvv --asyncio-mode=auto --cov=lsst.cmservice --cov-branch --cov-report=term --cov-report=html ${PYTEST_ARGS}
.PHONY: run
run: PGPORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
run: export DB__URL=postgresql://cm-service@localhost:${PGPORT}/cm-service
run: export DB__PASSWORD=INSECURE-PASSWORD
run: export DB__ECHO=true
run: export FEATURE_API_V2=1
run: export FEATURE_API_V1=0
run: export FEATURE_DAEMON_V2=0
run: export FEATURE_STORE_FSM=1
run: run-compose
alembic upgrade head
python3 -m lsst.cmservice.main
.PHONY: run-worker
run-worker: PGPORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
run-worker: export DB__URL=postgresql://cm-service@localhost:${PGPORT}/cm-service
run-worker: export DB__PASSWORD=INSECURE-PASSWORD
run-worker: export DB__ECHO=true
run-worker: export FEATURE_API_V2=0
run-worker: export FEATURE_API_V1=0
run-worker: export FEATURE_DAEMON_V2=1
run-worker: export FEATURE_DAEMON_CAMPAIGNS=1
run-worker: export FEATURE_DAEMON_NODES=1
run-worker: export FEATURE_ALLOW_TASK_UPSERT=1
run-worker: export FEATURE_STORE_FSM=1
run-worker: run-compose
alembic upgrade head
python3 -m lsst.cmservice.daemon
.PHONY: docs
docs:
uv run script/render_jsonschema.py --clean --html
.PHONY: packages
packages:
$(MAKE) -C packages/cm-canvas rebuild
.PHONY: run-web
run-web: $(PY_VENV) docs packages
uv run web
.PHONY: migrate
migrate: export PGUSER=cm-service
migrate: export PGDATABASE=cm-service
migrate: export PGHOST=localhost
migrate: export DB__PORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
migrate: export DB__PASSWORD=INSECURE-PASSWORD
migrate: export DB__URL=postgresql://${PGHOST}/${PGDATABASE}
migrate: run-compose
alembic upgrade head
.PHONY: unmigrate
unmigrate: export PGUSER=cm-service
unmigrate: export PGDATABASE=cm-service
unmigrate: export PGHOST=localhost
unmigrate: export DB__PORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
unmigrate: export DB__PASSWORD=INSECURE-PASSWORD
unmigrate: export DB__URL=postgresql://${PGHOST}/${PGDATABASE}
unmigrate: run-compose
alembic downgrade base