|
1 | 1 | SERVICES_DIR := services |
| 2 | +SERVICES := $(shell ls $(SERVICES_DIR)) |
2 | 3 |
|
3 | | -install: |
4 | | - # install core |
| 4 | +INSTALL_TARGETS := $(addprefix install-,$(SERVICES)) |
| 5 | +INSTALL_DEV_TARGETS := $(addprefix install-dev-,$(SERVICES)) |
| 6 | +TEST_TARGETS := $(addprefix test-,$(SERVICES)) |
| 7 | +LINT_TARGETS := $(addprefix lint-,$(SERVICES)) |
| 8 | +UPDATE_TARGETS := $(addprefix update-dependencies-,$(SERVICES)) |
| 9 | + |
| 10 | +.PHONY: install install-core $(INSTALL_TARGETS) |
| 11 | +install: install-core $(INSTALL_TARGETS) |
| 12 | + |
| 13 | +install-core: |
5 | 14 | uv sync --no-dev --directory core/ |
6 | | - # install services |
7 | | - @for f in $(shell ls ${SERVICES_DIR}); do uv sync --no-dev --directory ${SERVICES_DIR}/$${f}; done |
8 | 15 |
|
9 | | -install-dev: |
10 | | - # install services |
11 | | - @for f in $(shell ls ${SERVICES_DIR}); do set -e;uv sync --frozen --directory ${SERVICES_DIR}/$${f}; done |
| 16 | +$(INSTALL_TARGETS): install-%: |
| 17 | + # install service $* |
| 18 | + uv sync --no-dev --directory $(SERVICES_DIR)/$* |
| 19 | + |
| 20 | +.PHONY: install-dev $(INSTALL_DEV_TARGETS) |
| 21 | +install-dev: $(INSTALL_DEV_TARGETS) |
12 | 22 | # install core. This needs to be done last or it will get overriden by the dependency installation of the services |
13 | 23 | uv sync --frozen --directory core |
14 | 24 |
|
15 | | -test-services: |
16 | | - # test core |
| 25 | +$(INSTALL_DEV_TARGETS): install-dev-%: |
| 26 | + # install service $* |
| 27 | + uv sync --frozen --directory $(SERVICES_DIR)/$* |
| 28 | + |
| 29 | +.PHONY: test-services test-core $(TEST_TARGETS) |
| 30 | +test-services: test-core $(TEST_TARGETS) |
| 31 | + |
| 32 | +test-core: |
17 | 33 | cd core && uv run pytest |
18 | | - # test services |
19 | | - @for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f}; sh -c ' uv run pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..; done |
20 | 34 |
|
21 | | -lint-services: |
22 | | - # lint core |
| 35 | +$(TEST_TARGETS): test-%: |
| 36 | + # test service $* |
| 37 | + cd $(SERVICES_DIR)/$* && sh -c 'uv run pytest || ([ $$? = 5 ] && exit 0 || exit $$?)' |
| 38 | + |
| 39 | +.PHONY: lint-services lint-core lint-examples lint-versions $(LINT_TARGETS) |
| 40 | +lint-services: lint-core lint-examples $(LINT_TARGETS) lint-versions |
| 41 | + |
| 42 | +lint-core: |
23 | 43 | cd core && uv run flake8 . |
| 44 | + |
| 45 | +lint-examples: |
24 | 46 | # lint examples. Use configuration from core |
25 | | - cd core && uv run flake8 --toml-config pyproject.toml --black-config pyproject.toml ../examples; |
26 | | - # lint services |
27 | | - @for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};uv run flake8 .; cd ../..; done |
| 47 | + cd core && uv run flake8 --toml-config pyproject.toml --black-config pyproject.toml ../examples |
| 48 | + |
| 49 | +$(LINT_TARGETS): lint-%: |
| 50 | + # lint service $* |
| 51 | + cd $(SERVICES_DIR)/$* && uv run flake8 . |
| 52 | + |
| 53 | +lint-versions: |
28 | 54 | # lint versions |
29 | | - @./scripts/lint-versions.sh |
| 55 | + ./scripts/lint-versions.sh |
30 | 56 |
|
| 57 | +# Old parameterized targets for single service, aliased to pattern rules |
31 | 58 | test: |
32 | | - echo "Testing service ${service}" |
33 | | - cd ${SERVICES_DIR}/${service}; sh -c ' uv run pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..; |
| 59 | + $(MAKE) test-$(service) |
34 | 60 |
|
35 | 61 | lint: |
36 | | - echo "Linting service ${service}" |
37 | | - cd ${SERVICES_DIR}/${service};uv run flake8 .; cd ../..; |
| 62 | + $(MAKE) lint-$(service) |
| 63 | + |
| 64 | +.PHONY: update-dependencies update-dependencies-core $(UPDATE_TARGETS) |
| 65 | +update-dependencies: update-dependencies-core $(UPDATE_TARGETS) |
38 | 66 |
|
39 | | -update-dependencies: |
40 | | - # lock core |
| 67 | +update-dependencies-core: |
41 | 68 | cd core && uv lock |
42 | | - # lock services |
43 | | - @for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};uv lock; cd ../..; done |
| 69 | + |
| 70 | +$(UPDATE_TARGETS): update-dependencies-%: |
| 71 | + # lock service $* |
| 72 | + cd $(SERVICES_DIR)/$* && uv lock |
0 commit comments